• 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_TASK_TEXTURE2D_DESC_H_
17 #define TENSORFLOW_LITE_DELEGATES_GPU_COMMON_TASK_TEXTURE2D_DESC_H_
18 
19 #include "tensorflow/lite/delegates/gpu/common/data_type.h"
20 #include "tensorflow/lite/delegates/gpu/common/status.h"
21 #include "tensorflow/lite/delegates/gpu/common/task/gpu_object_desc.h"
22 #include "tensorflow/lite/delegates/gpu/common/types.h"
23 
24 namespace tflite {
25 namespace gpu {
26 
27 struct Texture2DDescriptor : public GPUObjectDescriptor {
28   DataType element_type;
29   bool normalized = false;   // used with INT data types, if normalized, we read
30                              // in kernel float data.
31   DataType normalized_type;  // can be FLOAT32 or FLOAT16, using with normalized
32                              // = true
33 
34   // optional
35   int2 size = int2(0, 0);
36   std::vector<uint8_t> data;
37 
38   Texture2DDescriptor() = default;
39   Texture2DDescriptor(const Texture2DDescriptor&) = default;
40   Texture2DDescriptor& operator=(const Texture2DDescriptor&) = default;
41   Texture2DDescriptor(Texture2DDescriptor&& desc) = default;
42   Texture2DDescriptor& operator=(Texture2DDescriptor&& desc) = default;
43 
44   absl::Status PerformSelector(const GpuInfo& gpu_info,
45                                const std::string& selector,
46                                const std::vector<std::string>& args,
47                                const std::vector<std::string>& template_args,
48                                std::string* result) const override;
49 
50   GPUResources GetGPUResources() const override;
51   absl::Status PerformReadSelector(const GpuInfo& gpu_info,
52                                    const std::vector<std::string>& args,
53                                    std::string* result) const;
54 
55   void Release() override;
56 };
57 
58 }  // namespace gpu
59 }  // namespace tflite
60 
61 #endif  // TENSORFLOW_LITE_DELEGATES_GPU_COMMON_TASK_TEXTURE2D_DESC_H_
62