aboutsummaryrefslogtreecommitdiff
path: root/reference_model/src/ops/image.cc
diff options
context:
space:
mode:
authorKevin Cheng <kevin.cheng@arm.com>2021-06-29 15:32:19 -0700
committerKevin Cheng <kevin.cheng@arm.com>2021-08-20 18:07:06 +0100
commitacb550f4410ae861e53cae27a9feb4b11d45769f (patch)
treeae2f4ec558c2cdf1afa020b80a09d7ab4be5ef6d /reference_model/src/ops/image.cc
parent68e7aee65bda5ac03fa7def753b7dc7462554793 (diff)
downloadreference_model-acb550f4410ae861e53cae27a9feb4b11d45769f.tar.gz
Replace node level check ASSERT_MSG_NODE()/FATAL_ERROR_NODE() with REQUIRE() or ERROR_IF()
- Adding return code enum class: {VALID, UNPREDICTABLE, ERROR} - Runtime errors (e.g. memory allocation failure) will abort immediately, or will return one of the three return codes Part of the codes are re-written to pass REQUIRE() to the top-level (e.g. apply_scale_32/16()) - Update setExpectedFailure() to setExpectedReturnCode() on test generation script - Update test regression script to interface with reference model change Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: Ia063c936bcb2a54d6e379a5bb6801aa72d1186f1
Diffstat (limited to 'reference_model/src/ops/image.cc')
-rw-r--r--reference_model/src/ops/image.cc34
1 files changed, 20 insertions, 14 deletions
diff --git a/reference_model/src/ops/image.cc b/reference_model/src/ops/image.cc
index 829a6e0..f4decae 100644
--- a/reference_model/src/ops/image.cc
+++ b/reference_model/src/ops/image.cc
@@ -22,8 +22,11 @@ using namespace Eigen;
using namespace tosa;
template <DType InDtype, DType OutDtype>
-OpResize<InDtype, OutDtype>::OpResize(TosaAttributeBase* attribute_, TosaQuantInfoBase* qinfo_, uint64_t id_)
- : GraphNode(Op_RESIZE, id_)
+OpResize<InDtype, OutDtype>::OpResize(SubgraphTraverser* sgt_,
+ TosaAttributeBase* attribute_,
+ TosaQuantInfoBase* qinfo_,
+ uint64_t id_)
+ : GraphNode(sgt_, Op_RESIZE, id_)
{
setRequiredOperands(1, 1);
setRequiredRank(4, 4);
@@ -102,10 +105,13 @@ int OpResize<InDtype, OutDtype>::eval()
int out_width = out->getShape()[2];
int out_channels = out->getShape()[3];
- ASSERT_MSG_NODE(shift > 0 && shift <= 11, "OpResize: attribute shift should be within [1, 11]");
- ASSERT_MSG_NODE(stride[0] > 0 && stride[1] > 0, "OpResize: invalid attribute stride");
- ASSERT_MSG_NODE(in_batch == out_batch, "OpResize: output tensor batch mismatch");
- ASSERT_MSG_NODE(in_channels == out_channels, "OpResize: output tensor channel mismatch");
+ 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");
+ ERROR_IF(offset[0] <= (-16 << shift) || offset[0] >= (16 << shift), "OpResize: invalid attribute offset_x");
+ ERROR_IF(offset[1] <= (-16 << shift) || offset[1] >= (16 << shift), "OpResize: invalid attribute offset_y");
+ ERROR_IF(in_batch != out_batch, "OpResize: output tensor batch mismatch");
+ ERROR_IF(in_channels != out_channels, "OpResize: output tensor channel mismatch");
for (int b = 0; b < out_batch; b++)
for (int c = 0; c < out_channels; c++)
@@ -125,8 +131,8 @@ int OpResize<InDtype, OutDtype>::eval()
int32_t ix0 = MAX(ix, 0);
int32_t ix1 = MIN(ix + 1, in_width - 1);
- ASSERT_MSG(iy0 <= iy1 && ix0 <= ix1, "OpResize: invalid index (iy0, iy1, ix0, ix1)=(%d,%d,%d,%d)",
- iy0, iy1, ix0, ix1);
+ REQUIRE(iy0 <= iy1 && ix0 <= ix1, "OpResize: invalid index (iy0, iy1, ix0, ix1)=(%d,%d,%d,%d)", iy0,
+ iy1, ix0, ix1);
OutEigenType acc;
if (mode == ResizeMode_BILINEAR)
@@ -167,10 +173,10 @@ int OpResize<DType_FLOAT, DType_FLOAT>::eval()
int out_width = out->getShape()[2];
int out_channels = out->getShape()[3];
- ASSERT_MSG_NODE(shift == 0, "OpResize: float mode must have 0 shift");
- ASSERT_MSG_NODE(stride_fp[0] > 0.0f && stride_fp[1] > 0.0f, "OpResize: invalid attribute stride");
- ASSERT_MSG_NODE(in_batch == out_batch, "OpResize: output tensor batch mismatch");
- ASSERT_MSG_NODE(in_channels == out_channels, "OpResize: output tensor channel mismatch");
+ 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");
+ ERROR_IF(in_channels != out_channels, "OpResize: output tensor channel mismatch");
for (int b = 0; b < out_batch; b++)
for (int c = 0; c < out_channels; c++)
@@ -190,8 +196,8 @@ int OpResize<DType_FLOAT, DType_FLOAT>::eval()
int32_t ix0 = MAX(ix, 0);
int32_t ix1 = MIN(ix + 1, in_width - 1);
- ASSERT_MSG(iy0 <= iy1 && ix0 <= ix1, "OpResize: invalid index (iy0, iy1, ix0, ix1)=(%d,%d,%d,%d)",
- iy0, iy1, ix0, ix1);
+ REQUIRE(iy0 <= iy1 && ix0 <= ix1, "OpResize: invalid index (iy0, iy1, ix0, ix1)=(%d,%d,%d,%d)", iy0,
+ iy1, ix0, ix1);
OutEigenType acc;
if (mode == ResizeMode_BILINEAR)