Fix bug that NegateOp doesn't clip output value
Signed-off-by: Kevin Cheng <kevin.cheng@arm.com>
Change-Id: I6b335605d79338fc77e3f84585aeffe1e61cb1f2
diff --git a/reference_model/src/ops/ewise_unary.cc b/reference_model/src/ops/ewise_unary.cc
index a73669c..95a1102 100644
--- a/reference_model/src/ops/ewise_unary.cc
+++ b/reference_model/src/ops/ewise_unary.cc
@@ -232,6 +232,7 @@
ASSERT(this->qinfo);
this->fcn = [this](InEigenType a) -> OutEigenType {
InEigenType result = -(a - this->qinfo->input_zp()) + this->qinfo->output_zp();
+ result = std::min(std::max(result, static_cast<InEigenType>(QMin)), static_cast<InEigenType>(QMax));
return result;
};
break;