From 1f6ffed239350aa11d65bc8036862470fa9bec10 Mon Sep 17 00:00:00 2001 From: Sergei Barannikov/AI Tools Lab /SRR/Engineer/Samsung Electronics Date: Mon, 4 Nov 2019 10:16:28 +0300 Subject: [PATCH] [neurun] Replace OperandIndex in DepthToSpace and SpaceToDepth Params (#8707) Replace `OperandIndex` in `DepthToSpace::Param` and `SpaceToDepth::Param` with `int32_t`. Signed-off-by: Sergei Barannikov --- runtime/neurun/backend/acl_cl/KernelGenerator.cc | 6 ++---- runtime/neurun/backend/acl_neon/KernelGenerator.cc | 6 ++---- runtime/neurun/core/include/model/operation/DepthToSpace.h | 2 +- runtime/neurun/core/include/model/operation/SpaceToDepth.h | 2 +- runtime/neurun/core/src/compiler/OperationValidator.cc | 6 ++---- runtime/neurun/frontend/nnapi/wrapper/OperationFactory.cc | 8 ++++---- 6 files changed, 12 insertions(+), 18 deletions(-) diff --git a/runtime/neurun/backend/acl_cl/KernelGenerator.cc b/runtime/neurun/backend/acl_cl/KernelGenerator.cc index 397c7d5..fb90819 100644 --- a/runtime/neurun/backend/acl_cl/KernelGenerator.cc +++ b/runtime/neurun/backend/acl_cl/KernelGenerator.cc @@ -1426,9 +1426,8 @@ void KernelGenerator::visit(const model::operation::SpaceToDepth &node) { const auto ofm_index{node.getOutputs().at(0)}; const auto ifm_index{node.getInputs().at(model::operation::SpaceToDepth::Input::INPUT)}; - const auto block_size_index{node.param().block_size_index}; - auto block_size = _ctx.at(block_size_index).asScalar(); + auto block_size = node.param().block_size; auto ofm_alloc = _tensor_builder->at(ofm_index).get(); auto ifm_alloc = _tensor_builder->at(ifm_index).get(); @@ -1968,9 +1967,8 @@ void KernelGenerator::visit(const model::operation::DepthToSpace &node) { const auto output_index{node.getOutputs().at(0)}; const auto input_index{node.getInputs().at(model::operation::DepthToSpace::Input::INPUT)}; - const auto block_size_index{node.param().block_size_index}; - auto block_size = _ctx.at(block_size_index).asScalar(); + auto block_size = node.param().block_size; assert(block_size > 0); auto output_alloc = _tensor_builder->at(output_index).get(); diff --git a/runtime/neurun/backend/acl_neon/KernelGenerator.cc b/runtime/neurun/backend/acl_neon/KernelGenerator.cc index 3109e90..e9cb2d8 100644 --- a/runtime/neurun/backend/acl_neon/KernelGenerator.cc +++ b/runtime/neurun/backend/acl_neon/KernelGenerator.cc @@ -307,9 +307,8 @@ void KernelGenerator::visit(const model::operation::DepthToSpace &node) { const auto output_index{node.getOutputs().at(0)}; const auto input_index{node.getInputs().at(model::operation::DepthToSpace::Input::INPUT)}; - const auto block_size_index{node.param().block_size_index}; - auto block_size = _ctx.at(block_size_index).asScalar(); + auto block_size = node.param().block_size; assert(block_size > 0); auto output_alloc = _tensor_builder->at(output_index).get(); @@ -1725,9 +1724,8 @@ void KernelGenerator::visit(const model::operation::SpaceToDepth &node) { const auto ofm_index{node.getOutputs().at(0)}; const auto ifm_index{node.getInputs().at(model::operation::SpaceToDepth::Input::INPUT)}; - const auto block_size_index{node.param().block_size_index}; - auto block_size = _ctx.at(block_size_index).asScalar(); + auto block_size = node.param().block_size; auto ofm_alloc = _tensor_builder->at(ofm_index).get(); auto ifm_alloc = _tensor_builder->at(ifm_index).get(); diff --git a/runtime/neurun/core/include/model/operation/DepthToSpace.h b/runtime/neurun/core/include/model/operation/DepthToSpace.h index e77a4ee..88feb1f 100644 --- a/runtime/neurun/core/include/model/operation/DepthToSpace.h +++ b/runtime/neurun/core/include/model/operation/DepthToSpace.h @@ -38,7 +38,7 @@ public: struct Param { - OperandIndex block_size_index; + std::int32_t block_size; }; public: diff --git a/runtime/neurun/core/include/model/operation/SpaceToDepth.h b/runtime/neurun/core/include/model/operation/SpaceToDepth.h index 8effa3e..a7e9ece 100644 --- a/runtime/neurun/core/include/model/operation/SpaceToDepth.h +++ b/runtime/neurun/core/include/model/operation/SpaceToDepth.h @@ -38,7 +38,7 @@ public: struct Param { - OperandIndex block_size_index; + std::int32_t block_size; }; public: diff --git a/runtime/neurun/core/src/compiler/OperationValidator.cc b/runtime/neurun/core/src/compiler/OperationValidator.cc index 4ad8569..677f9d3 100644 --- a/runtime/neurun/core/src/compiler/OperationValidator.cc +++ b/runtime/neurun/core/src/compiler/OperationValidator.cc @@ -350,12 +350,11 @@ void OperationValidator::visit(const model::operation::SpaceToDepth &node) { const auto ofm_index{node.getOutputs().at(0)}; const auto ifm_index{node.getInputs().at(model::operation::SpaceToDepth::Input::INPUT)}; - const auto block_size_index{node.param().block_size_index}; const auto frontend_layout = _current_subg_layout; const auto input_shape = _ctx.at(ifm_index).shape().asFeature(frontend_layout); const auto output_shape = _ctx.at(ofm_index).shape().asFeature(frontend_layout); - const auto block_size = _ctx.at(block_size_index).asScalar(); + const auto block_size = node.param().block_size; UNUSED_RELEASE(input_shape); UNUSED_RELEASE(output_shape); @@ -590,7 +589,6 @@ void OperationValidator::visit(const model::operation::DepthToSpace &node) { const auto output_index{node.getOutputs().at(0)}; const auto input_index{node.getInputs().at(model::operation::DepthToSpace::Input::INPUT)}; - const auto block_size_index{node.param().block_size_index}; const auto frontend_layout = _current_subg_layout; const auto output_shape = _ctx.at(output_index).shape().asFeature(frontend_layout); @@ -602,7 +600,7 @@ void OperationValidator::visit(const model::operation::DepthToSpace &node) assert(_ctx.at(input_index).shape().rank() == 4); assert(_ctx.at(output_index).shape().rank() == 4); - int32_t block_size = _ctx.at(block_size_index).asScalar(); + int32_t block_size = node.param().block_size; UNUSED_RELEASE(block_size); diff --git a/runtime/neurun/frontend/nnapi/wrapper/OperationFactory.cc b/runtime/neurun/frontend/nnapi/wrapper/OperationFactory.cc index 6e41557..95193b8 100644 --- a/runtime/neurun/frontend/nnapi/wrapper/OperationFactory.cc +++ b/runtime/neurun/frontend/nnapi/wrapper/OperationFactory.cc @@ -988,7 +988,7 @@ OperationFactory::OperationFactory() }; _map[ANEURALNETWORKS_SPACE_TO_DEPTH] = [](const OperationFactory::Param &init_param, - neurun::model::Operands &) { + neurun::model::Operands &operands) { assert(init_param.input_count == 2 && init_param.output_count == 1); OperandIndexSequence outputs{init_param.outputs[0]}; @@ -1000,7 +1000,7 @@ OperationFactory::OperationFactory() OperandIndexSequence inputs{init_param.inputs[0]}; operation::SpaceToDepth::Param param; - param.block_size_index = OperandIndex{init_param.inputs[1]}; + param.block_size = operands.at(OperandIndex{init_param.inputs[1]}).asScalar(); return new operation::SpaceToDepth{inputs, outputs, param}; }; @@ -1471,7 +1471,7 @@ OperationFactory::OperationFactory() }; _map[ANEURALNETWORKS_DEPTH_TO_SPACE] = [](const OperationFactory::Param &init_param, - neurun::model::Operands &) { + neurun::model::Operands &operands) { assert(init_param.input_count == 2 && init_param.output_count == 1); OperandIndexSequence outputs{init_param.outputs[0]}; @@ -1483,7 +1483,7 @@ OperationFactory::OperationFactory() OperandIndexSequence inputs{init_param.inputs[0]}; operation::DepthToSpace::Param param; - param.block_size_index = OperandIndex{init_param.inputs[1]}; + param.block_size = operands.at(OperandIndex{init_param.inputs[1]}).asScalar(); return new operation::DepthToSpace{inputs, outputs, param}; }; -- 2.7.4