From: 이한종/동작제어Lab(SR)/Engineer/삼성전자 Date: Wed, 22 Aug 2018 01:34:44 +0000 (+0900) Subject: [neurun] Remove legacy tensor conversion (#2390) X-Git-Tag: 0.2~217 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=633c69b7c702c4167ea4819079074b81064952aa;p=platform%2Fcore%2Fml%2Fnnfw.git [neurun] Remove legacy tensor conversion (#2390) Remove tensor conversions since we will introduce a new way. Signed-off-by: Hanjoung Lee --- diff --git a/runtimes/neurun/src/backend/IStageGenerator.h b/runtimes/neurun/src/backend/IStageGenerator.h index b1e9de1..bea51d0 100644 --- a/runtimes/neurun/src/backend/IStageGenerator.h +++ b/runtimes/neurun/src/backend/IStageGenerator.h @@ -43,12 +43,6 @@ struct IStageGenerator virtual Stage generate(const ::internal::tflite::op::FullyConnected::Node &node) = 0; virtual Stage generate(const ::internal::tflite::op::Reshape::Node &node) = 0; virtual Stage generate(const ::internal::tflite::op::Softmax::Node &node) = 0; - virtual Stage - generate(const ::internal::tflite::op::TensorConvert::CpuFromCommon::Node &node) = 0; - virtual Stage generate(const ::internal::tflite::op::TensorConvert::CpuToCommon::Node &node) = 0; - virtual Stage - generate(const ::internal::tflite::op::TensorConvert::AclFromCommon::Node &node) = 0; - virtual Stage generate(const ::internal::tflite::op::TensorConvert::AclToCommon::Node &node) = 0; virtual Stage generate(const ::internal::tflite::op::NOP::Node &node) = 0; }; diff --git a/runtimes/neurun/src/backend/ITensorBuilder.h b/runtimes/neurun/src/backend/ITensorBuilder.h index f6a9d00..b0239b4 100644 --- a/runtimes/neurun/src/backend/ITensorBuilder.h +++ b/runtimes/neurun/src/backend/ITensorBuilder.h @@ -27,9 +27,6 @@ struct ITensorBuilder { virtual ~ITensorBuilder(void) = default; virtual void mark(const ::neurun::graph::operand::Index &ind) = 0; - virtual void markFromCommon(const ::internal::tflite::op::Node &op, int32_t ind) = 0; - virtual void markToCommon(const ::internal::tflite::op::Node &op, int32_t ind) = 0; - virtual void insertTensorConvertNodes(::internal::tflite::op::Sequence &operations) = 0; // TODO Add an interface for adding subsumption info virtual void prepare(const std::map &tensor_info_ctx) = 0; virtual void allocate(void) = 0; diff --git a/runtimes/neurun/src/backend/acl_cl/StageGenerator.cc b/runtimes/neurun/src/backend/acl_cl/StageGenerator.cc index b588c24..723c32e 100644 --- a/runtimes/neurun/src/backend/acl_cl/StageGenerator.cc +++ b/runtimes/neurun/src/backend/acl_cl/StageGenerator.cc @@ -100,10 +100,9 @@ void ActivationBuilder::append(FuseCode code, ::arm_compute::ICLTensor *ifm_allo // // StageGenerator // -StageGenerator::StageGenerator( - const neurun::graph::operand::Set &ctx, const std::shared_ptr &tensor_builder, - const std::shared_ptr<::internal::common::TensorBuilder> &common_tensor_builder) - : _ctx(ctx), _tensor_builder(tensor_builder), _common_tensor_builder(common_tensor_builder) +StageGenerator::StageGenerator(const neurun::graph::operand::Set &ctx, + const std::shared_ptr &tensor_builder) + : _ctx(ctx), _tensor_builder(tensor_builder) { // DO NOTHING } @@ -511,94 +510,6 @@ Stage StageGenerator::generate(const ::internal::tflite::op::Softmax::Node &node }; } -Stage StageGenerator::generate( - const ::internal::tflite::op::TensorConvert::CpuFromCommon::Node &node) -{ - throw std::runtime_error("Wrong Approach"); -} - -Stage StageGenerator::generate(const ::internal::tflite::op::TensorConvert::CpuToCommon::Node &node) -{ - throw std::runtime_error("Wrong Approach"); -} - -Stage StageGenerator::generate( - const ::internal::tflite::op::TensorConvert::AclFromCommon::Node &node) -{ - const ::neurun::graph::operand::Index ifm_index{node.param().ifm_index}; - - struct Param - { - int ifm_index; - - ::neurun::internal::operand::Shape shape{1}; - }; - - Param param; - - param.ifm_index = ifm_index.asInt(); - - param.shape = _ctx.at(ifm_index).shape(); - - auto tensors = _tensor_builder; - - _common_tensor_builder->mark(ifm_index); - - auto common_tensor_builder = _common_tensor_builder; - - return [tensors, common_tensor_builder, param](IExecutionBuilder &builder) { - const ::neurun::graph::operand::Index ifm_index{param.ifm_index}; - - auto input_alloc = tensors->at(ifm_index).get(); - auto common_tensor = common_tensor_builder->at(ifm_index); - - std::unique_ptr<::neurun::kernel::acl_cl::TensorConvertFromCommonLayer> fn{ - new ::neurun::kernel::acl_cl::TensorConvertFromCommonLayer}; - - fn->configure(common_tensor.get(), input_alloc, param.shape); - - builder.append(std::move(fn)); - }; -} - -Stage StageGenerator::generate(const ::internal::tflite::op::TensorConvert::AclToCommon::Node &node) -{ - const ::neurun::graph::operand::Index ofm_index{node.param().ofm_index}; - - struct Param - { - int ofm_index; - - ::neurun::internal::operand::Shape shape{1}; - }; - - Param param; - - param.ofm_index = ofm_index.asInt(); - - param.shape = _ctx.at(ofm_index).shape(); - - auto tensors = _tensor_builder; - - _common_tensor_builder->mark(ofm_index); - - auto common_tensor_builder = _common_tensor_builder; - - return [tensors, common_tensor_builder, param](IExecutionBuilder &builder) { - const ::neurun::graph::operand::Index ofm_index{param.ofm_index}; - - auto output_alloc = tensors->at(ofm_index).get(); - auto common_tensor = common_tensor_builder->at(ofm_index); - - std::unique_ptr<::neurun::kernel::acl_cl::TensorConvertToCommonLayer> fn{ - new ::neurun::kernel::acl_cl::TensorConvertToCommonLayer}; - - fn->configure(output_alloc, common_tensor.get(), param.shape); - - builder.append(std::move(fn)); - }; -} - Stage StageGenerator::generate(const ::internal::tflite::op::NOP::Node &node) { // DO NOTHING diff --git a/runtimes/neurun/src/backend/acl_cl/StageGenerator.h b/runtimes/neurun/src/backend/acl_cl/StageGenerator.h index 358a0b4..8965f62 100644 --- a/runtimes/neurun/src/backend/acl_cl/StageGenerator.h +++ b/runtimes/neurun/src/backend/acl_cl/StageGenerator.h @@ -5,7 +5,6 @@ #include "graph/operand/Set.h" #include "backend/acl_cl/TensorBuilder.h" -#include "internal/common/TensorBuilder.h" namespace neurun { @@ -18,8 +17,7 @@ class StageGenerator : public IStageGenerator { public: StageGenerator(const neurun::graph::operand::Set &ctx, - const std::shared_ptr &tensor_builder, - const std::shared_ptr<::internal::common::TensorBuilder> &common_tensor_builder); + const std::shared_ptr &tensor_builder); virtual std::shared_ptr tensor_builder() override { return _tensor_builder; } @@ -30,20 +28,11 @@ public: virtual Stage generate(const ::internal::tflite::op::FullyConnected::Node &node) override; virtual Stage generate(const ::internal::tflite::op::Reshape::Node &node) override; virtual Stage generate(const ::internal::tflite::op::Softmax::Node &node) override; - virtual Stage - generate(const ::internal::tflite::op::TensorConvert::CpuFromCommon::Node &node) override; - virtual Stage - generate(const ::internal::tflite::op::TensorConvert::CpuToCommon::Node &node) override; - virtual Stage - generate(const ::internal::tflite::op::TensorConvert::AclFromCommon::Node &node) override; - virtual Stage - generate(const ::internal::tflite::op::TensorConvert::AclToCommon::Node &node) override; virtual Stage generate(const ::internal::tflite::op::NOP::Node &node) override; private: const neurun::graph::operand::Set &_ctx; std::shared_ptr _tensor_builder; - std::shared_ptr<::internal::common::TensorBuilder> _common_tensor_builder; }; } // namespace acl_cl diff --git a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc index 818334c..87cec49 100644 --- a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc +++ b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc @@ -23,39 +23,6 @@ void TensorBuilder::mark(const ::neurun::graph::operand::Index &ind) _inds.insert(ind.asInt()); } -void TensorBuilder::markFromCommon(const ::internal::tflite::op::Node &op, int32_t ind) -{ - _from_common_candidates.emplace_back(op, ind); -} - -void TensorBuilder::markToCommon(const ::internal::tflite::op::Node &op, int32_t ind) -{ - _to_common_candidates.emplace_back(op, ind); -} - -void TensorBuilder::insertTensorConvertNodes(::internal::tflite::op::Sequence &operations) -{ - for (auto param : _from_common_candidates) - { - auto index = operations.find(param.op); - if (index != -1) - { - operations.insert<::internal::tflite::op::TensorConvert::AclFromCommon::Node>( - index, ::internal::tflite::op::TensorConvert::AclFromCommon::Param(param.tensor_index)); - } - } - - for (auto param : _to_common_candidates) - { - auto index = operations.find(param.op); - if (index != -1) - { - operations.insert<::internal::tflite::op::TensorConvert::AclToCommon::Node>( - index + 1, ::internal::tflite::op::TensorConvert::AclToCommon::Param(param.tensor_index)); - } - } -} - void TensorBuilder::prepare(const std::map &tensor_info_ctx) { assert(_tensors.size() == 0); diff --git a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h index be96544..4790da7 100644 --- a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h +++ b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h @@ -24,9 +24,6 @@ public: TensorBuilder(codegen::Plan &plan); virtual void mark(const ::neurun::graph::operand::Index &ind) override; - virtual void markFromCommon(const ::internal::tflite::op::Node &op, int32_t ind) override; - virtual void markToCommon(const ::internal::tflite::op::Node &op, int32_t ind) override; - virtual void insertTensorConvertNodes(::internal::tflite::op::Sequence &operations) override; virtual void prepare(const std::map &tensor_info_ctx) override; virtual void allocate(void) override; diff --git a/runtimes/neurun/src/backend/cpu/StageGenerator.cc b/runtimes/neurun/src/backend/cpu/StageGenerator.cc index 9695604..f9cab11 100644 --- a/runtimes/neurun/src/backend/cpu/StageGenerator.cc +++ b/runtimes/neurun/src/backend/cpu/StageGenerator.cc @@ -26,12 +26,9 @@ namespace backend namespace cpu { -StageGenerator::StageGenerator( - const neurun::graph::operand::Set &operand_ctx, - const std::shared_ptr &tensor_builder, - const std::shared_ptr<::internal::common::TensorBuilder> &common_tensor_builder) - : _ctx(operand_ctx), _tensor_builder(tensor_builder), - _common_tensor_builder(common_tensor_builder) +StageGenerator::StageGenerator(const neurun::graph::operand::Set &operand_ctx, + const std::shared_ptr &tensor_builder) + : _ctx(operand_ctx), _tensor_builder(tensor_builder) { // DO NOTHING } @@ -508,94 +505,6 @@ Stage StageGenerator::generate(const ::internal::tflite::op::Softmax::Node &node }; } -Stage StageGenerator::generate( - const ::internal::tflite::op::TensorConvert::CpuFromCommon::Node &node) -{ - const ::neurun::graph::operand::Index ifm_index{node.param().ifm_index}; - - struct Param - { - int ifm_index; - - ::neurun::internal::operand::Shape shape{1}; - }; - - Param param; - - param.ifm_index = ifm_index.asInt(); - - param.shape = _ctx.at(ifm_index).shape(); - - auto tensors = _tensor_builder; - - _common_tensor_builder->mark(ifm_index); - - auto common_tensor_builder = _common_tensor_builder; - - return [tensors, common_tensor_builder, param](IExecutionBuilder &builder) { - const ::neurun::graph::operand::Index ifm_index{param.ifm_index}; - - auto input_alloc = tensors->at(ifm_index).get(); - auto common_tensor = common_tensor_builder->at(ifm_index); - - std::unique_ptr<::neurun::kernel::cpu::TensorConvertFromCommonLayer> fn{ - new ::neurun::kernel::cpu::TensorConvertFromCommonLayer}; - - fn->configure(common_tensor.get(), input_alloc, param.shape); - - builder.append(std::move(fn)); - }; -} - -Stage StageGenerator::generate(const ::internal::tflite::op::TensorConvert::CpuToCommon::Node &node) -{ - const ::neurun::graph::operand::Index ofm_index{node.param().ofm_index}; - - struct Param - { - int ofm_index; - - ::neurun::internal::operand::Shape shape{1}; - }; - - Param param; - - param.ofm_index = ofm_index.asInt(); - - param.shape = _ctx.at(ofm_index).shape(); - - auto tensors = _tensor_builder; - - _common_tensor_builder->mark(ofm_index); - - auto common_tensor_builder = _common_tensor_builder; - - return [tensors, common_tensor_builder, param](IExecutionBuilder &builder) { - const ::neurun::graph::operand::Index ofm_index{param.ofm_index}; - - auto output_alloc = tensors->at(ofm_index).get(); - auto common_tensor = common_tensor_builder->at(ofm_index); - - std::unique_ptr<::neurun::kernel::cpu::TensorConvertToCommonLayer> fn{ - new ::neurun::kernel::cpu::TensorConvertToCommonLayer}; - - fn->configure(output_alloc, common_tensor.get(), param.shape); - - builder.append(std::move(fn)); - }; -} - -Stage StageGenerator::generate( - const ::internal::tflite::op::TensorConvert::AclFromCommon::Node &node) -{ - throw std::runtime_error("Wrong Approach"); -} - -Stage StageGenerator::generate(const ::internal::tflite::op::TensorConvert::AclToCommon::Node &node) -{ - throw std::runtime_error("Wrong Approach"); -} - Stage StageGenerator::generate(const ::internal::tflite::op::NOP::Node &node) { // DO NOTHING diff --git a/runtimes/neurun/src/backend/cpu/StageGenerator.h b/runtimes/neurun/src/backend/cpu/StageGenerator.h index ef47539..06b6336 100644 --- a/runtimes/neurun/src/backend/cpu/StageGenerator.h +++ b/runtimes/neurun/src/backend/cpu/StageGenerator.h @@ -7,8 +7,6 @@ #include "internal/cpu.h" #include "TensorBuilder.h" -#include "internal/common/TensorBuilder.h" - namespace neurun { namespace backend @@ -20,8 +18,7 @@ class StageGenerator : public IStageGenerator { public: StageGenerator(const neurun::graph::operand::Set &ctx, - const std::shared_ptr &tensor_builder, - const std::shared_ptr<::internal::common::TensorBuilder> &common_tensor_builder); + const std::shared_ptr &tensor_builder); virtual std::shared_ptr tensor_builder() override { return _tensor_builder; } @@ -32,20 +29,11 @@ public: virtual Stage generate(const ::internal::tflite::op::FullyConnected::Node &node) override; virtual Stage generate(const ::internal::tflite::op::Reshape::Node &node) override; virtual Stage generate(const ::internal::tflite::op::Softmax::Node &node) override; - virtual Stage - generate(const ::internal::tflite::op::TensorConvert::CpuFromCommon::Node &node) override; - virtual Stage - generate(const ::internal::tflite::op::TensorConvert::CpuToCommon::Node &node) override; - virtual Stage - generate(const ::internal::tflite::op::TensorConvert::AclFromCommon::Node &node) override; - virtual Stage - generate(const ::internal::tflite::op::TensorConvert::AclToCommon::Node &node) override; virtual Stage generate(const ::internal::tflite::op::NOP::Node &node) override; private: const neurun::graph::operand::Set &_ctx; std::shared_ptr _tensor_builder; - std::shared_ptr<::internal::common::TensorBuilder> _common_tensor_builder; }; } // namespace cpu diff --git a/runtimes/neurun/src/backend/cpu/TensorBuilder.cc b/runtimes/neurun/src/backend/cpu/TensorBuilder.cc index 5e54815..e8e9765 100644 --- a/runtimes/neurun/src/backend/cpu/TensorBuilder.cc +++ b/runtimes/neurun/src/backend/cpu/TensorBuilder.cc @@ -23,39 +23,6 @@ void TensorBuilder::mark(const ::neurun::graph::operand::Index &ind) _inds.insert(ind.asInt()); } -void TensorBuilder::markFromCommon(const ::internal::tflite::op::Node &op, int32_t ind) -{ - _from_common_candidates.emplace_back(op, ind); -} - -void TensorBuilder::markToCommon(const ::internal::tflite::op::Node &op, int32_t ind) -{ - _to_common_candidates.emplace_back(op, ind); -} - -void TensorBuilder::insertTensorConvertNodes(::internal::tflite::op::Sequence &operations) -{ - for (auto param : _from_common_candidates) - { - auto index = operations.find(param.op); - if (index != -1) - { - operations.insert<::internal::tflite::op::TensorConvert::CpuFromCommon::Node>( - index, ::internal::tflite::op::TensorConvert::CpuFromCommon::Param(param.tensor_index)); - } - } - - for (auto param : _to_common_candidates) - { - auto index = operations.find(param.op); - if (index != -1) - { - operations.insert<::internal::tflite::op::TensorConvert::CpuToCommon::Node>( - index + 1, ::internal::tflite::op::TensorConvert::CpuToCommon::Param(param.tensor_index)); - } - } -} - void TensorBuilder::prepare(const std::map &tensor_info_ctx) { assert(_tensors.size() == 0); diff --git a/runtimes/neurun/src/backend/cpu/TensorBuilder.h b/runtimes/neurun/src/backend/cpu/TensorBuilder.h index 853c0e3..0f2bf42 100644 --- a/runtimes/neurun/src/backend/cpu/TensorBuilder.h +++ b/runtimes/neurun/src/backend/cpu/TensorBuilder.h @@ -23,9 +23,6 @@ public: TensorBuilder(codegen::Plan &plan); virtual void mark(const ::neurun::graph::operand::Index &ind) override; - virtual void markFromCommon(const ::internal::tflite::op::Node &op, int32_t ind) override; - virtual void markToCommon(const ::internal::tflite::op::Node &op, int32_t ind) override; - virtual void insertTensorConvertNodes(::internal::tflite::op::Sequence &operations) override; virtual void prepare(const std::map &tensor_info_ctx) override; virtual void allocate(void) override; diff --git a/runtimes/neurun/src/codegen/BackendResolver.cc b/runtimes/neurun/src/codegen/BackendResolver.cc index d5e1d15..eb7a5a8 100644 --- a/runtimes/neurun/src/codegen/BackendResolver.cc +++ b/runtimes/neurun/src/codegen/BackendResolver.cc @@ -33,10 +33,5 @@ std::set> BackendResolver::getA return ret; } -std::shared_ptr<::internal::common::TensorBuilder> BackendResolver::getCommonTensorBuilder() -{ - return _backend_manager.getCommonTensorBuilder(); -} - } // namespace neurun } // namespace codegen diff --git a/runtimes/neurun/src/codegen/BackendResolver.h b/runtimes/neurun/src/codegen/BackendResolver.h index 2adccda..58cb92f 100644 --- a/runtimes/neurun/src/codegen/BackendResolver.h +++ b/runtimes/neurun/src/codegen/BackendResolver.h @@ -2,6 +2,7 @@ #define __NEURUN_CODEGEN_BACKEND_RESOLVER_H__ #include +#include #include #include "logging.h" @@ -9,7 +10,6 @@ #include "internal/BackendManager.h" #include "backend/IInitializerGenerator.h" #include "backend/IStageGenerator.h" -#include "internal/common/TensorBuilder.h" namespace neurun { @@ -48,16 +48,6 @@ public: #include "internal/op/Op.lst" #undef OP } - - // TODO : It's just workaround. It's logic should be changed. - _gen_map[typeid(::internal::tflite::op::TensorConvert::CpuFromCommon::Node)] = - backend_manager.get("cpu"); - _gen_map[typeid(::internal::tflite::op::TensorConvert::CpuToCommon::Node)] = - backend_manager.get("cpu"); - _gen_map[typeid(::internal::tflite::op::TensorConvert::AclFromCommon::Node)] = - backend_manager.get("acl_cl"); - _gen_map[typeid(::internal::tflite::op::TensorConvert::AclToCommon::Node)] = - backend_manager.get("acl_cl"); } std::shared_ptr @@ -65,7 +55,6 @@ public: std::shared_ptr getStageGenerator(const std::type_index &type); std::shared_ptr getTensorBuilder(const std::type_index &type); std::set> getAllTensorBuilders(); - std::shared_ptr<::internal::common::TensorBuilder> getCommonTensorBuilder(); private: std::unordered_map _gen_map; diff --git a/runtimes/neurun/src/codegen/Dumper.cc b/runtimes/neurun/src/codegen/Dumper.cc index 61e105e..1ff1b90 100644 --- a/runtimes/neurun/src/codegen/Dumper.cc +++ b/runtimes/neurun/src/codegen/Dumper.cc @@ -70,30 +70,6 @@ void Dumper::visit(const Softmax::Node &node) VERBOSE(LIR) << " - Output : OFM(" << node.param().output_index << ")" << std::endl; } -void Dumper::visit(const TensorConvert::CpuFromCommon::Node &node) -{ - VERBOSE(LIR) << "CpuFromCommon" << std::endl; - // NOTE No details for this node. Soon will be removed. -} - -void Dumper::visit(const TensorConvert::CpuToCommon::Node &node) -{ - VERBOSE(LIR) << "CpuToCommon" << std::endl; - // NOTE No details for this node. Soon will be removed. -} - -void Dumper::visit(const TensorConvert::AclFromCommon::Node &node) -{ - VERBOSE(LIR) << "AclFromCommon" << std::endl; - // NOTE No details for this node. Soon will be removed. -} - -void Dumper::visit(const TensorConvert::AclToCommon::Node &node) -{ - VERBOSE(LIR) << "AclToCommon" << std::endl; - // NOTE No details for this node. Soon will be removed. -} - void Dumper::visit(const NOP::Node &node) { VERBOSE(LIR) << "* NOP" << std::endl; diff --git a/runtimes/neurun/src/codegen/Dumper.h b/runtimes/neurun/src/codegen/Dumper.h index ab95702..413feb7 100644 --- a/runtimes/neurun/src/codegen/Dumper.h +++ b/runtimes/neurun/src/codegen/Dumper.h @@ -21,10 +21,6 @@ public: void visit(const ::internal::tflite::op::FullyConnected::Node &node) override; void visit(const ::internal::tflite::op::Reshape::Node &node) override; void visit(const ::internal::tflite::op::Softmax::Node &node) override; - void visit(const ::internal::tflite::op::TensorConvert::CpuFromCommon::Node &node) override; - void visit(const ::internal::tflite::op::TensorConvert::CpuToCommon::Node &node) override; - void visit(const ::internal::tflite::op::TensorConvert::AclFromCommon::Node &node) override; - void visit(const ::internal::tflite::op::TensorConvert::AclToCommon::Node &node) override; void visit(const ::internal::tflite::op::NOP::Node &node) override; }; diff --git a/runtimes/neurun/src/codegen/PlanBuilder.cc b/runtimes/neurun/src/codegen/PlanBuilder.cc index 54cf03b..5471218 100644 --- a/runtimes/neurun/src/codegen/PlanBuilder.cc +++ b/runtimes/neurun/src/codegen/PlanBuilder.cc @@ -22,7 +22,6 @@ void PlanBuilder::addStage(const Stage &stage) { _stages.emplace_back(stage); } void PlanBuilder::finalize(BackendResolver &backend_resolver) { auto tensor_builders = backend_resolver.getAllTensorBuilders(); - auto common_tensor_builder = backend_resolver.getCommonTensorBuilder(); // Prepare tensors for (auto &tensor_builder : tensor_builders) @@ -30,8 +29,6 @@ void PlanBuilder::finalize(BackendResolver &backend_resolver) tensor_builder->prepare(_tensor_info_ctx); } - common_tensor_builder->prepare(_tensor_info_ctx); - // Process Stage ExecutionBuilder execution_builder{_plan}; @@ -47,8 +44,6 @@ void PlanBuilder::finalize(BackendResolver &backend_resolver) tensor_builder->allocate(); } - common_tensor_builder->allocate(); - // Fill weight/bias for (auto it = _initializer_ctx.begin(); it != _initializer_ctx.end(); ++it) { diff --git a/runtimes/neurun/src/codegen/Planner.cc b/runtimes/neurun/src/codegen/Planner.cc index 9e08939..21636ce 100644 --- a/runtimes/neurun/src/codegen/Planner.cc +++ b/runtimes/neurun/src/codegen/Planner.cc @@ -205,30 +205,6 @@ void Planner::visit(const ::internal::tflite::op::Softmax::Node &node) _builder.addStage(stage_gen->generate(node)); } -void Planner::visit(const ::internal::tflite::op::TensorConvert::CpuFromCommon::Node &node) -{ - auto stage_gen = _backend_resolver.getStageGenerator(typeid(node)); - _builder.addStage(stage_gen->generate(node)); -} - -void Planner::visit(const ::internal::tflite::op::TensorConvert::CpuToCommon::Node &node) -{ - auto stage_gen = _backend_resolver.getStageGenerator(typeid(node)); - _builder.addStage(stage_gen->generate(node)); -} - -void Planner::visit(const ::internal::tflite::op::TensorConvert::AclFromCommon::Node &node) -{ - auto stage_gen = _backend_resolver.getStageGenerator(typeid(node)); - _builder.addStage(stage_gen->generate(node)); -} - -void Planner::visit(const ::internal::tflite::op::TensorConvert::AclToCommon::Node &node) -{ - auto stage_gen = _backend_resolver.getStageGenerator(typeid(node)); - _builder.addStage(stage_gen->generate(node)); -} - void Planner::visit(const ::internal::tflite::op::NOP::Node &node) { // DO NOTHING diff --git a/runtimes/neurun/src/codegen/Planner.h b/runtimes/neurun/src/codegen/Planner.h index 1db33a8..2e410ed 100644 --- a/runtimes/neurun/src/codegen/Planner.h +++ b/runtimes/neurun/src/codegen/Planner.h @@ -39,10 +39,6 @@ public: void visit(const ::internal::tflite::op::FullyConnected::Node &node) override; void visit(const ::internal::tflite::op::Reshape::Node &node) override; void visit(const ::internal::tflite::op::Softmax::Node &node) override; - void visit(const ::internal::tflite::op::TensorConvert::CpuFromCommon::Node &node) override; - void visit(const ::internal::tflite::op::TensorConvert::CpuToCommon::Node &node) override; - void visit(const ::internal::tflite::op::TensorConvert::AclFromCommon::Node &node) override; - void visit(const ::internal::tflite::op::TensorConvert::AclToCommon::Node &node) override; void visit(const ::internal::tflite::op::NOP::Node &node) override; private: diff --git a/runtimes/neurun/src/codegen/TensorMarker.cc b/runtimes/neurun/src/codegen/TensorMarker.cc index f064034..0f256ad 100644 --- a/runtimes/neurun/src/codegen/TensorMarker.cc +++ b/runtimes/neurun/src/codegen/TensorMarker.cc @@ -12,9 +12,6 @@ void TensorMarker::visit(const ::internal::tflite::op::Conv2D::implicit::Node &n mark(param.ifm_index); mark(param.ker_index); mark(param.bias_index); - - markToCommon(node, param.ofm_index); - markFromCommon(node, param.ifm_index); } void TensorMarker::visit(const ::internal::tflite::op::MaxPool2D::implicit::Node &node) @@ -22,9 +19,6 @@ void TensorMarker::visit(const ::internal::tflite::op::MaxPool2D::implicit::Node const auto ¶m = node.param(); mark(param.ofm_index); mark(param.ifm_index); - - markToCommon(node, param.ofm_index); - markFromCommon(node, param.ifm_index); } void TensorMarker::visit(const ::internal::tflite::op::AvgPool2D::implicit::Node &node) @@ -32,20 +26,15 @@ void TensorMarker::visit(const ::internal::tflite::op::AvgPool2D::implicit::Node const auto ¶m = node.param(); mark(param.ofm_index); mark(param.ifm_index); - - markToCommon(node, param.ofm_index); - markFromCommon(node, param.ifm_index); } void TensorMarker::visit(const ::internal::tflite::op::Concat::Node &node) { const auto ¶m = node.param(); mark(param.ofm_index); - markToCommon(node, param.ofm_index); for (auto ind : param.ifm_indexes) { mark(ind); - markFromCommon(node, ind); } } @@ -56,9 +45,6 @@ void TensorMarker::visit(const ::internal::tflite::op::FullyConnected::Node &nod mark(param.input_index); mark(param.weight_index); mark(param.bias_index); - - markToCommon(node, param.output_index); - markFromCommon(node, param.input_index); } void TensorMarker::visit(const ::internal::tflite::op::Reshape::Node &node) @@ -66,9 +52,6 @@ void TensorMarker::visit(const ::internal::tflite::op::Reshape::Node &node) const auto ¶m = node.param(); mark(param.output_index); mark(param.input_index); - - markToCommon(node, param.output_index); - markFromCommon(node, param.input_index); } void TensorMarker::visit(const ::internal::tflite::op::Softmax::Node &node) @@ -76,29 +59,6 @@ void TensorMarker::visit(const ::internal::tflite::op::Softmax::Node &node) const auto ¶m = node.param(); mark(param.output_index); mark(param.input_index); - - markToCommon(node, param.output_index); - markFromCommon(node, param.input_index); -} - -void TensorMarker::visit(const ::internal::tflite::op::TensorConvert::CpuFromCommon::Node &node) -{ - // DO NOTHING -} - -void TensorMarker::visit(const ::internal::tflite::op::TensorConvert::CpuToCommon::Node &node) -{ - // DO NOTHING -} - -void TensorMarker::visit(const ::internal::tflite::op::TensorConvert::AclFromCommon::Node &node) -{ - // DO NOTHING -} - -void TensorMarker::visit(const ::internal::tflite::op::TensorConvert::AclToCommon::Node &node) -{ - // DO NOTHING } void TensorMarker::visit(const ::internal::tflite::op::NOP::Node &node) diff --git a/runtimes/neurun/src/codegen/TensorMarker.h b/runtimes/neurun/src/codegen/TensorMarker.h index d11c7fb..7a816f6 100644 --- a/runtimes/neurun/src/codegen/TensorMarker.h +++ b/runtimes/neurun/src/codegen/TensorMarker.h @@ -25,22 +25,10 @@ public: void visit(const ::internal::tflite::op::FullyConnected::Node &node) override; void visit(const ::internal::tflite::op::Reshape::Node &node) override; void visit(const ::internal::tflite::op::Softmax::Node &node) override; - void visit(const ::internal::tflite::op::TensorConvert::CpuFromCommon::Node &node) override; - void visit(const ::internal::tflite::op::TensorConvert::CpuToCommon::Node &node) override; - void visit(const ::internal::tflite::op::TensorConvert::AclFromCommon::Node &node) override; - void visit(const ::internal::tflite::op::TensorConvert::AclToCommon::Node &node) override; void visit(const ::internal::tflite::op::NOP::Node &node) override; private: void mark(int32_t ind) { _tensor_builder.mark(::neurun::graph::operand::Index{ind}); } - void markFromCommon(const ::internal::tflite::op::Node &op, int32_t ind) - { - _tensor_builder.markFromCommon(op, ind); - } - void markToCommon(const ::internal::tflite::op::Node &op, int32_t ind) - { - _tensor_builder.markToCommon(op, ind); - } private: neurun::backend::ITensorBuilder &_tensor_builder; diff --git a/runtimes/neurun/src/compilation.cc b/runtimes/neurun/src/compilation.cc index f171899..51fafc0 100644 --- a/runtimes/neurun/src/compilation.cc +++ b/runtimes/neurun/src/compilation.cc @@ -15,8 +15,6 @@ #include "internal/Padding.h" #include "backend/IInitializerGenerator.h" #include "backend/IStageGenerator.h" -#include "internal/common/Tensor.h" -#include "internal/common/TensorBuilder.h" #include "compilation.h" #include "model.h" @@ -50,15 +48,6 @@ int ANeuralNetworksCompilation::finish() linear->markTensors(backend_resolver); -#if 0 // Tensor Conversion disabled - auto tensor_builders = backend_resolver.getAllTensorBuilders(); - - for (auto tensor_builder : tensor_builders) - { - tensor_builder->insertTensorConvertNodes(operations); - } -#endif - linear->accept(neurun::codegen::Planner{operands, plan_builder, backend_resolver}); // TODO Add optimization passes diff --git a/runtimes/neurun/src/internal/BackendManager.cc b/runtimes/neurun/src/internal/BackendManager.cc index ff1f15f..603e3dd 100644 --- a/runtimes/neurun/src/internal/BackendManager.cc +++ b/runtimes/neurun/src/internal/BackendManager.cc @@ -14,15 +14,12 @@ BackendManager::BackendManager(neurun::codegen::Plan &plan) : _plan(plan) { const auto &operands = _plan.model().operands(); - _common_tensor_builder = std::make_shared<::internal::common::TensorBuilder>(_plan); - // Add arm_compute backend { using namespace ::neurun::backend::acl_cl; auto acl_tensor_builder = std::make_shared(_plan); auto acl_initializer_gen = std::make_shared(operands); - auto acl_stage_gen = - std::make_shared(operands, acl_tensor_builder, _common_tensor_builder); + auto acl_stage_gen = std::make_shared(operands, acl_tensor_builder); // TODO Do not use magic string for backend id _gen_map["acl_cl"] = {acl_initializer_gen, acl_stage_gen}; @@ -33,8 +30,7 @@ BackendManager::BackendManager(neurun::codegen::Plan &plan) : _plan(plan) using namespace ::neurun::backend::cpu; auto cpu_tensor_builder = std::make_shared(_plan); auto cpu_initializer_gen = std::make_shared(operands); - auto cpu_stage_gen = - std::make_shared(operands, cpu_tensor_builder, _common_tensor_builder); + auto cpu_stage_gen = std::make_shared(operands, cpu_tensor_builder); // TODO Do not use magic string for backend id _gen_map["cpu"] = {cpu_initializer_gen, cpu_stage_gen}; @@ -43,9 +39,4 @@ BackendManager::BackendManager(neurun::codegen::Plan &plan) : _plan(plan) Backend BackendManager::get(const std::string &key) { return _gen_map.at(key); } -std::shared_ptr<::internal::common::TensorBuilder> BackendManager::getCommonTensorBuilder() -{ - return _common_tensor_builder; -} - } // namespace internal diff --git a/runtimes/neurun/src/internal/BackendManager.h b/runtimes/neurun/src/internal/BackendManager.h index b6a1efc..afe57b1 100644 --- a/runtimes/neurun/src/internal/BackendManager.h +++ b/runtimes/neurun/src/internal/BackendManager.h @@ -7,7 +7,6 @@ #include "backend/IInitializerGenerator.h" #include "backend/IStageGenerator.h" #include "backend/ITensorBuilder.h" -#include "internal/common/TensorBuilder.h" namespace internal { @@ -37,12 +36,9 @@ public: Backend get(const std::string &key); - std::shared_ptr<::internal::common::TensorBuilder> getCommonTensorBuilder(); - private: neurun::codegen::Plan &_plan; std::map _gen_map; - std::shared_ptr<::internal::common::TensorBuilder> _common_tensor_builder; }; } // namespace internal diff --git a/runtimes/neurun/src/internal/Sink.h b/runtimes/neurun/src/internal/Sink.h index 4c6f691..7c29aaf 100644 --- a/runtimes/neurun/src/internal/Sink.h +++ b/runtimes/neurun/src/internal/Sink.h @@ -12,8 +12,6 @@ #include "internal/nnapi/feature/View.h" #include "internal/nnapi/feature/Reader.h" -#include "internal/common/Tensor.h" - struct Sink { virtual ~Sink() = default; @@ -35,12 +33,6 @@ public: public: void pull(::arm_compute::ITensor &tensor) const override { -// NOTE Leave common tensor conversion code before Graph IR supports tensor conversion -#if 0 - // Only for common tensor now - assert(typeid(tensor) == typeid(::internal::common::Tensor)); -#endif - float *base = reinterpret_cast(_base); for (int32_t n = 0; n < _vlen; ++n) @@ -95,22 +87,6 @@ public: into.at(bat, ch, row, col) = value; }; } - -// NOTE Leave common tensor conversion code before Graph IR supports tensor conversion -#if 0 - // Only for common tensor now - assert(typeid(tensor) == typeid(::internal::common::Tensor)); - - // nnapi tensor ordering == common tensor ordering - const ::internal::nnapi::feature::Reader from{_shape, tensor.buffer(), _size}; - ::internal::nnapi::feature::View into{_shape, _base, _size}; - - ::nnfw::util::feature::iterate(_shape) - << [&](uint32_t batch, uint32_t ch, uint32_t row, uint32_t col) { - const auto value = from.at(batch, ch, row, col); - into.at(batch, ch, row, col) = value; - }; -#endif } private: diff --git a/runtimes/neurun/src/internal/Source.h b/runtimes/neurun/src/internal/Source.h index e5270ad..00bc28e 100644 --- a/runtimes/neurun/src/internal/Source.h +++ b/runtimes/neurun/src/internal/Source.h @@ -14,8 +14,6 @@ #include "backend/acl_cl/feature/View.h" -#include "internal/common/Tensor.h" - struct Source { virtual ~Source() = default; @@ -38,12 +36,6 @@ public: public: void push(::arm_compute::ITensor &tensor) const override { -// NOTE Leave common tensor conversion code before Graph IR supports tensor conversion -#if 0 - // Only for common tensor now - assert(typeid(tensor) == typeid(::internal::common::Tensor)); -#endif - auto base = reinterpret_cast(_base); for (int32_t n = 0; n < _vlen; ++n) @@ -98,22 +90,6 @@ public: into.at(bat, ch, row, col) = value; }; } - -// NOTE Leave common tensor conversion code before Graph IR supports tensor conversion -#if 0 - // Only for common tensor now - assert(typeid(tensor) == typeid(::internal::common::Tensor)); - - // nnapi tensor ordering == common tensor ordering - const ::internal::nnapi::feature::Reader from{_shape, _base, _size}; - ::internal::nnapi::feature::View into{_shape, tensor.buffer(), _size}; - - ::nnfw::util::feature::iterate(_shape) - << [&](uint32_t batch, uint32_t ch, uint32_t row, uint32_t col) { - const auto value = from.at(batch, ch, row, col); - into.at(batch, ch, row, col) = value; - }; -#endif } private: diff --git a/runtimes/neurun/src/internal/common/Tensor.h b/runtimes/neurun/src/internal/common/Tensor.h deleted file mode 100644 index 27d2002..0000000 --- a/runtimes/neurun/src/internal/common/Tensor.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef __INTERNAL_COMMON_TENSOR_H__ -#define __INTERNAL_COMMON_TENSOR_H__ - -#include -#include - -#include "backend/IObject.h" - -namespace internal -{ -namespace common -{ - -class Tensor : public ::arm_compute::ITensor -{ -public: - Tensor() = default; - - Tensor(::arm_compute::TensorInfo info) : _info(info) - { - // DO_NOTING - } - - Tensor(uint8_t *buffer) : _buffer(buffer) - { - // DO NOTHING - } - -public: - void setBuffer(uint8_t *buffer) { _buffer = buffer; } - -public: - ::arm_compute::TensorInfo *info() const override - { - return const_cast<::arm_compute::TensorInfo *>(&_info); - } - - ::arm_compute::TensorInfo *info() override { return &_info; } - - uint8_t *buffer() const override { return _buffer; } - - void allocate() - { - uint32_t size = _info.total_size(); // NOTE This size may not be accurate - _buffer = new uint8_t[size]; // NOTE The allocated buffer is never deallocated. - } - -private: - ::arm_compute::TensorInfo _info; - uint8_t *_buffer = nullptr; -}; - -} // common -} // internal - -#endif // __INTERNAL_COMMON_TENSOR_H__ diff --git a/runtimes/neurun/src/internal/common/TensorBuilder.cc b/runtimes/neurun/src/internal/common/TensorBuilder.cc deleted file mode 100644 index 7b04a8d..0000000 --- a/runtimes/neurun/src/internal/common/TensorBuilder.cc +++ /dev/null @@ -1,76 +0,0 @@ -#include "TensorBuilder.h" - -#include - -namespace internal -{ -namespace common -{ - -TensorBuilder::TensorBuilder(neurun::codegen::Plan &plan) : _plan(plan) -{ - // DO NOTHING -} - -void TensorBuilder::mark(const ::neurun::graph::operand::Index &ind) -{ - assert(_tensors.size() == 0); - - int index = ind.asInt(); - - auto it = _inds.find(index); - if (it == _inds.end()) - { - _inds.insert(index); - } -} - -void TensorBuilder::markFromCommon(const ::internal::tflite::op::Node &op, int32_t ind) -{ - // DO NOTHING - throw std::runtime_error("Wrong Approach"); -} - -void TensorBuilder::markToCommon(const ::internal::tflite::op::Node &op, int32_t ind) -{ - // DO NOTHING - throw std::runtime_error("Wrong Approach"); -} - -void TensorBuilder::insertTensorConvertNodes(::internal::tflite::op::Sequence &operations) -{ - // DO NOTHING - throw std::runtime_error("Wrong Approach"); -} - -void TensorBuilder::prepare(const std::map &tensor_info_ctx) -{ - assert(_tensors.size() == 0); - - for (auto ind_int : _inds) - { - ::neurun::graph::operand::Index ind{ind_int}; - auto tensor = std::make_shared<::internal::common::Tensor>(tensor_info_ctx.at(ind.asInt())); - _plan.common_operands().set(ind, std::make_shared<::internal::common::Object>(tensor)); - _tensors[ind.asInt()] = tensor; - } -} - -void TensorBuilder::allocate(void) -{ - assert(_inds.size() == _tensors.size()); - - for (auto it : _tensors) - { - it.second->allocate(); - } -} - -std::shared_ptr<::internal::common::Tensor> -TensorBuilder::at(const ::neurun::graph::operand::Index &ind) -{ - return _tensors.at(ind.asInt()); -} - -} // namespace common -} // namespace internal diff --git a/runtimes/neurun/src/internal/common/TensorBuilder.h b/runtimes/neurun/src/internal/common/TensorBuilder.h deleted file mode 100644 index d974c1e..0000000 --- a/runtimes/neurun/src/internal/common/TensorBuilder.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef __INTERNAL_COMMON_TENSOR_BUILDER_H__ -#define __INTERNAL_COMMON_TENSOR_BUILDER_H__ - -#include -#include - -#include "backend/ITensorBuilder.h" -#include "codegen/Plan.h" -#include "internal/common/Tensor.h" -#include "internal/common/common.h" - -namespace internal -{ -namespace common -{ - -class Plan; - -class TensorBuilder : public neurun::backend::ITensorBuilder -{ -public: - TensorBuilder(neurun::codegen::Plan &plan); - - virtual void mark(const ::neurun::graph::operand::Index &ind) override; - virtual void markFromCommon(const ::internal::tflite::op::Node &op, int32_t ind) override; - virtual void markToCommon(const ::internal::tflite::op::Node &op, int32_t ind) override; - virtual void insertTensorConvertNodes(::internal::tflite::op::Sequence &operations) override; - virtual void prepare(const std::map &tensor_info_ctx) override; - virtual void allocate(void) override; - - std::shared_ptr<::internal::common::Tensor> at(const ::neurun::graph::operand::Index &ind); - -private: - neurun::codegen::Plan &_plan; - std::unordered_set _inds; - std::unordered_map> _tensors; -}; - -} // namespace common -} // namespace internal - -#endif // __INTERNAL_COMMON_TENSOR_BUILDER_H__ diff --git a/runtimes/neurun/src/internal/common/common.cc b/runtimes/neurun/src/internal/common/common.cc deleted file mode 100644 index f9f8064..0000000 --- a/runtimes/neurun/src/internal/common/common.cc +++ /dev/null @@ -1,14 +0,0 @@ -#include "common.h" - -namespace internal -{ -namespace common -{ - -void Object::access(const std::function &fn) const -{ - fn(*_tensor); -} - -} // common -} // internal diff --git a/runtimes/neurun/src/internal/common/common.h b/runtimes/neurun/src/internal/common/common.h deleted file mode 100644 index 69be54c..0000000 --- a/runtimes/neurun/src/internal/common/common.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __INTERNAL_COMMON_H__ -#define __INTERNAL_COMMON_H__ - -#include "backend/IObject.h" -#include "Tensor.h" - -namespace internal -{ -namespace common -{ - -class Object : public neurun::backend::operand::IObject -{ -public: - Object() = default; - -public: - Object(const std::shared_ptr &tensor) : _tensor{tensor} - { - // DO NOTHING - } - -public: - Tensor *ptr(void) const override { return _tensor.get(); } - -private: - std::shared_ptr _tensor; - -public: - void access(const std::function &fn) const override; -}; - -} // common -} // internal - -#endif // __INTERNAL_COMMON_H__ diff --git a/runtimes/neurun/src/internal/op/NodeVisitor.h b/runtimes/neurun/src/internal/op/NodeVisitor.h index 3a9a63c..6d9de9f 100644 --- a/runtimes/neurun/src/internal/op/NodeVisitor.h +++ b/runtimes/neurun/src/internal/op/NodeVisitor.h @@ -8,8 +8,6 @@ #include "internal/op/Reshape.h" #include "internal/op/FullyConnected.h" #include "internal/op/Softmax.h" -#include "internal/op/TensorConvert_Cpu.h" -#include "internal/op/TensorConvert_Acl.h" #include "internal/op/NOP.h" namespace internal @@ -30,10 +28,6 @@ struct NodeVisitor virtual void visit(const Reshape::Node &) = 0; virtual void visit(const FullyConnected::Node &) = 0; virtual void visit(const Softmax::Node &) = 0; - virtual void visit(const TensorConvert::CpuFromCommon::Node &) = 0; - virtual void visit(const TensorConvert::CpuToCommon::Node &) = 0; - virtual void visit(const TensorConvert::AclFromCommon::Node &) = 0; - virtual void visit(const TensorConvert::AclToCommon::Node &) = 0; virtual void visit(const NOP::Node &) = 0; }; diff --git a/runtimes/neurun/src/internal/op/TensorConvert_Acl.cc b/runtimes/neurun/src/internal/op/TensorConvert_Acl.cc deleted file mode 100644 index 9d16f33..0000000 --- a/runtimes/neurun/src/internal/op/TensorConvert_Acl.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal/op/TensorConvert_Acl.h" -#include "internal/op/NodeVisitor.h" - -#include - -namespace internal -{ -namespace tflite -{ -namespace op -{ -namespace TensorConvert -{ -namespace AclFromCommon -{ - -void Node::accept(NodeVisitor &&v) const { v.visit(*this); } - -} // namespace AclFromCommon -} // namespace TensorConvert -} // namespace op -} // namespace tflite -} // namespace internal - -namespace internal -{ -namespace tflite -{ -namespace op -{ -namespace TensorConvert -{ -namespace AclFromCommon -{ - -Param::Param(uint32_t inputIndex) { ifm_index = inputIndex; } - -} // namespace AclFromCommon -} // namespace TensorConvert -} // namespace op -} // namespace tflite -} // namespace internal - -namespace internal -{ -namespace tflite -{ -namespace op -{ -namespace TensorConvert -{ -namespace AclToCommon -{ - -void Node::accept(NodeVisitor &&v) const { v.visit(*this); } - -} // namespace AclToCommon -} // namespace TensorConvert -} // namespace op -} // namespace tflite -} // namespace internal - -namespace internal -{ -namespace tflite -{ -namespace op -{ -namespace TensorConvert -{ -namespace AclToCommon -{ - -Param::Param(uint32_t outputIndex) { ofm_index = outputIndex; } - -} // namespace AclToCommon -} // namespace TensorConvert -} // namespace op -} // namespace tflite -} // namespace internal diff --git a/runtimes/neurun/src/internal/op/TensorConvert_Acl.h b/runtimes/neurun/src/internal/op/TensorConvert_Acl.h deleted file mode 100644 index 303f71c..0000000 --- a/runtimes/neurun/src/internal/op/TensorConvert_Acl.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __INTERNAL_OP_TENSOR_CONVERT_ACL_H__ -#define __INTERNAL_OP_TENSOR_CONVERT_ACL_H__ - -#include "internal/op/Node.h" - -#include - -namespace internal -{ -namespace tflite -{ -namespace op -{ -namespace TensorConvert -{ -namespace AclFromCommon -{ - -struct Param -{ - int32_t ifm_index; - - Param() = default; - Param(uint32_t inputIndex); -}; - -class Node final : public op::Node -{ -public: - Node(const Param ¶m) : _param(param) - { - // DO NOTHING - } - -public: - virtual ~Node() = default; - -public: - const Param ¶m(void) const { return _param; } - -public: - void accept(NodeVisitor &&) const override; - -private: - const Param _param; -}; - -} // namespace AclFromCommon -} // namespace TensorConvert -} // namespace op -} // namespace tflite -} // namespace internal - -namespace internal -{ -namespace tflite -{ -namespace op -{ -namespace TensorConvert -{ -namespace AclToCommon -{ - -struct Param -{ - int32_t ofm_index; - - Param() = default; - Param(uint32_t outputIndex); -}; - -class Node final : public op::Node -{ -public: - Node(const Param ¶m) : _param(param) - { - // DO NOTHING - } - -public: - virtual ~Node() = default; - -public: - const Param ¶m(void) const { return _param; } - -public: - void accept(NodeVisitor &&) const override; - -private: - const Param _param; -}; - -} // namespace AclToCommon -} // namespace TensorConvert -} // namespace op -} // namespace tflite -} // namespace internal - -#endif // __INTERNAL_OP_TENSOR_CONVERT_ACL_H__ diff --git a/runtimes/neurun/src/internal/op/TensorConvert_Cpu.cc b/runtimes/neurun/src/internal/op/TensorConvert_Cpu.cc deleted file mode 100644 index 1563480..0000000 --- a/runtimes/neurun/src/internal/op/TensorConvert_Cpu.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "internal/op/TensorConvert_Cpu.h" -#include "internal/op/NodeVisitor.h" - -#include - -namespace internal -{ -namespace tflite -{ -namespace op -{ -namespace TensorConvert -{ -namespace CpuFromCommon -{ - -void Node::accept(NodeVisitor &&v) const { v.visit(*this); } - -} // namespace CpuFromCommon -} // namespace TensorConvert -} // namespace op -} // namespace tflite -} // namespace internal - -namespace internal -{ -namespace tflite -{ -namespace op -{ -namespace TensorConvert -{ -namespace CpuFromCommon -{ - -Param::Param(uint32_t inputIndex) { ifm_index = inputIndex; } - -} // namespace FromCommon -} // namespace TensorConvert -} // namespace op -} // namespace tflite -} // namespace internal - -namespace internal -{ -namespace tflite -{ -namespace op -{ -namespace TensorConvert -{ -namespace CpuToCommon -{ - -void Node::accept(NodeVisitor &&v) const { v.visit(*this); } - -} // namespace CpuToCommon -} // namespace TensorConvert -} // namespace op -} // namespace tflite -} // namespace internal - -namespace internal -{ -namespace tflite -{ -namespace op -{ -namespace TensorConvert -{ -namespace CpuToCommon -{ - -Param::Param(uint32_t outputIndex) { ofm_index = outputIndex; } - -} // namespace CpuToCommon -} // namespace TensorConvert -} // namespace op -} // namespace tflite -} // namespace internal diff --git a/runtimes/neurun/src/internal/op/TensorConvert_Cpu.h b/runtimes/neurun/src/internal/op/TensorConvert_Cpu.h deleted file mode 100644 index e6dd7d6..0000000 --- a/runtimes/neurun/src/internal/op/TensorConvert_Cpu.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __INTERNAL_OP_TENSOR_CONVERT_CPU_H__ -#define __INTERNAL_OP_TENSOR_CONVERT_CPU_H__ - -#include "internal/op/Node.h" - -#include - -namespace internal -{ -namespace tflite -{ -namespace op -{ -namespace TensorConvert -{ -namespace CpuFromCommon -{ - -struct Param -{ - int32_t ifm_index; - - Param() = default; - Param(uint32_t inputIndex); -}; - -class Node final : public op::Node -{ -public: - Node(const Param ¶m) : _param(param) - { - // DO NOTHING - } - -public: - virtual ~Node() = default; - -public: - const Param ¶m(void) const { return _param; } - -public: - void accept(NodeVisitor &&) const override; - -private: - const Param _param; -}; - -} // namespace CpuFromCommon -} // namespace TensorConvert -} // namespace op -} // namespace tflite -} // namespace internal - -namespace internal -{ -namespace tflite -{ -namespace op -{ -namespace TensorConvert -{ -namespace CpuToCommon -{ - -struct Param -{ - int32_t ofm_index; - - Param() = default; - Param(uint32_t outputIndex); -}; - -class Node final : public op::Node -{ -public: - Node(const Param ¶m) : _param(param) - { - // DO NOTHING - } - -public: - virtual ~Node() = default; - -public: - const Param ¶m(void) const { return _param; } - -public: - void accept(NodeVisitor &&) const override; - -private: - const Param _param; -}; - -} // namespace CpuToCommon -} // namespace TensorConvert -} // namespace op -} // namespace tflite -} // namespace internal - -#endif // __INTERNAL_OP_TENSOR_CONVERT_CPU_H__ diff --git a/runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.cc b/runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.cc index 260c8a1..3ec1e87 100644 --- a/runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.cc +++ b/runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.cc @@ -14,6 +14,12 @@ * limitations under the License. */ +// +// THIS FILE IS UNUSED BUT LEFT FOR FUTURE REFERNCE +// + +#if 0 + #include "TensorConvertFromCommonLayer.h" #include "internal/nnapi/feature/Reader.h" @@ -84,3 +90,5 @@ void TensorConvertFromCommonLayer::run() { convert(); } } // namespace acl_cl } // namespace kernel } // namespace neurun + +#endif diff --git a/runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.h b/runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.h index 989f69b..7537891 100644 --- a/runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.h +++ b/runtimes/neurun/src/kernel/acl_cl/TensorConvertFromCommonLayer.h @@ -14,6 +14,12 @@ * limitations under the License. */ +// +// THIS FILE IS UNUSED BUT LEFT FOR FUTURE REFERNCE +// + +#if 0 + #ifndef __INTERNAL_KERNELS_ACL_CL_TENSOR_CONVERT_FROM_COMMON_LAYER_H__ #define __INTERNAL_KERNELS_ACL_CL_TENSOR_CONVERT_FROM_COMMON_LAYER_H__ @@ -57,3 +63,5 @@ private: } // namespace neurun #endif // __INTERNAL_KERNELS_ACL_CL_TENSOR_CONVERT_FROM_COMMON_LAYER_H__ + +#endif diff --git a/runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.cc b/runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.cc index 7ec0690..89d8322 100644 --- a/runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.cc +++ b/runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.cc @@ -14,6 +14,12 @@ * limitations under the License. */ +// +// THIS FILE IS UNUSED BUT LEFT FOR FUTURE REFERNCE +// + +#if 0 + #include "TensorConvertToCommonLayer.h" #include "backend/acl_cl/feature/View.h" @@ -84,3 +90,5 @@ void TensorConvertToCommonLayer::run() { convert(); } } // namespace acl_cl } // namespace kernel } // namespace neurun + +#endif diff --git a/runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.h b/runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.h index 6b63ee9..5544ad3 100644 --- a/runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.h +++ b/runtimes/neurun/src/kernel/acl_cl/TensorConvertToCommonLayer.h @@ -14,6 +14,12 @@ * limitations under the License. */ +// +// THIS FILE IS UNUSED BUT LEFT FOR FUTURE REFERNCE +// + +#if 0 + #ifndef __INTERNAL_KERNELS_ACL_CL_TENSOR_CONVERT_TO_COMMON_LAYER_H__ #define __INTERNAL_KERNELS_ACL_CL_TENSOR_CONVERT_TO_COMMON_LAYER_H__ @@ -57,3 +63,5 @@ private: } // namespace neurun #endif // __INTERNAL_KERNELS_ACL_CL_TENSOR_CONVERT_TO_COMMON_LAYER_H__ + +#endif diff --git a/runtimes/neurun/src/kernel/cpu/TensorConvertFromCommonLayer.cc b/runtimes/neurun/src/kernel/cpu/TensorConvertFromCommonLayer.cc index 8d3f3b7..44327ac 100644 --- a/runtimes/neurun/src/kernel/cpu/TensorConvertFromCommonLayer.cc +++ b/runtimes/neurun/src/kernel/cpu/TensorConvertFromCommonLayer.cc @@ -14,6 +14,12 @@ * limitations under the License. */ +// +// THIS FILE IS UNUSED BUT LEFT FOR FUTURE REFERNCE +// + +#if 0 + #include "TensorConvertFromCommonLayer.h" #include "internal/nnapi/feature/Reader.h" @@ -80,3 +86,5 @@ void TensorConvertFromCommonLayer::run() { convert(); } } // namespace cpu } // namespace kernel } // namespace neurun + +#endif diff --git a/runtimes/neurun/src/kernel/cpu/TensorConvertFromCommonLayer.h b/runtimes/neurun/src/kernel/cpu/TensorConvertFromCommonLayer.h index 1ee9ba3..f10f3fc 100644 --- a/runtimes/neurun/src/kernel/cpu/TensorConvertFromCommonLayer.h +++ b/runtimes/neurun/src/kernel/cpu/TensorConvertFromCommonLayer.h @@ -14,6 +14,12 @@ * limitations under the License. */ +// +// THIS FILE IS UNUSED BUT LEFT FOR FUTURE REFERNCE +// + +#if 0 + #ifndef __NEURUN_KERNEL_CPU_TENSOR_CONVERT_FROM_COMMON_LAYER_H__ #define __NEURUN_KERNEL_CPU_TENSOR_CONVERT_FROM_COMMON_LAYER_H__ @@ -57,3 +63,5 @@ private: } // namespace neurun #endif // __NEURUN_KERNEL_CPU_TENSOR_CONVERT_FROM_COMMON_LAYER_H__ + +#endif diff --git a/runtimes/neurun/src/kernel/cpu/TensorConvertToCommonLayer.cc b/runtimes/neurun/src/kernel/cpu/TensorConvertToCommonLayer.cc index 3dd6293..9cd79c1 100644 --- a/runtimes/neurun/src/kernel/cpu/TensorConvertToCommonLayer.cc +++ b/runtimes/neurun/src/kernel/cpu/TensorConvertToCommonLayer.cc @@ -14,6 +14,12 @@ * limitations under the License. */ +// +// THIS FILE IS UNUSED BUT LEFT FOR FUTURE REFERNCE +// + +#if 0 + #include "TensorConvertToCommonLayer.h" #include "internal/nnapi/feature/Reader.h" @@ -80,3 +86,5 @@ void TensorConvertToCommonLayer::run() { convert(); } } // namespace cpu } // namespace kernel } // namespace neurun + +#endif diff --git a/runtimes/neurun/src/kernel/cpu/TensorConvertToCommonLayer.h b/runtimes/neurun/src/kernel/cpu/TensorConvertToCommonLayer.h index 49ae50d..92d7adb 100644 --- a/runtimes/neurun/src/kernel/cpu/TensorConvertToCommonLayer.h +++ b/runtimes/neurun/src/kernel/cpu/TensorConvertToCommonLayer.h @@ -14,6 +14,12 @@ * limitations under the License. */ +// +// THIS FILE IS UNUSED BUT LEFT FOR FUTURE REFERNCE +// + +#if 0 + #ifndef __NEURUN_KERNEL_CPU_TENSOR_CONVERT_TO_COMMON_LAYER_H__ #define __NEURUN_KERNEL_CPU_TENSOR_CONVERT_TO_COMMON_LAYER_H__ @@ -57,3 +63,5 @@ private: } // namespace neurun #endif // __NEURUN_KERNEL_CPU_TENSOR_CONVERT_TO_COMMON_LAYER_H__ + +#endif