8 #include <DelegateOptions.hpp>
11 #include <tensorflow/core/public/version.h>
12 #include <tensorflow/lite/c/c_api_opaque.h>
14 #include <tensorflow/lite/acceleration/configuration/delegate_registry.h>
15 #include <tensorflow/lite/core/acceleration/configuration/c/stable_delegate.h>
17 #if TF_MAJOR_VERSION > 2 || (TF_MAJOR_VERSION == 2 && TF_MINOR_VERSION > 5)
18 #define ARMNN_POST_TFLITE_2_5
43 TfLiteStatus
DoPrepare(TfLiteOpaqueContext* context, TfLiteOpaqueDelegate* delegate,
void* data);
45 armnnDelegate::DelegateOptions
ParseArmNNSettings(
const tflite::TFLiteSettings* tflite_settings);
69 return instance.get();
72 TfLiteOpaqueDelegateBuilder m_Builder =
74 reinterpret_cast<void*
>(
this),
79 kTfLiteDelegateFlagsNone,
85 armnnDelegate::DelegateOptions m_Options;
88 static int TfLiteArmnnOpaqueDelegateErrno(TfLiteOpaqueDelegate* delegate) {
return 0; }
93 using tflite::delegates::DelegatePluginInterface;
99 static std::unique_ptr<ArmnnDelegatePlugin>
New(
const tflite::TFLiteSettings& tfliteSettings)
101 return std::make_unique<ArmnnDelegatePlugin>(tfliteSettings);
104 tflite::delegates::TfLiteDelegatePtr
Create()
override
120 armnnDelegate::DelegateOptions m_delegateOptions;
128 const TfLiteOpaqueDelegateParams* parameters,
133 TfLiteStatus
Prepare(TfLiteOpaqueContext* tfLiteContext);
135 TfLiteStatus
Invoke(TfLiteOpaqueContext* tfLiteContext, TfLiteOpaqueNode* tfLiteNode);
138 TfLiteOpaqueContext* tfLiteContext,
139 TfLiteRegistrationExternal* tfLiteRegistration,
140 TfLiteOpaqueNode* tfLiteNode,
145 std::vector<armnn::BindingPointInfo>& inputBindings,
146 std::vector<armnn::BindingPointInfo>& outputBindings)
147 : m_NetworkId(networkId)
149 , m_InputBindings(inputBindings)
150 , m_OutputBindings(outputBindings)
152 static TfLiteStatus AddInputLayer(
DelegateData& delegateData,
153 TfLiteOpaqueContext* tfLiteContext,
154 const TfLiteIntArray* inputs,
155 std::vector<armnn::BindingPointInfo>& inputBindings);
156 static TfLiteStatus AddOutputLayer(
DelegateData& delegateData,
157 TfLiteOpaqueContext* tfLiteContext,
158 const TfLiteIntArray* outputs,
159 std::vector<armnn::BindingPointInfo>& outputBindings);
165 std::vector<armnn::BindingPointInfo> m_InputBindings;
166 std::vector<armnn::BindingPointInfo> m_OutputBindings;