Adding nnapi delegation changes regarding TransposeConv (#3427)
authorDevansh Bansal/SNAP /SRI-Bangalore/Engineer/삼성전자 <b.devansh@samsung.com>
Fri, 30 Nov 2018 01:08:48 +0000 (06:38 +0530)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Fri, 30 Nov 2018 01:08:48 +0000 (10:08 +0900)
This patch adds required changes to nnapi delegate to run transpose conv

Signed-off-by: b.devansh <b.devansh@samsung.com>
libs/support/tflite/src/nnapi_delegate.cpp
libs/support/tflite/src/nnapi_delegate_ex_AddOpsAndParams_lambda.inc

index 3f8a129..9d37161 100644 (file)
@@ -729,6 +729,14 @@ TfLiteStatus AddOpsAndParams(
             augmented_inputs.data(), static_cast<uint32_t>(node.outputs->size),
             reinterpret_cast<uint32_t*>(node.outputs->data)));
         continue;
+      case tflite::BuiltinOperator_TRANSPOSE_CONV:
+        add_transpose_conv_params(node.builtin_data);
+        CHECK_NN(ANeuralNetworksModel_addOperationEx(
+            nn_model, ANEURALNETWORKS_TRANSPOSE_CONV_EX,
+            static_cast<uint32_t>(augmented_inputs.size()),
+            augmented_inputs.data(), static_cast<uint32_t>(node.outputs->size),
+            reinterpret_cast<uint32_t*>(node.outputs->data)));
+        continue;
       case tflite::BuiltinOperator_ARG_MAX:
         CHECK_NN(ANeuralNetworksModel_addOperationEx(
             nn_model, ANEURALNETWORKS_ARGMAX_EX,
@@ -775,7 +783,7 @@ TfLiteStatus AddOpsAndParams(
       case tflite::BuiltinOperator_SLICE:
       case tflite::BuiltinOperator_SIN:
       //case tflite::BuiltinOperator_LOG:
-      case tflite::BuiltinOperator_TRANSPOSE_CONV:
+      //case tflite::BuiltinOperator_TRANSPOSE_CONV:
 #ifndef OBS_BUILD
       case tflite::BuiltinOperator_TILE:
       case tflite::BuiltinOperator_EXPAND_DIMS:
index b6b0bf6..5cba4ee 100644 (file)
       }
     };
 
+    auto add_transpose_conv_params = [&add_scalar_int32](void* data) {
+      auto builtin = reinterpret_cast<TfLiteTransposeConvParams*>(data);
+      add_scalar_int32(builtin->padding);
+      add_scalar_int32(builtin->stride_width);
+      add_scalar_int32(builtin->stride_height);
+    };
+
     auto add_lrn_params = [&add_scalar_int32,
                             &add_scalar_float32](void* data) {
       auto builtin = reinterpret_cast<TfLiteLocalResponseNormParams*>(data);