Enables other type of operands in CONV2D operation. (#1889)
author장지섭/동작제어Lab(SR)/Engineer/삼성전자 <jiseob.jang@samsung.com>
Mon, 9 Jul 2018 07:19:46 +0000 (16:19 +0900)
committer이춘석/동작제어Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Mon, 9 Jul 2018 07:19:46 +0000 (16:19 +0900)
* Change the type of CONV2D's Bias from QASYMM8 to INT32

This commit changes CONV2D's bias type from QASYMM8 to INT32.

According to the nnapi description, for input tensor of {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM} type, the bias should be of {@link ANEURALNETWORKS_TENSOR_INT32}.

Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
* Add QuantizationInfo to TensorInfo in CONV2D operation.

This commit adds QuantizationInfo to TensorInfo in CONV2D operation.

Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
runtimes/pure_arm_compute/src/compilation.cc

index 8c0689b..bcfe543 100644 (file)
@@ -761,10 +761,18 @@ void Planner::visit(const ::internal::tflite::op::Conv2D::implicit::Node &node)
 
   // TODO Should move to the place where the operand is handled, if it is possible.
   // Set Shape Constraints and TensorInfo
-  _builder.addShapeConstr(ofm_index, asTensorInfo(ofm_shape, _ctx.at(ofm_index).type()));
-  _builder.addShapeConstr(ifm_index, asTensorInfo(ifm_shape, _ctx.at(ifm_index).type()));
-  _builder.addShapeConstr(ker_index, asTensorInfo(ker_shape, _ctx.at(ker_index).type()));
-  _builder.addShapeConstr(bias_index, asTensorInfo(bias_size, _ctx.at(bias_index).type()));
+  _builder.addShapeConstr(ofm_index,
+                          asTensorInfo(ofm_shape, _ctx.at(ofm_index).type(),
+                                       _ctx.at(ofm_index).scale(), _ctx.at(ofm_index).zeroPoint()));
+  _builder.addShapeConstr(ifm_index,
+                          asTensorInfo(ifm_shape, _ctx.at(ifm_index).type(),
+                                       _ctx.at(ifm_index).scale(), _ctx.at(ifm_index).zeroPoint()));
+  _builder.addShapeConstr(ker_index,
+                          asTensorInfo(ker_shape, _ctx.at(ker_index).type(),
+                                       _ctx.at(ker_index).scale(), _ctx.at(ker_index).zeroPoint()));
+  _builder.addShapeConstr(bias_index, asTensorInfo(bias_size, _ctx.at(bias_index).type(),
+                                                   _ctx.at(bias_index).scale(),
+                                                   _ctx.at(bias_index).zeroPoint()));
 
   // Set initializer for kernel
   {
@@ -806,9 +814,9 @@ void Planner::visit(const ::internal::tflite::op::Conv2D::implicit::Node &node)
         _builder.addInitializer(bias_index, initializer);
         break;
       }
-      case ANEURALNETWORKS_TENSOR_QUANT8_ASYMM:
+      case ANEURALNETWORKS_TENSOR_INT32:
       {
-        auto initializer = std::bind(initVectorTensor<uint8_t>, _1, bias_base, bias_size);
+        auto initializer = std::bind(initVectorTensor<int32_t>, _1, bias_base, bias_size);
         _builder.addInitializer(bias_index, initializer);
         break;
       }