-
Notifications
You must be signed in to change notification settings - Fork 981
Expand file tree
/
Copy pathExecuTorchBackendOption.h
More file actions
89 lines (74 loc) · 2.55 KB
/
ExecuTorchBackendOption.h
File metadata and controls
89 lines (74 loc) · 2.55 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
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
* Enum to define the type of a backend option value.
*/
typedef NS_ENUM(NSInteger, ExecuTorchBackendOptionType) {
ExecuTorchBackendOptionTypeBoolean,
ExecuTorchBackendOptionTypeInteger,
ExecuTorchBackendOptionTypeString,
} NS_SWIFT_NAME(BackendOptionType);
/**
* Represents a single key-value configuration option for a backend.
*
* Backend options are used to pass per-delegate configuration (e.g., compute
* unit, thread count, cache directory) when loading a module. Each option has
* a string key and a typed value (boolean, integer, or string).
*/
NS_SWIFT_NAME(BackendOption)
__attribute__((objc_subclassing_restricted))
@interface ExecuTorchBackendOption : NSObject
/** The option key name (e.g. "compute_unit", "num_threads"). */
@property (nonatomic, readonly) NSString *key;
/** The type of the option value. */
@property (nonatomic, readonly) ExecuTorchBackendOptionType type;
/** The boolean value. Only valid when type is Boolean. */
@property (nonatomic, readonly) BOOL boolValue;
/** The integer value. Only valid when type is Integer. */
@property (nonatomic, readonly) NSInteger intValue;
/** The string value. Only valid when type is String. */
@property (nullable, nonatomic, readonly) NSString *stringValue;
/**
* Creates a backend option with a boolean value.
*
* @param key The option key.
* @param value The boolean value.
* @return A new ExecuTorchBackendOption instance.
*/
+ (instancetype)optionWithKey:(NSString *)key
booleanValue:(BOOL)value
NS_SWIFT_NAME(init(_:_:))
NS_RETURNS_RETAINED;
/**
* Creates a backend option with an integer value.
*
* @param key The option key.
* @param value The integer value.
* @return A new ExecuTorchBackendOption instance.
*/
+ (instancetype)optionWithKey:(NSString *)key
integerValue:(NSInteger)value
NS_SWIFT_NAME(init(_:_:))
NS_RETURNS_RETAINED;
/**
* Creates a backend option with a string value.
*
* @param key The option key.
* @param value The string value.
* @return A new ExecuTorchBackendOption instance.
*/
+ (instancetype)optionWithKey:(NSString *)key
stringValue:(NSString *)value
NS_SWIFT_NAME(init(_:_:))
NS_RETURNS_RETAINED;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END