Skip to content

Commit c1b305e

Browse files
committed
Update
[ghstack-poisoned]
1 parent 5b97ef5 commit c1b305e

File tree

4 files changed

+10
-45
lines changed

4 files changed

+10
-45
lines changed

runtime/core/exec_aten/util/dim_order_util.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -260,35 +260,6 @@ ET_NODISCARD inline Error stride_to_dim_order(
260260
return Error::Ok;
261261
}
262262

263-
/**
264-
* Print a string representation of an ArrayRef of tensor sizes into a
265-
* user-provided string buffer. If the user buffer is too small, the string
266-
* will be truncated. The output is of the format (1,2,3,4).
267-
*
268-
* Note that we cannot use ArrayRef here due to a circular dependency (see
269-
* above comments).
270-
*/
271-
template <class SizesType>
272-
inline void sizes_to_string(
273-
char* output,
274-
size_t output_size,
275-
SizesType* sizes,
276-
size_t rank) {
277-
auto remaining_size = output_size;
278-
for (auto i = 0; remaining_size > 0 && i < rank; i++) {
279-
snprintf(
280-
output,
281-
remaining_size,
282-
"%s%zd",
283-
i == 0 ? "(" : ",",
284-
static_cast<size_t>(sizes[i]));
285-
auto len = strlen(output);
286-
output += len;
287-
remaining_size -= len;
288-
}
289-
snprintf(output, remaining_size, ")");
290-
}
291-
292263
} // namespace runtime
293264
} // namespace executorch
294265

runtime/core/exec_aten/util/tensor_shape_to_c_string.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#include "tensor_util.h"
2-
31
/*
42
* Copyright (c) Meta Platforms, Inc. and affiliates.
53
* All rights reserved.
@@ -8,7 +6,7 @@
86
* LICENSE file in the root directory of this source tree.
97
*/
108

11-
#include <executorch/runtime/core/exec_aten/util/tensor_util.h>
9+
#include <executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h>
1210

1311
#include <executorch/runtime/platform/assert.h>
1412

runtime/core/portable_type/targets.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ def define_common_targets():
3232
":scalar_type",
3333
"//executorch/runtime/core:core",
3434
"//executorch/runtime/core:tensor_shape_dynamism",
35-
"//executorch/runtime/core/exec_aten/util:scalar_type_util",
3635
"//executorch/runtime/core/exec_aten/util:dim_order_util",
36+
"//executorch/runtime/core/exec_aten/util:scalar_type_util",
37+
"//executorch/runtime/core/exec_aten/util:tensor_shape_to_c_string",
3738
"//executorch/runtime/core:tag",
3839
],
3940
)

runtime/core/portable_type/tensor_impl.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <executorch/runtime/core/exec_aten/util/dim_order_util.h>
1515
#include <executorch/runtime/core/exec_aten/util/scalar_type_util.h>
16+
#include <executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h>
1617
#include <executorch/runtime/core/portable_type/qint_types.h>
1718
#include <executorch/runtime/core/portable_type/scalar_type.h>
1819
#include <executorch/runtime/platform/assert.h>
@@ -95,18 +96,12 @@ Error TensorImpl::internal_resize_contiguous(ArrayRef<SizesType> new_sizes) {
9596
case TensorShapeDynamism::STATIC:
9697
if (!std::equal(sizes_, sizes_ + dim_, new_sizes.begin())) {
9798
#ifdef ET_LOG_ENABLED
98-
std::array<char, 16> old_sizes_str, new_sizes_str;
99-
100-
executorch::runtime::sizes_to_string(
101-
old_sizes_str.data(),
102-
old_sizes_str.size(),
103-
sizes().data(),
104-
sizes().size());
105-
executorch::runtime::sizes_to_string(
106-
new_sizes_str.data(),
107-
new_sizes_str.size(),
108-
new_sizes.data(),
109-
new_sizes.size());
99+
auto old_sizes_str = executorch::runtime::tensor_shape_to_c_string(
100+
executorch::runtime::Span<const executorch::aten::SizesType>(
101+
sizes().data(), sizes().size()));
102+
auto new_sizes_str = executorch::runtime::tensor_shape_to_c_string(
103+
executorch::runtime::Span<const executorch::aten::SizesType>(
104+
new_sizes.data(), new_sizes.size()));
110105
#endif
111106

112107
ET_CHECK_OR_RETURN_ERROR(

0 commit comments

Comments
 (0)