1 // Copyright 2018 Google Inc. 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 #import <Foundation/Foundation.h>
16 
17 NS_ASSUME_NONNULL_BEGIN
18 
19 /** Custom configuration options for a TensorFlow Lite interpreter. */
20 @interface TFLInterpreterOptions : NSObject
21 
22 /**
23  * Maximum number of threads that the interpreter should run on. Defaults to 0 (unspecified, letting
24  * TensorFlow Lite to optimize the threading decision).
25  */
26 @property(nonatomic) NSUInteger numberOfThreads;
27 
28 /**
29  * Experimental: Enable an optimized set of floating point CPU kernels (provided by XNNPACK).
30  *
31  * Enabling this flag will enable use of a new, highly optimized set of CPU kernels provided via the
32  * XNNPACK delegate. Currently, this is restricted to a subset of floating point operations.
33  * Eventually, we plan to enable this by default, as it can provide significant performance benefits
34  * for many classes of floating point models. See
35  * https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/delegates/xnnpack/README.md
36  * for more details.
37  *
38  * Things to keep in mind when enabling this flag:
39  *
40  *     * Startup time and resize time may increase.
41  *     * Baseline memory consumption may increase.
42  *     * Compatibility with other delegates (e.g., GPU) has not been fully validated.
43  *     * Quantized models will not see any benefit.
44  *
45  * WARNING: This is an experimental interface that is subject to change.
46  */
47 @property(nonatomic) BOOL useXNNPACK;
48 
49 /**
50  * Initializes a new instance of `TFLInterpreterOptions`.
51  *
52  * @return A new instance of `TFLInterpreterOptions`.
53  */
54 - (instancetype)init NS_DESIGNATED_INITIALIZER;
55 
56 @end
57 
58 NS_ASSUME_NONNULL_END
59