NNAPIFlags enum

NNAPIFlags are bool options we want to set for NNAPI EP This enum is defined as bit flags, and cannot have negative value To generate an uint32_t nnapi_flags for using with OrtSessionOptionsAppendExecutionProvider_Nnapi below, uint32_t nnapi_flags = 0; nnapi_flags |= NNAPI_FLAG_USE_FP16;

Inheritance
Available extensions

Values

NNAPI_FLAG_USE_NONE → const NNAPIFlags
const NNAPIFlags(0)
NNAPI_FLAG_USE_FP16 → const NNAPIFlags

Using fp16 relaxation in NNAPI EP, this may improve perf but may also reduce precision

const NNAPIFlags(1)
NNAPI_FLAG_USE_NCHW → const NNAPIFlags

Use NCHW layout in NNAPI EP, this is only available after Android API level 29 Please note for now, NNAPI perform worse using NCHW compare to using NHWC

const NNAPIFlags(2)
NNAPI_FLAG_CPU_DISABLED → const NNAPIFlags

Prevent NNAPI from using CPU devices.

NNAPI is more efficient using GPU or NPU for execution, and NNAPI might fall back to its own CPU implementation for operations not supported by GPU/NPU. The CPU implementation of NNAPI (which is called nnapi-reference) might be less efficient than the optimized versions of the operation of ORT. It might be advantageous to disable the NNAPI CPU fallback and handle execution using ORT kernels.

For some models, if NNAPI would use CPU to execute an operation, and this flag is set, the execution of the model may fall back to ORT kernels.

This option is only available after Android API level 29, and will be ignored for Android API level 28-

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

const NNAPIFlags(4)
NNAPI_FLAG_CPU_ONLY → const NNAPIFlags

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

const NNAPIFlags(8)

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
name String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value int
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromValue(int value) NNAPIFlags

Constants

NNAPI_FLAG_LAST → const NNAPIFlags
Keep NNAPI_FLAG_LAST at the end of the enum definition And assign the last NNAPIFlag to it
values → const List<NNAPIFlags>
A constant List of the values in this enum, in order of their declaration.