Repository navigation
Expand file tree
/
Copy pathTFLMetalDelegate.h
More file actions
91 lines (76 loc) · 2.85 KB
/
Copy pathTFLMetalDelegate.h
File metadata and controls
91 lines (76 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright 2020 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#import <Foundation/Foundation.h>
#import "TFLDelegate.h"
NS_ASSUME_NONNULL_BEGIN
/**
* @enum TFLMetalDelegateThreadWaitType
* This enum specifies wait type for Metal delegate.
*/
typedef NS_ENUM(NSUInteger, TFLMetalDelegateThreadWaitType) {
/**
* The thread does not wait for the work to complete. Useful when the output of the work is used
* with the GPU pipeline.
*/
TFLMetalDelegateThreadWaitTypeDoNotWait,
/** The thread waits until the work is complete. */
TFLMetalDelegateThreadWaitTypePassive,
/**
* The thread waits for the work to complete with minimal latency, which may require additional
* CPU resources.
*/
TFLMetalDelegateThreadWaitTypeActive,
/** The thread waits for the work while trying to prevent the GPU from going into sleep mode. */
TFLMetalDelegateThreadWaitTypeAggressive,
};
/** Custom configuration options for a Metal delegate. */
@interface TFLMetalDelegateOptions : NSObject
/**
* Indicates whether the GPU delegate allows precision loss, such as allowing `Float16` precision
* for a `Float32` computation. The default is `false`.
*/
@property(nonatomic, getter=isPrecisionLossAllowed) BOOL precisionLossAllowed;
/**
* Indicates how the current thread should wait for work on the GPU to complete. The default
* is `TFLMetalDelegateThreadWaitTypePassive`.
*/
@property(nonatomic) TFLMetalDelegateThreadWaitType waitType;
/**
* Indicates whether the GPU delegate allows execution of an 8-bit quantized model. The default is
* `true`.
*/
@property(nonatomic, getter=isQuantizationEnabled) BOOL quantizationEnabled;
@end
/**
* A delegate that uses the `Metal` framework for performing TensorFlow Lite graph operations with
* GPU acceleration.
*/
@interface TFLMetalDelegate : TFLDelegate
/**
* Initializes a new GPU delegate with default options.
*
* @return A new GPU delegate with default options. `nil` when the GPU delegate creation fails.
*/
- (nullable instancetype)init;
/**
* Initializes a new GPU delegate with the given options.
*
* @param options GPU delegate options.
*
* @return A new GPU delegate with default options. `nil` when the GPU delegate creation fails.
*/
- (nullable instancetype)initWithOptions:(TFLMetalDelegateOptions *)options
NS_DESIGNATED_INITIALIZER;
@end
NS_ASSUME_NONNULL_END