Skip to content

Commit b7cc2df

Browse files
committed
Make deform_conv_attributes.h self-contained for numeric_limits
1 parent 8aeb21d commit b7cc2df

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

onnxruntime/core/providers/cpu/nn/deform_conv_attributes.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#pragma once
55

6-
#include <climits>
6+
#include <limits>
77

88
#include "core/common/common.h"
99
#include "core/framework/op_kernel.h"
@@ -194,10 +194,10 @@ inline Status DeformConvValidateAndParse(
194194
params.out_w = (params.W_in + params.pad_w + params.pad_w_end - params.dilation_w * (params.kW - 1) - 1) / params.stride_w + 1;
195195
ORT_RETURN_IF_NOT(params.out_h >= 0 && params.out_w >= 0, "Computed output spatial size must be non-negative.");
196196

197-
// CPU BilinearInterpolate uses int for indices (for performance optimization); W <= INT_MAX / (H+1) covers all index math.
197+
// CPU BilinearInterpolate uses int for indices (for performance optimization); W <= int_max / (H+1) covers all index math.
198198
ORT_RETURN_IF_NOT(params.H >= 0 && params.W_in >= 0, "Input spatial dimensions H and W must be non-negative.");
199-
ORT_RETURN_IF_NOT(params.W_in <= static_cast<int64_t>(INT_MAX) / (params.H + 1),
200-
"Input (H+1)*W must not exceed INT_MAX (for performance optimization).");
199+
ORT_RETURN_IF_NOT(params.W_in <= static_cast<int64_t>(std::numeric_limits<int>::max()) / (params.H + 1),
200+
"Input (H+1)*W must not exceed int max (for performance optimization).");
201201

202202
// Validate tensor shapes (use division to avoid int64 overflow in offset_group * 2 * kH * kW).
203203
ORT_RETURN_IF_NOT(offset_shape[0] == params.N, "Offset batch size must match input batch size.");

0 commit comments

Comments
 (0)