• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2021 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_METAL_METAL_DEVICE_H_
17 #define TENSORFLOW_LITE_DELEGATES_GPU_METAL_METAL_DEVICE_H_
18 
19 #import <Metal/Metal.h>
20 
21 #include <string>
22 #include <vector>
23 
24 #include "tensorflow/lite/delegates/gpu/common/gpu_info.h"
25 
26 namespace tflite {
27 namespace gpu {
28 namespace metal {
29 
30 // A wrapper around metal device
31 class MetalDevice {
32  public:
33   MetalDevice();
34   MetalDevice(id<MTLDevice> device);
35 
36   MetalDevice(MetalDevice&& device) = default;
37   MetalDevice& operator=(MetalDevice&& device) = default;
38   MetalDevice(const MetalDevice&) = delete;
39   MetalDevice& operator=(const MetalDevice&) = delete;
40 
41   ~MetalDevice() = default;
42 
device()43   id<MTLDevice> device() const { return device_; }
44 
GetInfo()45   const GpuInfo& GetInfo() const { return info_; }
46 
47   bool IsLanguageVersion2orHigher() const;
48 
49  private:
50   id<MTLDevice> device_ = nullptr;
51   GpuInfo info_;
52 };
53 
54 }  // namespace metal
55 }  // namespace gpu
56 }  // namespace tflite
57 
58 #endif  // TENSORFLOW_LITE_DELEGATES_GPU_METAL_METAL_DEVICE_H_
59