From 944fcfc9eb65d8227f4be628cc41a140ca1c0b7f Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=EC=B6=98=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 11:28:49 +0900 Subject: [PATCH] CAST_EX nnapi_delegate (#1429) 1. Add add_cast_ex_params 2. Add nnapi call from nnapi_delagate.cpp Signed-off-by: Chunseok Lee --- libs/support/tflite/src/nnapi_delegate.cpp | 11 ++++++++--- .../tflite/src/nnapi_delegate_ex_AddOpsAndParams_lambda.inc | 5 +++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libs/support/tflite/src/nnapi_delegate.cpp b/libs/support/tflite/src/nnapi_delegate.cpp index 697c2be..62f1e46 100644 --- a/libs/support/tflite/src/nnapi_delegate.cpp +++ b/libs/support/tflite/src/nnapi_delegate.cpp @@ -313,15 +313,21 @@ void AddOpsAndParams(tflite::Interpreter *interpreter, ANeuralNetworksModel *nn_ } case tflite::BuiltinOperator_STRIDED_SLICE: add_strided_slice_ex_params(node.builtin_data); - nn_op_type = ANEURALNETWORKS_STRIDED_SLICE_EX; // FIXME: This call is ugly. please fix this // Use ANN_addOperationEx for STRIDED_SLICE CHECK_NN(ANeuralNetworksModel_addOperationEx( - nn_model, static_cast(ANEURALNETWORKS_STRIDED_SLICE_EX), + nn_model, ANEURALNETWORKS_STRIDED_SLICE_EX, static_cast(augmented_inputs.size()), augmented_inputs.data(), static_cast(node.outputs->size), reinterpret_cast(node.outputs->data))); continue; + case tflite::BuiltinOperator_CAST: + add_cast_ex_params(node.builtin_data); + CHECK_NN(ANeuralNetworksModel_addOperationEx( + nn_model, ANEURALNETWORKS_CAST_EX, static_cast(augmented_inputs.size()), + augmented_inputs.data(), static_cast(node.outputs->size), + reinterpret_cast(node.outputs->data))); + continue; case tflite::BuiltinOperator_CONCAT_EMBEDDINGS: case tflite::BuiltinOperator_LSH_PROJECTION: case tflite::BuiltinOperator_SVDF: @@ -351,7 +357,6 @@ void AddOpsAndParams(tflite::Interpreter *interpreter, ANeuralNetworksModel *nn_ case tflite::BuiltinOperator_LOG_SOFTMAX: case tflite::BuiltinOperator_DEQUANTIZE: case tflite::BuiltinOperator_DELEGATE: - case tflite::BuiltinOperator_CAST: FATAL("Op code %d is currently not delegated to NNAPI", builtin); nn_op_type = -1; // set to invalid break; diff --git a/libs/support/tflite/src/nnapi_delegate_ex_AddOpsAndParams_lambda.inc b/libs/support/tflite/src/nnapi_delegate_ex_AddOpsAndParams_lambda.inc index 126ab71..4f5587a 100644 --- a/libs/support/tflite/src/nnapi_delegate_ex_AddOpsAndParams_lambda.inc +++ b/libs/support/tflite/src/nnapi_delegate_ex_AddOpsAndParams_lambda.inc @@ -31,3 +31,8 @@ } add_scalar_int32(builtin->shrink_axis_mask); }; + auto add_cast_ex_params = [&add_scalar_int32](void* data) { + auto builtin = reinterpret_cast(data); + add_scalar_int32(builtin->in_data_type); + add_scalar_int32(builtin->out_data_type); + }; -- 2.7.4