Skip to content

Commit f0a52f4

Browse files
tarun292facebook-github-bot
authored andcommitted
Core runtime changes for Windows MSVC support
Differential Revision: D65328601
1 parent 97a4600 commit f0a52f4

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

kernels/prim_ops/register_prim_ops.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static Kernel prim_ops[] = {
148148
EValue& out = *stack[2];
149149
if (a.isInt() && b.isInt()) {
150150
const int64_t quot = a.toInt() / b.toInt();
151-
if (std::signbit(a.toInt()) == std::signbit(b.toInt())) {
151+
if (std::signbit(static_cast<double>(a.toInt())) == std::signbit(static_cast<double>(b.toInt()))) {
152152
out = EValue(quot);
153153
return;
154154
}

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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ 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 = dim_order_to_stride(new_sizes.data(), dim_order_, dim_, strides_);
114+
if (error != Error::Ok) {
115+
return error;
116+
}
115117
}
116118
numel_ = new_numel;
117119
std::copy(new_sizes.begin(), new_sizes.end(), sizes_);

runtime/executor/memory_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class MemoryManager final {
7171
// bug that triggers a syntax error when using [[maybe_unused]] on the
7272
// first parameter of a constructor:
7373
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429
74-
__attribute__((unused)) MemoryAllocator* constant_allocator,
74+
__ET_UNUSED MemoryAllocator* constant_allocator,
7575
HierarchicalAllocator* non_constant_allocator,
7676
MemoryAllocator* runtime_allocator,
7777
MemoryAllocator* temporary_allocator)

runtime/executor/program.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
#define ET_ENABLE_PROGRAM_VERIFICATION 1
2828
#endif
2929

30+
#ifdef _MSC_VER
31+
#pragma warning(disable : 4456 4457)
32+
#else
3033
#pragma clang diagnostic ignored "-Wshadow"
34+
#endif
3135

3236
namespace executorch {
3337
namespace runtime {
@@ -88,7 +92,11 @@ Result<executorch_flatbuffer::ExecutionPlan*> get_execution_plan(
8892
} else if (eh.error() == Error::NotFound) {
8993
// No header; the program consumes the whole file, and there are no
9094
// segments.
91-
program_size = ET_UNWRAP(loader->size());
95+
auto result = loader->size();
96+
if (!result.ok()) {
97+
return result.error();
98+
}
99+
program_size = result.get();
92100
} else {
93101
ET_LOG(Error, "Extended header may be corrupt");
94102
return eh.error();

0 commit comments

Comments
 (0)