• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #include "tensorflow/lite/delegates/nnapi/nnapi_delegate.h"
17 
18 namespace tflite {
19 
20 // Return a non-functional NN API Delegate struct.
NnApiDelegate()21 TfLiteDelegate* NnApiDelegate() {
22   static StatefulNnApiDelegate* delegate = new StatefulNnApiDelegate();
23   return delegate;
24 }
25 
StatefulNnApiDelegate(const NnApi *)26 StatefulNnApiDelegate::StatefulNnApiDelegate(const NnApi* /* nnapi */)
27     : StatefulNnApiDelegate() {}
28 
StatefulNnApiDelegate(Options)29 StatefulNnApiDelegate::StatefulNnApiDelegate(Options /* options */)
30     : StatefulNnApiDelegate() {}
31 
StatefulNnApiDelegate(const NnApi *,Options)32 StatefulNnApiDelegate::StatefulNnApiDelegate(const NnApi* /* nnapi */,
33                                              Options /* options */)
34     : StatefulNnApiDelegate() {}
35 
StatefulNnApiDelegate()36 StatefulNnApiDelegate::StatefulNnApiDelegate()
37     : TfLiteDelegate(TfLiteDelegateCreate()),
38       delegate_data_(/*nnapi=*/nullptr) {
39   Prepare = DoPrepare;
40 }
41 
DoPrepare(TfLiteContext *,TfLiteDelegate *)42 TfLiteStatus StatefulNnApiDelegate::DoPrepare(TfLiteContext* /* context */,
43                                               TfLiteDelegate* /* delegate */) {
44   return kTfLiteOk;
45 }
46 
RegisterNnapiMemory(ANeuralNetworksMemory * memory,CopyToHostTensorFnPtr callback,void * callback_context)47 TfLiteBufferHandle StatefulNnApiDelegate::RegisterNnapiMemory(
48     ANeuralNetworksMemory* memory, CopyToHostTensorFnPtr callback,
49     void* callback_context) {
50   return kTfLiteNullBufferHandle;
51 }
52 
GetNnApiErrno() const53 int StatefulNnApiDelegate::GetNnApiErrno() const { return 0; }
54 
55 using ::tflite::delegate::nnapi::NNAPIDelegateKernel;
56 
Data(const NnApi * nnapi)57 StatefulNnApiDelegate::Data::Data(const NnApi* nnapi) : nnapi(nnapi) {}
58 
~Data()59 StatefulNnApiDelegate::Data::~Data() {}
60 
CacheDelegateKernel(const TfLiteDelegateParams * delegate_params,NNAPIDelegateKernel * delegate_state)61 void StatefulNnApiDelegate::Data::CacheDelegateKernel(
62     const TfLiteDelegateParams* delegate_params,
63     NNAPIDelegateKernel* delegate_state) {}
64 
MaybeGetCachedDelegateKernel(const TfLiteDelegateParams * delegate_params)65 NNAPIDelegateKernel* StatefulNnApiDelegate::Data::MaybeGetCachedDelegateKernel(
66     const TfLiteDelegateParams* delegate_params) {
67   return nullptr;
68 }
69 
70 }  // namespace tflite
71