• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2020 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 #ifndef TENSORFLOW_LITE_DELEGATES_UTILS_DUMMY_DELEGATE_DUMMY_DELEGATE_H_
17 #define TENSORFLOW_LITE_DELEGATES_UTILS_DUMMY_DELEGATE_DUMMY_DELEGATE_H_
18 
19 #include <memory>
20 
21 #include "tensorflow/lite/c/common.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif  // __cplusplus
26 
27 typedef struct {
28   // Allowed ops to delegate.
29   int allowed_builtin_code;
30   // Report error during init.
31   bool error_during_init;
32   // Report error during prepare.
33   bool error_during_prepare;
34   // Report error during invoke.
35   bool error_during_invoke;
36 } DummyDelegateOptions;
37 
38 // Returns a structure with the default delegate options.
39 DummyDelegateOptions TfLiteDummyDelegateOptionsDefault();
40 
41 // Creates a new delegate instance that needs to be destroyed with
42 // `TfLiteDummyDelegateDelete` when delegate is no longer used by TFLite.
43 // When `options` is set to `nullptr`, the above default values are used:
44 TfLiteDelegate* TfLiteDummyDelegateCreate(const DummyDelegateOptions* options);
45 
46 // Destroys a delegate created with `TfLiteDummyDelegateCreate` call.
47 void TfLiteDummyDelegateDelete(TfLiteDelegate* delegate);
48 #ifdef __cplusplus
49 }
50 #endif  // __cplusplus
51 
52 // A convenient wrapper that returns C++ std::unique_ptr for automatic memory
53 // management.
54 inline std::unique_ptr<TfLiteDelegate, void (*)(TfLiteDelegate*)>
TfLiteDummyDelegateCreateUnique(const DummyDelegateOptions * options)55 TfLiteDummyDelegateCreateUnique(const DummyDelegateOptions* options) {
56   return std::unique_ptr<TfLiteDelegate, void (*)(TfLiteDelegate*)>(
57       TfLiteDummyDelegateCreate(options), TfLiteDummyDelegateDelete);
58 }
59 
60 #endif  // TENSORFLOW_LITE_DELEGATES_UTILS_DUMMY_DELEGATE_DUMMY_DELEGATE_H_
61