aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Cheng <kevin.cheng@arm.com>2021-09-15 10:17:39 -0700
committerKevin Cheng <kevin.cheng@arm.com>2021-09-20 13:39:06 -0700
commit1918e8aabf76cd74e7b5bc9839cd14b3db376ca6 (patch)
tree94ed8b0fe8d0800a1944bba2ff3a3ecab59d0750
parentc94e63dc274e1681f20c3fed1837ea49452d03ed (diff)
downloadreference_model-1918e8aabf76cd74e7b5bc9839cd14b3db376ca6.tar.gz
Add maximum dimension check ERROR_IF in RESIZE.
Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: Iccbabe4298de4bd681115e273c16c48ea6d3028e
-rw-r--r--reference_model/src/ops/image.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/reference_model/src/ops/image.cc b/reference_model/src/ops/image.cc
index f4decae..72647cc 100644
--- a/reference_model/src/ops/image.cc
+++ b/reference_model/src/ops/image.cc
@@ -105,6 +105,8 @@ int OpResize<InDtype, OutDtype>::eval()
int out_width = out->getShape()[2];
int out_channels = out->getShape()[3];
+ ERROR_IF(std::max<int>({ in_height, in_width, out_height, out_width }) >= 16384,
+ "OpResize: exceeds maximum dimension");
ERROR_IF(shift < 1 || shift > 11, "OpResize: attribute shift should be within [1, 11]");
ERROR_IF(stride[0] <= 0 || stride[0] >= (16 << shift), "OpResize: invalid attribute stride_x");
ERROR_IF(stride[1] <= 0 || stride[1] >= (16 << shift), "OpResize: invalid attribute stride_y");
@@ -173,6 +175,8 @@ int OpResize<DType_FLOAT, DType_FLOAT>::eval()
int out_width = out->getShape()[2];
int out_channels = out->getShape()[3];
+ ERROR_IF(std::max<int>({ in_height, in_width, out_height, out_width }) >= 16384,
+ "OpResize: exceeds maximum dimension");
ERROR_IF(shift != 0, "OpResize: float mode must have 0 shift");
ERROR_IF(stride_fp[0] <= 0.0f || stride_fp[1] <= 0.0f, "OpResize: invalid attribute stride");
ERROR_IF(in_batch != out_batch, "OpResize: output tensor batch mismatch");