HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
nnapi_provider_factory.h
Go to the documentation of this file.
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
// Licensed under the MIT License.
3
#pragma once
4
5
#include "onnxruntime_c_api.h"
6
7
// NNAPIFlags are bool options we want to set for NNAPI EP
8
// This enum is defined as bit flags, and cannot have negative value
9
// To generate an uint32_t nnapi_flags for using with OrtSessionOptionsAppendExecutionProvider_Nnapi below,
10
// uint32_t nnapi_flags = 0;
11
// nnapi_flags |= NNAPI_FLAG_USE_FP16;
12
enum
NNAPIFlags
{
13
NNAPI_FLAG_USE_NONE
= 0x000,
14
15
// Using fp16 relaxation in NNAPI EP, this may improve perf but may also reduce precision
16
NNAPI_FLAG_USE_FP16
= 0x001,
17
18
// Use NCHW layout in NNAPI EP, this is only available after Android API level 29
19
// Please note for now, NNAPI perform worse using NCHW compare to using NHWC
20
NNAPI_FLAG_USE_NCHW
= 0x002,
21
22
// Prevent NNAPI from using CPU devices.
23
//
24
// NNAPI is more efficient using GPU or NPU for execution, and NNAPI might fall back to its own CPU implementation
25
// for operations not supported by GPU/NPU. The CPU implementation of NNAPI (which is called nnapi-reference)
26
// might be less efficient than the optimized versions of the operation of ORT. It might be advantageous to disable
27
// the NNAPI CPU fallback and handle execution using ORT kernels.
28
//
29
// For some models, if NNAPI would use CPU to execute an operation, and this flag is set, the execution of the
30
// model may fall back to ORT kernels.
31
//
32
// This option is only available after Android API level 29, and will be ignored for Android API level 28-
33
//
34
// For NNAPI device assignments, see https://developer.android.com/ndk/guides/neuralnetworks#device-assignment
35
// For NNAPI CPU fallback, see https://developer.android.com/ndk/guides/neuralnetworks#cpu-fallback
36
//
37
// Please note, the NNAPI EP will return error status if both NNAPI_FLAG_CPU_DISABLED
38
// and NNAPI_FLAG_CPU_ONLY flags are set
39
NNAPI_FLAG_CPU_DISABLED
= 0x004,
40
41
// Using CPU only in NNAPI EP, this may decrease the perf but will provide
42
// reference output value without precision loss, which is useful for validation
43
//
44
// Please note, the NNAPI EP will return error status if both NNAPI_FLAG_CPU_DISABLED
45
// and NNAPI_FLAG_CPU_ONLY flags are set
46
NNAPI_FLAG_CPU_ONLY
= 0x008,
47
48
// Keep NNAPI_FLAG_LAST at the end of the enum definition
49
// And assign the last NNAPIFlag to it
50
NNAPI_FLAG_LAST
=
NNAPI_FLAG_CPU_ONLY
,
51
};
52
53
#ifdef __cplusplus
54
extern
"C"
{
55
#endif
56
57
ORT_EXPORT
ORT_API_STATUS
(OrtSessionOptionsAppendExecutionProvider_Nnapi,
58
_In_ OrtSessionOptions* options, uint32_t nnapi_flags);
59
60
#ifdef __cplusplus
61
}
62
#endif
NNAPI_FLAG_CPU_DISABLED
Definition:
nnapi_provider_factory.h:39
NNAPI_FLAG_CPU_ONLY
Definition:
nnapi_provider_factory.h:46
NNAPI_FLAG_USE_NCHW
Definition:
nnapi_provider_factory.h:20
NNAPI_FLAG_LAST
Definition:
nnapi_provider_factory.h:50
NNAPIFlags
NNAPIFlags
Definition:
nnapi_provider_factory.h:12
NNAPI_FLAG_USE_FP16
Definition:
nnapi_provider_factory.h:16
NNAPI_FLAG_USE_NONE
Definition:
nnapi_provider_factory.h:13
ORT_API_STATUS
ORT_EXPORT ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_Nnapi, _In_ OrtSessionOptions *options, uint32_t nnapi_flags)
onnxruntime
core
providers
nnapi
nnapi_provider_factory.h
Generated on Sun Nov 17 2024 03:01:33 for HDK by
1.8.6