• 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 #ifndef TENSORFLOW_LITE_DELEGATES_GPU_COMMON_MODEL_BUILDER_H_
17 #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_MODEL_BUILDER_H_
18 
19 #include <cstdint>
20 #include <string>
21 
22 #include "tensorflow/lite/context.h"
23 #include "tensorflow/lite/delegates/gpu/common/model.h"
24 #include "tensorflow/lite/delegates/gpu/common/status.h"
25 
26 namespace tflite {
27 namespace gpu {
28 
29 // Validates which operations are supported and returns array of operations to
30 // replace with GPU kernels. The caller must free the pointer on TfLiteIntArray.
31 TfLiteIntArray* GetOpsToReplace(TfLiteContext* context);
32 
33 // Extracts TFLite delegate execution plan from the input TFLite context and
34 // converts it into generic graph format.
35 Status BuildModel(TfLiteContext* context,
36                   const TfLiteDelegateParams* delegate_params,
37                   GraphFloat32* graph);
38 
39 // Same as above but also apply all transformations on the final graph.
40 // Prefer using this method instead of BuildModel.
41 Status BuildFinalModel(TfLiteContext* context,
42                        const TfLiteDelegateParams* delegate_params,
43                        GraphFloat32* graph);
44 
45 // Module-internal converter, exposed for unit testing purpose only.
46 Status ConvertTfLiteTensorToTensorRef(const TfLiteTensor& tflite_tensor,
47                                       TensorRef<BHWC>* tensor_ref);
48 
49 }  // namespace gpu
50 }  // namespace tflite
51 
52 #endif  // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_MODEL_BUILDER_H_
53