• 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_GPU_COMMON_SELECTORS_SUBGRAPH_H_
17 #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_SELECTORS_SUBGRAPH_H_
18 
19 #include <memory>
20 #include <vector>
21 
22 #include "tensorflow/lite/delegates/gpu/common/model.h"
23 #include "tensorflow/lite/delegates/gpu/common/task/gpu_operation.h"
24 #include "tensorflow/lite/delegates/gpu/common/task/tensor_desc.h"
25 
26 namespace tflite {
27 namespace gpu {
28 
29 struct GPUOperationWithRefs {
30   std::unique_ptr<GPUOperation> operation;
31 
32   // input and output ids can be positive or negative.
33   // if we have positive id, we will use preallocated tensor from GraphFloat32
34   // otherwise, we will use ids for newly allocated tensors
35   std::vector<int> input_ids;
36   std::vector<int> output_ids;
37 };
38 
39 struct GPUOperationsSubgraph {
40   std::vector<GPUOperationWithRefs> operations;
41   std::vector<std::pair<BHWC, TensorDescriptor>> new_tensors;
42 };
43 
44 std::unique_ptr<GPUOperation>* InitSingleOpSubgraph(
45     const std::vector<Value*>& inputs, const std::vector<Value*>& outputs,
46     GPUOperationsSubgraph* gpu_subgraph);
47 
48 }  // namespace gpu
49 }  // namespace tflite
50 
51 #endif  // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_SELECTORS_SUBGRAPH_H_
52