Skip to content

Commit 1820d3b

Browse files
tarun292facebook-github-bot
authored andcommitted
Core runtime changes for Windows MSVC support (#6624)
Summary: Miscellaneous core runtime fixes to make sure we can build with MSVC. Differential Revision: D65328601
1 parent 914091f commit 1820d3b

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

kernels/quantized/cpu/op_quantize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ Tensor& quantize_per_channel_out(
281281
check_quantize_per_tensor_args(input, quant_min, quant_max, dtype, out);
282282

283283
// a list contains all dimensions except axis
284-
int64_t dims[input.dim() - 1];
284+
int64_t dims[kTensorDimensionLimit];
285285
for (int64_t i = 0; i < input.dim() - 1; i++) {
286286
if (i < axis) {
287287
dims[i] = i;

runtime/core/portable_type/tensor_impl.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ Error TensorImpl::internal_resize_contiguous(ArrayRef<SizesType> new_sizes) {
110110
numel_bound_);
111111

112112
if (strides_ && dim_order_) {
113-
ET_CHECK_OK_OR_RETURN_ERROR(
114-
dim_order_to_stride(new_sizes.data(), dim_order_, dim_, strides_));
113+
auto error =
114+
dim_order_to_stride(new_sizes.data(), dim_order_, dim_, strides_);
115+
if (error != Error::Ok) {
116+
return error;
117+
}
115118
}
116119
numel_ = new_numel;
117120
std::copy(new_sizes.begin(), new_sizes.end(), sizes_);

runtime/executor/memory_manager.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ class MemoryManager final {
6767
* TODO(T162089316): Remove this once all users migrate to the new ctor.
6868
*/
6969
ET_DEPRECATED MemoryManager(
70-
// We would normally use ET_UNUSED here, but GCC older than 9.3 has a
71-
// bug that triggers a syntax error when using [[maybe_unused]] on the
72-
// first parameter of a constructor:
73-
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429
74-
__attribute__((unused)) MemoryAllocator* constant_allocator,
70+
ET_UNUSED MemoryAllocator* constant_allocator,
7571
HierarchicalAllocator* non_constant_allocator,
7672
MemoryAllocator* runtime_allocator,
7773
MemoryAllocator* temporary_allocator)

runtime/executor/program.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ Result<executorch_flatbuffer::ExecutionPlan*> get_execution_plan(
8686
} else if (eh.error() == Error::NotFound) {
8787
// No header; the program consumes the whole file, and there are no
8888
// segments.
89-
program_size = ET_UNWRAP(loader->size());
89+
auto result = loader->size();
90+
if (!result.ok()) {
91+
return result.error();
92+
}
93+
program_size = result.get();
9094
} else {
9195
ET_LOG(Error, "Extended header may be corrupt");
9296
return eh.error();

runtime/platform/compiler.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,15 @@
8080
[[deprecated("This API is experimental and may change without notice.")]]
8181
#define ET_FALLTHROUGH [[fallthrough]]
8282
#define ET_NODISCARD [[nodiscard]]
83+
84+
#if defined(__GNUC__) && (__GNUC__ < 9 || (__GNUC__ == 9 && __GNUC_MINOR__ < 3))
85+
// GCC older than 9.3 has a bug that triggers a syntax error when using [[maybe_unused]]
86+
// on the first parameter of a constructor:
87+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429
88+
#define ET_UNUSED __attribute__((unused))
89+
#else
8390
#define ET_UNUSED [[maybe_unused]]
91+
#endif
8492

8593
// UNLIKELY Macro
8694
// example

0 commit comments

Comments
 (0)