diff --git a/include/onnxruntime/core/providers/nnapi/nnapi_provider_factory.h b/include/onnxruntime/core/providers/nnapi/nnapi_provider_factory.h index 57a1ba2aad..a0aeb5ac26 100644 --- a/include/onnxruntime/core/providers/nnapi/nnapi_provider_factory.h +++ b/include/onnxruntime/core/providers/nnapi/nnapi_provider_factory.h @@ -33,11 +33,21 @@ enum NNAPIFlags { // // For NNAPI device assignments, see https://developer.android.com/ndk/guides/neuralnetworks#device-assignment // For NNAPI CPU fallback, see https://developer.android.com/ndk/guides/neuralnetworks#cpu-fallback + // + // Please note, the NNAPI EP will return error status if both NNAPI_FLAG_CPU_DISABLED + // and NNAPI_FLAG_CPU_ONLY flags are set NNAPI_FLAG_CPU_DISABLED = 0x004, - // Keep NNAPI_FLAG_MAX at the end of the enum definition + // Using CPU only in NNAPI EP, this may decrease the perf but will provide + // reference output value without precision loss, which is useful for validation + // + // Please note, the NNAPI EP will return error status if both NNAPI_FLAG_CPU_DISABLED + // and NNAPI_FLAG_CPU_ONLY flags are set + NNAPI_FLAG_CPU_ONLY = 0x008, + + // Keep NNAPI_FLAG_LAST at the end of the enum definition // And assign the last NNAPIFlag to it - NNAPI_FLAG_LAST = NNAPI_FLAG_CPU_DISABLED, + NNAPI_FLAG_LAST = NNAPI_FLAG_CPU_ONLY, }; #ifdef __cplusplus diff --git a/java/src/main/java/ai/onnxruntime/providers/NNAPIFlags.java b/java/src/main/java/ai/onnxruntime/providers/NNAPIFlags.java index 560d15b081..696ecb9bd8 100644 --- a/java/src/main/java/ai/onnxruntime/providers/NNAPIFlags.java +++ b/java/src/main/java/ai/onnxruntime/providers/NNAPIFlags.java @@ -8,7 +8,8 @@ package ai.onnxruntime.providers; public enum NNAPIFlags implements OrtFlags { USE_FP16(1), // NNAPI_FLAG_USE_FP16(0x001) USE_NCHW(2), // NNAPI_FLAG_USE_NCHW(0x002) - CPU_DISABLED(4); // NNAPI_FLAG_CPU_DISABLED(0x004) + CPU_DISABLED(4), // NNAPI_FLAG_CPU_DISABLED(0x004) + CPU_ONLY(8); // NNAPI_FLAG_CPU_ONLY(0x008) public final int value; diff --git a/onnxruntime/core/providers/nnapi/nnapi_builtin/nnapi_execution_provider.cc b/onnxruntime/core/providers/nnapi/nnapi_builtin/nnapi_execution_provider.cc index 5ba0a02176..c049f2e292 100644 --- a/onnxruntime/core/providers/nnapi/nnapi_builtin/nnapi_execution_provider.cc +++ b/onnxruntime/core/providers/nnapi/nnapi_builtin/nnapi_execution_provider.cc @@ -235,8 +235,15 @@ common::Status NnapiExecutionProvider::Compile(const std::vector nnapi_model; diff --git a/tools/ci_build/github/azure-pipelines/templates/android-java-api-aar.yml b/tools/ci_build/github/azure-pipelines/templates/android-java-api-aar.yml index c4385ae98b..f6d9e8e2af 100644 --- a/tools/ci_build/github/azure-pipelines/templates/android-java-api-aar.yml +++ b/tools/ci_build/github/azure-pipelines/templates/android-java-api-aar.yml @@ -25,6 +25,7 @@ parameters: default: '' - name: publish_executables + # The executables will only be published if the publish_executables is set to "1" displayName: Publish executables such as onnxruntime_perf_test, ... type: string default: '0'