diff --git a/kernels/quantized/cpu/op_quantize.cpp b/kernels/quantized/cpu/op_quantize.cpp index 74654ffafee..0b1b5c5529c 100644 --- a/kernels/quantized/cpu/op_quantize.cpp +++ b/kernels/quantized/cpu/op_quantize.cpp @@ -281,7 +281,7 @@ Tensor& quantize_per_channel_out( check_quantize_per_tensor_args(input, quant_min, quant_max, dtype, out); // a list contains all dimensions except axis - int64_t dims[input.dim() - 1]; + int64_t dims[kTensorDimensionLimit]; for (int64_t i = 0; i < input.dim() - 1; i++) { if (i < axis) { dims[i] = i; diff --git a/runtime/core/portable_type/tensor_impl.cpp b/runtime/core/portable_type/tensor_impl.cpp index 2082b8a4c70..689a37cb5d8 100644 --- a/runtime/core/portable_type/tensor_impl.cpp +++ b/runtime/core/portable_type/tensor_impl.cpp @@ -110,8 +110,11 @@ Error TensorImpl::internal_resize_contiguous(ArrayRef new_sizes) { numel_bound_); if (strides_ && dim_order_) { - ET_CHECK_OK_OR_RETURN_ERROR( - dim_order_to_stride(new_sizes.data(), dim_order_, dim_, strides_)); + auto error = + dim_order_to_stride(new_sizes.data(), dim_order_, dim_, strides_); + if (error != Error::Ok) { + return error; + } } numel_ = new_numel; std::copy(new_sizes.begin(), new_sizes.end(), sizes_); diff --git a/runtime/executor/memory_manager.h b/runtime/executor/memory_manager.h index 1d3d7a6ffbe..42edd9f0bea 100644 --- a/runtime/executor/memory_manager.h +++ b/runtime/executor/memory_manager.h @@ -67,18 +67,16 @@ class MemoryManager final { * TODO(T162089316): Remove this once all users migrate to the new ctor. */ ET_DEPRECATED MemoryManager( - // We would normally use ET_UNUSED here, but GCC older than 9.3 has a - // bug that triggers a syntax error when using [[maybe_unused]] on the - // first parameter of a constructor: - // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429 - __attribute__((unused)) MemoryAllocator* constant_allocator, + MemoryAllocator* constant_allocator, HierarchicalAllocator* non_constant_allocator, MemoryAllocator* runtime_allocator, MemoryAllocator* temporary_allocator) : MemoryManager( /*method_allocator=*/runtime_allocator, /*planned_memory=*/non_constant_allocator, - /*temp_allocator=*/temporary_allocator) {} + /*temp_allocator=*/temporary_allocator) { + (void)constant_allocator; // Suppress unused variable warning + } /** * Returns the allocator that the runtime will use to allocate internal diff --git a/runtime/executor/program.cpp b/runtime/executor/program.cpp index 0a15b0d0f7f..7eb646059d6 100644 --- a/runtime/executor/program.cpp +++ b/runtime/executor/program.cpp @@ -88,7 +88,11 @@ Result get_execution_plan( } else if (eh.error() == Error::NotFound) { // No header; the program consumes the whole file, and there are no // segments. - program_size = ET_UNWRAP(loader->size()); + auto result = loader->size(); + if (!result.ok()) { + return result.error(); + } + program_size = result.get(); } else { ET_LOG(Error, "Extended header may be corrupt"); return eh.error();