Skip to content

Commit 287488f

Browse files
authored
Core runtime changes for Windows MSVC support
Differential Revision: D65328601 Pull Request resolved: #6624
1 parent 11d1742 commit 287488f

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
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: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,16 @@ 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+
MemoryAllocator* constant_allocator,
7571
HierarchicalAllocator* non_constant_allocator,
7672
MemoryAllocator* runtime_allocator,
7773
MemoryAllocator* temporary_allocator)
7874
: MemoryManager(
7975
/*method_allocator=*/runtime_allocator,
8076
/*planned_memory=*/non_constant_allocator,
81-
/*temp_allocator=*/temporary_allocator) {}
77+
/*temp_allocator=*/temporary_allocator) {
78+
(void)constant_allocator; // Suppress unused variable warning
79+
}
8280

8381
/**
8482
* Returns the allocator that the runtime will use to allocate internal

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();

0 commit comments

Comments
 (0)