@@ -30,6 +30,17 @@ typedef NS_ENUM(uint32_t, ExecuTorchValueTag) {
30
30
ExecuTorchValueTagOptionalTensorList,
31
31
} NS_SWIFT_NAME(ValueTag);
32
32
33
+ typedef NSNumber *ExecuTorchScalarValue
34
+ NS_SWIFT_BRIDGED_TYPEDEF NS_SWIFT_NAME (ScalarValue);
35
+ typedef NSString *ExecuTorchStringValue
36
+ NS_SWIFT_BRIDGED_TYPEDEF NS_SWIFT_NAME (StringValue);
37
+ typedef BOOL ExecuTorchBooleanValue
38
+ NS_SWIFT_BRIDGED_TYPEDEF NS_SWIFT_NAME (BoolValue);
39
+ typedef NSInteger ExecuTorchIntegerValue
40
+ NS_SWIFT_BRIDGED_TYPEDEF NS_SWIFT_NAME (IntegerValue);
41
+ typedef double ExecuTorchDoubleValue
42
+ NS_SWIFT_BRIDGED_TYPEDEF NS_SWIFT_NAME (DoubleValue);
43
+
33
44
/* *
34
45
* A dynamic value type used by ExecuTorch.
35
46
*
@@ -54,6 +65,41 @@ __attribute__((deprecated("This API is experimental.")))
54
65
*/
55
66
@property(nullable, nonatomic, readonly) ExecuTorchTensor *tensorValue NS_SWIFT_NAME (tensor);
56
67
68
+ /* *
69
+ * The string value if the tag is ExecuTorchValueTagString.
70
+ *
71
+ * @return An NSString instance or nil.
72
+ */
73
+ @property(nullable, nonatomic, readonly) ExecuTorchStringValue stringValue NS_SWIFT_NAME (string);
74
+
75
+ /* *
76
+ * The scalar value if the tag is boolean, integer or double.
77
+ *
78
+ * @return A scalar value or nil.
79
+ */
80
+ @property(nullable, nonatomic, readonly) ExecuTorchScalarValue scalarValue NS_SWIFT_NAME (scalar);
81
+
82
+ /* *
83
+ * The boolean value if the tag is ExecuTorchValueTagBoolean.
84
+ *
85
+ * @return A BOOL representing the boolean value.
86
+ */
87
+ @property(nonatomic, readonly) ExecuTorchBooleanValue boolValue NS_SWIFT_NAME (boolean);
88
+
89
+ /* *
90
+ * The integer value if the tag is ExecuTorchValueTagInteger.
91
+ *
92
+ * @return An NSInteger representing the integer value.
93
+ */
94
+ @property(nonatomic, readonly) ExecuTorchIntegerValue intValue NS_SWIFT_NAME (integer);
95
+
96
+ /* *
97
+ * The double value if the tag is ExecuTorchValueTagDouble.
98
+ *
99
+ * @return A double representing the double value.
100
+ */
101
+ @property(nonatomic, readonly) ExecuTorchDoubleValue doubleValue NS_SWIFT_NAME (double );
102
+
57
103
/* *
58
104
* Returns YES if the value is of type None.
59
105
*
@@ -68,6 +114,41 @@ __attribute__((deprecated("This API is experimental.")))
68
114
*/
69
115
@property(nonatomic, readonly) BOOL isTensor;
70
116
117
+ /* *
118
+ * Returns YES if the value is a string.
119
+ *
120
+ * @return A BOOL indicating whether the value is a string.
121
+ */
122
+ @property(nonatomic, readonly) BOOL isString;
123
+
124
+ /* *
125
+ * Returns YES if the value is a scalar (boolean, integer or double).
126
+ *
127
+ * @return A BOOL indicating whether the value is a scalar.
128
+ */
129
+ @property(nonatomic, readonly) BOOL isScalar;
130
+
131
+ /* *
132
+ * Returns YES if the value is a boolean.
133
+ *
134
+ * @return A BOOL indicating whether the value is a boolean.
135
+ */
136
+ @property(nonatomic, readonly) BOOL isBoolean;
137
+
138
+ /* *
139
+ * Returns YES if the value is an integer.
140
+ *
141
+ * @return A BOOL indicating whether the value is an integer.
142
+ */
143
+ @property(nonatomic, readonly) BOOL isInteger;
144
+
145
+ /* *
146
+ * Returns YES if the value is a double.
147
+ *
148
+ * @return A BOOL indicating whether the value is a double.
149
+ */
150
+ @property(nonatomic, readonly) BOOL isDouble;
151
+
71
152
/* *
72
153
* Creates an instance encapsulating a Tensor.
73
154
*
@@ -76,6 +157,42 @@ __attribute__((deprecated("This API is experimental.")))
76
157
*/
77
158
+ (instancetype )valueWithTensor:(ExecuTorchTensor *)value NS_SWIFT_NAME (init(_:));
78
159
160
+ /* *
161
+ * Creates an instance encapsulating a string.
162
+ *
163
+ * @param value A string.
164
+ * @return A new ExecuTorchValue instance with a tag of ExecuTorchValueTagString.
165
+ */
166
+ + (instancetype )valueWithString:(ExecuTorchStringValue)value
167
+ NS_SWIFT_NAME (init(_:));
168
+
169
+ /* *
170
+ * Creates an instance encapsulating a boolean.
171
+ *
172
+ * @param value A boolean.
173
+ * @return A new ExecuTorchValue instance with a tag of ExecuTorchValueTagBoolean.
174
+ */
175
+ + (instancetype )valueWithBoolean:(ExecuTorchBooleanValue)value
176
+ NS_SWIFT_NAME (init(_:));
177
+
178
+ /* *
179
+ * Creates an instance encapsulating an integer.
180
+ *
181
+ * @param value An integer.
182
+ * @return A new ExecuTorchValue instance with a tag of ExecuTorchValueTagInteger.
183
+ */
184
+ + (instancetype )valueWithInteger:(ExecuTorchIntegerValue)value
185
+ NS_SWIFT_NAME (init(_:));
186
+
187
+ /* *
188
+ * Creates an instance encapsulating a double value.
189
+ *
190
+ * @param value A double value.
191
+ * @return A new ExecuTorchValue instance with a tag of ExecuTorchValueTagDouble.
192
+ */
193
+ + (instancetype )valueWithDouble:(ExecuTorchDoubleValue)value
194
+ NS_SWIFT_NAME (init(_:));
195
+
79
196
@end
80
197
81
198
NS_ASSUME_NONNULL_END
0 commit comments