Skip to content

Commit 3d3cf2a

Browse files
authored
Return retained objects from Value constructors.
Differential Revision: D76491605 Pull Request resolved: #11632
1 parent 333395e commit 3d3cf2a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

extension/apple/ExecuTorch/Exported/ExecuTorchValue.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ __attribute__((deprecated("This API is experimental.")))
173173
* @param value An ExecuTorchTensor instance.
174174
* @return A new ExecuTorchValue instance with a tag of ExecuTorchValueTagTensor.
175175
*/
176-
+ (instancetype)valueWithTensor:(ExecuTorchTensor *)value NS_REFINED_FOR_SWIFT;
176+
+ (instancetype)valueWithTensor:(ExecuTorchTensor *)value
177+
NS_REFINED_FOR_SWIFT
178+
NS_RETURNS_RETAINED;
177179

178180
/**
179181
* Creates an instance encapsulating a string.
@@ -182,7 +184,8 @@ __attribute__((deprecated("This API is experimental.")))
182184
* @return A new ExecuTorchValue instance with a tag of ExecuTorchValueTagString.
183185
*/
184186
+ (instancetype)valueWithString:(ExecuTorchStringValue)value
185-
NS_SWIFT_NAME(init(_:));
187+
NS_SWIFT_NAME(init(_:))
188+
NS_RETURNS_RETAINED;
186189

187190
/**
188191
* Creates an instance encapsulating a boolean.
@@ -191,7 +194,8 @@ __attribute__((deprecated("This API is experimental.")))
191194
* @return A new ExecuTorchValue instance with a tag of ExecuTorchValueTagBoolean.
192195
*/
193196
+ (instancetype)valueWithBoolean:(ExecuTorchBooleanValue)value
194-
NS_SWIFT_NAME(init(_:));
197+
NS_SWIFT_NAME(init(_:))
198+
NS_RETURNS_RETAINED;
195199

196200
/**
197201
* Creates an instance encapsulating an integer.
@@ -200,7 +204,8 @@ __attribute__((deprecated("This API is experimental.")))
200204
* @return A new ExecuTorchValue instance with a tag of ExecuTorchValueTagInteger.
201205
*/
202206
+ (instancetype)valueWithInteger:(ExecuTorchIntegerValue)value
203-
NS_SWIFT_NAME(init(_:));
207+
NS_SWIFT_NAME(init(_:))
208+
NS_RETURNS_RETAINED;
204209

205210
/**
206211
* Creates an instance encapsulating a double value.
@@ -209,7 +214,8 @@ __attribute__((deprecated("This API is experimental.")))
209214
* @return A new ExecuTorchValue instance with a tag of ExecuTorchValueTagDouble.
210215
*/
211216
+ (instancetype)valueWithDouble:(ExecuTorchDoubleValue)value
212-
NS_SWIFT_NAME(init(_:));
217+
NS_SWIFT_NAME(init(_:))
218+
NS_RETURNS_RETAINED;
213219

214220
/**
215221
* Creates an instance encapsulating a float value.
@@ -221,7 +227,8 @@ __attribute__((deprecated("This API is experimental.")))
221227
* @return A new ExecuTorchValue instance with a tag of ExecuTorchValueTagDouble.
222228
*/
223229
+ (instancetype)valueWithFloat:(ExecuTorchFloatValue)value
224-
NS_SWIFT_NAME(init(_:));
230+
NS_SWIFT_NAME(init(_:))
231+
NS_RETURNS_RETAINED;
225232

226233
/**
227234
* Creates an instance encapsulating a scalar value.
@@ -232,7 +239,8 @@ __attribute__((deprecated("This API is experimental.")))
232239
* @return A new ExecuTorchValue instance with the appropriate tag.
233240
*/
234241
+ (instancetype)valueWithScalar:(ExecuTorchScalarValue)value
235-
NS_SWIFT_NAME(init(_:));
242+
NS_SWIFT_NAME(init(_:))
243+
NS_RETURNS_RETAINED;
236244

237245
/**
238246
* Returns a copy of the value.

0 commit comments

Comments
 (0)