From 1918e8aabf76cd74e7b5bc9839cd14b3db376ca6 Mon Sep 17 00:00:00 2001 From: Kevin Cheng Date: Wed, 15 Sep 2021 10:17:39 -0700 Subject: Add maximum dimension check ERROR_IF in RESIZE. Signed-off-by: Kevin Cheng Change-Id: Iccbabe4298de4bd681115e273c16c48ea6d3028e --- reference_model/src/ops/image.cc | 4 ++++ 1 file changed, 4 insertions(+) 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::eval() int out_width = out->getShape()[2]; int out_channels = out->getShape()[3]; + ERROR_IF(std::max({ 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::eval() int out_width = out->getShape()[2]; int out_channels = out->getShape()[3]; + ERROR_IF(std::max({ 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"); -- cgit v1.2.1