From 55c89c8ab523f81b495538976e2c2f64fa2a546e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 31 May 2018 08:41:01 +0900 Subject: [PATCH] TensorFlowMax nnapi_delegate (#1432) Add nnapi call from nnapi_delegate.cpp for TensorFlowMax Signed-off-by: Hyeongseok Oh --- libs/support/tflite/src/nnapi_delegate.cpp | 11 +++++++++++ tools/tflite_run/src/operators.cc | 11 ++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/libs/support/tflite/src/nnapi_delegate.cpp b/libs/support/tflite/src/nnapi_delegate.cpp index 7e072e1..697c2be 100644 --- a/libs/support/tflite/src/nnapi_delegate.cpp +++ b/libs/support/tflite/src/nnapi_delegate.cpp @@ -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(augmented_inputs.size()), augmented_inputs.data(), + static_cast(node.outputs->size), + reinterpret_cast(node.outputs->data))); + continue; + } + FATAL("Custom operations are not supported when using NNAPI."); nn_op_type = -1; // set to invalid break; diff --git a/tools/tflite_run/src/operators.cc b/tools/tflite_run/src/operators.cc index 626d871..c1a2997 100644 --- a/tools/tflite_run/src/operators.cc +++ b/tools/tflite_run/src/operators.cc @@ -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) -- 2.7.4