aboutsummaryrefslogtreecommitdiff
path: root/reference_model/src/ops/activation_funcs.cc
diff options
context:
space:
mode:
authorKevin Cheng <kevin.cheng@arm.com>2021-10-14 17:09:57 -0700
committerKevin Cheng <kevin.cheng@arm.com>2021-10-18 18:50:08 +0000
commitcc61be36c3b0f5cd1ea719e129a54fd48a6ee9a2 (patch)
tree2d664f87e3fdd75de8c6794f6f6c8d6364ece6bb /reference_model/src/ops/activation_funcs.cc
parente807aae606a78d923a2565052f7c2179e3050650 (diff)
downloadreference_model-cc61be36c3b0f5cd1ea719e129a54fd48a6ee9a2.tar.gz
More ERROR_IF supports
- Also delay tensor allocation after operator being validated ERROR_IF can be caught first before 0 or negative dimension set the graph_status to UNPREDICTABLE - Rescale, Argmax, FullyConnected, Matmul, Pad, Reshape, Slice, Transpose, Clamp, Concat, Equal, Greater, GreaterEqual, Table Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: I4e1b3e5794fe195ce1a37e28443ae584645a3b91
Diffstat (limited to 'reference_model/src/ops/activation_funcs.cc')
-rw-r--r--reference_model/src/ops/activation_funcs.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/reference_model/src/ops/activation_funcs.cc b/reference_model/src/ops/activation_funcs.cc
index 21677d5..c344bcb 100644
--- a/reference_model/src/ops/activation_funcs.cc
+++ b/reference_model/src/ops/activation_funcs.cc
@@ -25,14 +25,15 @@ using namespace tosa;
template <int Rank, DType Dtype>
int OpClamp<Rank, Dtype>::register_fcn()
{
-
switch (Dtype)
{
case DType_FLOAT:
{
InEigenType min = (InEigenType)attribute->min_fp();
InEigenType max = (InEigenType)attribute->max_fp();
- this->fcn = [min, max](InEigenType a) -> OutEigenType { return a <= min ? min : a >= max ? max : a; };
+ ERROR_IF(max < min, "OpClamp: max smaller than min");
+
+ this->fcn = [min, max](InEigenType a) -> OutEigenType { return a <= min ? min : a >= max ? max : a; };
}
break;
case DType_INT8:
@@ -40,7 +41,8 @@ int OpClamp<Rank, Dtype>::register_fcn()
{
InEigenType min = (InEigenType)attribute->min_int();
InEigenType max = (InEigenType)attribute->max_int();
- this->fcn = [min, max](InEigenType a) -> OutEigenType { return a <= min ? min : a >= max ? max : a; };
+ ERROR_IF(max < min, "OpClamp: max smaller than min");
+ this->fcn = [min, max](InEigenType a) -> OutEigenType { return a <= min ? min : a >= max ? max : a; };
}
break;
default: