TensorFlowMax nnapi_delegate (#1432)
author오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Wed, 30 May 2018 23:41:01 +0000 (08:41 +0900)
committer최형규/동작제어Lab(SR)/Staff Engineer/삼성전자 <hk0110.choi@samsung.com>
Wed, 30 May 2018 23:41:01 +0000 (08:41 +0900)
Add nnapi call from nnapi_delegate.cpp for TensorFlowMax

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
libs/support/tflite/src/nnapi_delegate.cpp
tools/tflite_run/src/operators.cc

index 7e072e1..697c2be 100644 (file)
@@ -356,6 +356,17 @@ void AddOpsAndParams(tflite::Interpreter *interpreter, ANeuralNetworksModel *nn_
         nn_op_type = -1; // set to invalid
         break;
       case tflite::BuiltinOperator_CUSTOM:
+        std::string custom_name(registration.custom_name);
+        if (custom_name.compare("TensorFlowMax") == 0)
+        {
+          CHECK_NN(ANeuralNetworksModel_addOperationEx(
+              nn_model, ANEURALNETWORKS_TENSORFLOW_MAX_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;
+        }
+
         FATAL("Custom operations are not supported when using NNAPI.");
         nn_op_type = -1; // set to invalid
         break;
index 626d871..c1a2997 100644 (file)
@@ -569,11 +569,12 @@ TfLiteStatus EvalSquaredDifference(TfLiteContext *context, TfLiteNode *node)
 }
 }
 
-#define REGISTER_FUNCTION(Name)                                                                \
-  TfLiteRegistration *Register_##Name(void)                                                    \
-  {                                                                                            \
-    static TfLiteRegistration r = {::Init##Name, ::Free##Name, ::Prepare##Name, ::Eval##Name}; \
-    return &r;                                                                                 \
+#define REGISTER_FUNCTION(Name)                                                                  \
+  TfLiteRegistration *Register_##Name(void)                                                      \
+  {                                                                                              \
+    static TfLiteRegistration r = {::Init##Name, ::Free##Name, ::Prepare##Name, ::Eval##Name, 0, \
+                                   #Name};                                                       \
+    return &r;                                                                                   \
   }
 REGISTER_FUNCTION(CAST)
 REGISTER_FUNCTION(Stack)