• 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_GL_API2_H_
17 #define TENSORFLOW_LITE_DELEGATES_GPU_GL_API2_H_
18 
19 #include <cstdint>
20 #include <memory>
21 
22 #include "absl/types/span.h"
23 #include "tensorflow/lite/delegates/gpu/api.h"
24 #include "tensorflow/lite/delegates/gpu/common/model.h"
25 #include "tensorflow/lite/delegates/gpu/common/status.h"
26 #include "tensorflow/lite/delegates/gpu/gl/command_queue.h"
27 
28 namespace tflite {
29 namespace gpu {
30 namespace gl {
31 
32 struct InferenceOptions : public tflite::gpu::InferenceOptions {};
33 
34 struct InferenceEnvironmentProperties {
35   bool is_opengl_available = false;
36 };
37 
38 // Manages all resources that need to stay around as long as any inference is
39 // running using the OpenGL backend.
40 class InferenceEnvironment {
41  public:
42   virtual ~InferenceEnvironment() = default;
43 
44   virtual absl::Status NewInferenceBuilder(
45       GraphFloat32&& model, const InferenceOptions& options,
46       std::unique_ptr<InferenceBuilder>* builder) = 0;
47 };
48 
49 struct InferenceEnvironmentOptions {
50   CommandQueue* queue = nullptr;
51 };
52 
53 // Creates a new OpenGL environment that needs to stay around until all
54 // inference runners are destroyed.
55 absl::Status NewInferenceEnvironment(
56     const InferenceEnvironmentOptions& options,
57     std::unique_ptr<InferenceEnvironment>* environment,
58     InferenceEnvironmentProperties* properties /* optional */);
59 
60 }  // namespace gl
61 }  // namespace gpu
62 }  // namespace tflite
63 
64 #endif  // TENSORFLOW_LITE_DELEGATES_GPU_GL_API2_H_
65