diff options
author | Eric Kunze <eric.kunze@arm.com> | 2022-06-07 05:20:44 +0000 |
---|---|---|
committer | Eric Kunze <eric.kunze@arm.com> | 2022-06-15 11:38:04 -0700 |
commit | b5fabec33abeca2d92c20c7b094fa3f113d0ddd8 (patch) | |
tree | 9c7d946012c7a70a7fcb237daa4376d7b65c6f76 /reference_model/src/ops/ewise_unary.cc | |
parent | 24594f55ee3bf0e95c764e51b94c3ec7f9cfa54a (diff) | |
download | reference_model-b5fabec33abeca2d92c20c7b094fa3f113d0ddd8.tar.gz |
Remove quantization info from serialization attributes
Any needed information moves into the attributes for each operator.
New serialization library version removes teh quantization information
attributes from the schema
Signed-off-by: Eric Kunze <eric.kunze@arm.com>
Change-Id: Icf6165687ab1fd34a01f64c01b0b92b2820e72fa
Diffstat (limited to 'reference_model/src/ops/ewise_unary.cc')
-rw-r--r-- | reference_model/src/ops/ewise_unary.cc | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/reference_model/src/ops/ewise_unary.cc b/reference_model/src/ops/ewise_unary.cc index 8b83a50..8ef1e3c 100644 --- a/reference_model/src/ops/ewise_unary.cc +++ b/reference_model/src/ops/ewise_unary.cc @@ -29,7 +29,10 @@ UnaryNode<Rank, Dtype>::UnaryNode(SubgraphTraverser* sgt_, const Op& op_, uint64 setRequiredOperands(1, 1); setRequiredRank(0, 6); - fcn = [](InEigenType a) -> OutEigenType { return OutEigenType(); }; + fcn = [](InEigenType a) -> OutEigenType { + ASSERT_MSG(0, "In default UnaryNode function, missing function registration"); + return OutEigenType(); + }; } template <int Rank, DType Dtype> @@ -211,13 +214,28 @@ int OpLogicalNot<Rank, Dtype>::register_fcn() } template <int Rank, DType Dtype> +OpNegate<Rank, Dtype>::OpNegate(SubgraphTraverser* sgt_, + TosaAttributeBase* attribute_, + uint64_t id_) + : UnaryNode<Rank, Dtype>(sgt_, Op_NEGATE, id_) +{ + INIT_ATTRIBUTE(Negate); + + register_fcn(); +} + +template <int Rank, DType Dtype> +OpNegate<Rank, Dtype>::~OpNegate() +{ + if (attribute) + delete attribute; +} + +template <int Rank, DType Dtype> int OpNegate<Rank, Dtype>::register_fcn() { - if (Dtype != DType_INT8 && this->qinfo) - { - ERROR_IF(this->qinfo->input_zp() != 0, "OpNegate: zeropoint only for int8_t"); - ERROR_IF(this->qinfo->output_zp() != 0, "OpNegate: zeropoint only for int8_t"); - } + ERROR_IF(Dtype != DType_INT8 && attribute->input1_zp() != 0, "OpNegate: zeropoint only for int8_t"); + ERROR_IF(Dtype != DType_INT8 && attribute->output_zp() != 0, "OpNegate: zeropoint only for int8_t"); switch (Dtype) { @@ -251,11 +269,11 @@ int OpNegate<Rank, Dtype>::register_fcn() break; case DType_INT8: this->fcn = [this](InEigenType a) -> OutEigenType { - int64_t res_in_64 = 0 - (a - this->qinfo->input_zp()); + int64_t res_in_64 = 0 - (a - attribute->input1_zp()); int64_t i32_max_in_64 = static_cast<int64_t>(std::numeric_limits<int32_t>::max()); int64_t i32_min_in_64 = static_cast<int64_t>(std::numeric_limits<int32_t>::min()); REQUIRE(res_in_64 <= i32_max_in_64 && res_in_64 >= i32_min_in_64, "OpNegate: result not in acc type range (int32)"); - res_in_64 += this->qinfo->output_zp(); + res_in_64 += attribute->output_zp(); InEigenType result = static_cast<InEigenType>(std::min(std::max(res_in_64, static_cast<int64_t>(QMin)), static_cast<int64_t>(QMax))); return result; }; |