From 269e898e23cfb4acb337beb5385620ac5afd9df8 Mon Sep 17 00:00:00 2001 From: Kevin Cheng Date: Tue, 28 Sep 2021 15:48:27 -0700 Subject: Remove ReluN op. Signed-off-by: Kevin Cheng Change-Id: Iaac727159a84de1f83de549c3a22704096f46bf9 --- reference_model/src/ops/activation_funcs.cc | 28 ---------------------------- reference_model/src/ops/activation_funcs.h | 20 -------------------- reference_model/src/ops/op_factory.cc | 4 ---- verif/tosa_test_gen.py | 19 ------------------- 4 files changed, 71 deletions(-) diff --git a/reference_model/src/ops/activation_funcs.cc b/reference_model/src/ops/activation_funcs.cc index 440f4e1..21677d5 100644 --- a/reference_model/src/ops/activation_funcs.cc +++ b/reference_model/src/ops/activation_funcs.cc @@ -50,31 +50,6 @@ int OpClamp::register_fcn() return 0; } -template -int OpReluN::register_fcn() -{ - - switch (Dtype) - { - case DType_FLOAT: - { - InEigenType N = (InEigenType)attribute->max_fp(); - this->fcn = [N](InEigenType a) -> OutEigenType { return a >= 0 ? (a <= N ? a : N) : 0; }; - } - break; - case DType_INT32: - { - InEigenType N = (InEigenType)attribute->max_int(); - this->fcn = [N](InEigenType a) -> OutEigenType { return a >= 0 ? (a <= N ? a : N) : 0; }; - } - break; - default: - ERROR_IF(true, "unsupported DType %s", EnumNamesDType()[Dtype]); - } - - return 0; -} - template int OpSigmoid::register_fcn() { @@ -110,9 +85,6 @@ DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpClamp, FLOAT); DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpClamp, INT8); DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpClamp, INT16); -DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpReluN, FLOAT); -DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpReluN, INT32); - DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpSigmoid, FLOAT); DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpTanh, FLOAT); diff --git a/reference_model/src/ops/activation_funcs.h b/reference_model/src/ops/activation_funcs.h index c834b52..10385e0 100644 --- a/reference_model/src/ops/activation_funcs.h +++ b/reference_model/src/ops/activation_funcs.h @@ -44,26 +44,6 @@ protected: TosaClampAttribute* attribute; }; -template -class OpReluN : public UnaryNode -{ -public: - OpReluN(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, TosaQuantInfoBase* qinfo_, uint64_t id_) - : UnaryNode(sgt_, Op_RELUN, id_) - { - INIT_ATTRIBUTE(ReluN); - register_fcn(); - } - static constexpr int32_t QMin = GetQMin::value; - static constexpr int32_t QMax = GetQMax::value; - using InEigenType = typename GetEigenType::type; - using OutEigenType = typename GetEigenType::type; - virtual int register_fcn(); - -protected: - TosaReluNAttribute* attribute; -}; - template class OpSigmoid : public UnaryNode { diff --git a/reference_model/src/ops/op_factory.cc b/reference_model/src/ops/op_factory.cc index 3bc55a8..a9ee136 100644 --- a/reference_model/src/ops/op_factory.cc +++ b/reference_model/src/ops/op_factory.cc @@ -105,10 +105,6 @@ GraphNode* OpFactory::newOp(SubgraphTraverser* sgt, DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpClamp, INT8); DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpClamp, INT16); break; - case Op_RELUN: - DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpReluN, FLOAT); - DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpReluN, INT32); - break; case Op_SIGMOID: DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OpSigmoid, FLOAT); break; diff --git a/verif/tosa_test_gen.py b/verif/tosa_test_gen.py index f55d892..4aa42da 100644 --- a/verif/tosa_test_gen.py +++ b/verif/tosa_test_gen.py @@ -1842,19 +1842,6 @@ class TosaTestGen: self.ser.addOperator(op, [a.name], [result_tens.name]) return result_tens - def build_relun(self, op, a): - result_tens = OutputShaper.unaryOp(self.ser, a) - - attr = ts.TosaSerializerAttribute() - - if a.dtype == DType.FLOAT: - attr.ReluNAttribute(0, self.getRandNumberDType(a.dtype)) - else: - attr.ReluNAttribute(self.getRandNumberDType(a.dtype), 0) - - self.ser.addOperator(op, [a.name], [result_tens.name], attr) - return result_tens - def build_sigmoid(self, op, a): result_tens = OutputShaper.unaryOp(self.ser, a) self.ser.addOperator(op, [a.name], [result_tens.name]) @@ -2909,12 +2896,6 @@ class TosaTestGen: "build_fcn": (build_clamp, TosaTensorGen.tgBasic, None), "types": TYPE_NARROW_INT_FP, }, - "relun": { - "op": Op.RELUN, - "operands": (1, 0), - "build_fcn": (build_relun, TosaTensorGen.tgBasic, None), - "types": TYPE_FI32, - }, "sigmoid": { "op": Op.SIGMOID, "operands": (1, 0), -- cgit v1.2.1