From 5d057eb725a94854ca05cd22739ab86803f5a931 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EA=B9=80=EC=88=98=EC=A7=84/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Wed, 27 Feb 2019 16:14:17 +0900 Subject: [PATCH] [neurun] Revert to using const_cast for extendRank in Mul op (#4503) * [neurun] Revert to using const_cast for extendRank in Mul op This commit reverts to using `const_cast` for `extendRank` in `Mul` op. That's because we've figured out the current implementation treats `copy` of `shape` object not `reference`. It makes the `shape` not extend actually. It seems it was a coincidence to be run all of tests related `broadcasting`. (We need to check the tests...) * add TrivialTest.BroadcastMulTwo test Signed-off-by: sjsujinkim --- runtimes/neurun/src/backend/acl_cl/StageGenerator.cc | 10 ++++++---- runtimes/neurun/src/model/operand/Object.h | 3 +-- tests/nnapi/nnapi_gtest.skip.armv7l-linux.neurun | 1 - 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/runtimes/neurun/src/backend/acl_cl/StageGenerator.cc b/runtimes/neurun/src/backend/acl_cl/StageGenerator.cc index 31ee3c6..fa0b92b 100644 --- a/runtimes/neurun/src/backend/acl_cl/StageGenerator.cc +++ b/runtimes/neurun/src/backend/acl_cl/StageGenerator.cc @@ -781,11 +781,13 @@ void StageGenerator::visit(const model::operation::MulNode &node) { const auto broadcast_rank = std::max(_ctx.at(lhs_index).shape().rank(), _ctx.at(rhs_index).shape().rank()); - auto lhs_shape = _ctx.at(lhs_index).shape(); - auto rhs_shape = _ctx.at(rhs_index).shape(); - lhs_shape.extendRank(broadcast_rank); - rhs_shape.extendRank(broadcast_rank); + // TODO remove const_cast later. For example, _ctx may need to be a non const variable or + // a node to extend shape may be inserted in front of this operation + const_cast<::neurun::model::operand::Shape &>(_ctx.at(lhs_index).shape()) + .extendRank(broadcast_rank); + const_cast<::neurun::model::operand::Shape &>(_ctx.at(rhs_index).shape()) + .extendRank(broadcast_rank); } struct Param diff --git a/runtimes/neurun/src/model/operand/Object.h b/runtimes/neurun/src/model/operand/Object.h index fb4c84a..9ebf037 100644 --- a/runtimes/neurun/src/model/operand/Object.h +++ b/runtimes/neurun/src/model/operand/Object.h @@ -55,7 +55,6 @@ public: public: const Shape &shape(void) const { return _shape; } - Shape &shape(void) { return _shape; } const TypeInfo &typeInfo(void) const { return _type; } size_t operandSize(void) const; bool usageIsDefined(void) const { return _usage != Usage::NOT_DEFINED; } @@ -108,7 +107,7 @@ public: graph::operand::ParentInfo *parent_info(); private: - Shape _shape; + const Shape _shape; const TypeInfo _type; std::unique_ptr _data; Usage _usage; diff --git a/tests/nnapi/nnapi_gtest.skip.armv7l-linux.neurun b/tests/nnapi/nnapi_gtest.skip.armv7l-linux.neurun index a3ce557..2c2e1d8 100644 --- a/tests/nnapi/nnapi_gtest.skip.armv7l-linux.neurun +++ b/tests/nnapi/nnapi_gtest.skip.armv7l-linux.neurun @@ -2,7 +2,6 @@ # Following tests will be skipped on armv7l-linux # # Not support operations -TrivialTest.BroadcastMulTwo ValidationTestCompilation.Finish ValidationTestIdentify.DuplicateInputs ValidationTestIdentify.DuplicateOutputs -- 2.7.4