[neurun] Replace OperandIndex in DepthToSpace and SpaceToDepth Params (#8707)
authorSergei Barannikov/AI Tools Lab /SRR/Engineer/Samsung Electronics <s.barannikov@samsung.com>
Mon, 4 Nov 2019 07:16:28 +0000 (10:16 +0300)
committer이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Mon, 4 Nov 2019 07:16:28 +0000 (16:16 +0900)
Replace `OperandIndex` in `DepthToSpace::Param` and `SpaceToDepth::Param` with `int32_t`.

Signed-off-by: Sergei Barannikov <s.barannikov@samsung.com>
runtime/neurun/backend/acl_cl/KernelGenerator.cc
runtime/neurun/backend/acl_neon/KernelGenerator.cc
runtime/neurun/core/include/model/operation/DepthToSpace.h
runtime/neurun/core/include/model/operation/SpaceToDepth.h
runtime/neurun/core/src/compiler/OperationValidator.cc
runtime/neurun/frontend/nnapi/wrapper/OperationFactory.cc

index 397c7d5..fb90819 100644 (file)
@@ -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<int32_t>();
+  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<int32_t>();
+  auto block_size = node.param().block_size;
   assert(block_size > 0);
 
   auto output_alloc = _tensor_builder->at(output_index).get();
index 3109e90..e9cb2d8 100644 (file)
@@ -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<int32_t>();
+  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<int32_t>();
+  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();
index e77a4ee..88feb1f 100644 (file)
@@ -38,7 +38,7 @@ public:
 
   struct Param
   {
-    OperandIndex block_size_index;
+    std::int32_t block_size;
   };
 
 public:
index 8effa3e..a7e9ece 100644 (file)
@@ -38,7 +38,7 @@ public:
 
   struct Param
   {
-    OperandIndex block_size_index;
+    std::int32_t block_size;
   };
 
 public:
index 4ad8569..677f9d3 100644 (file)
@@ -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<int32_t>();
+  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>();
+  int32_t block_size = node.param().block_size;
 
   UNUSED_RELEASE(block_size);
 
index 6e41557..95193b8 100644 (file)
@@ -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<std::int32_t>();
 
     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<std::int32_t>();
 
     return new operation::DepthToSpace{inputs, outputs, param};
   };