Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion extension/apple/ExecuTorch/Exported/ExecuTorchValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ __attribute__((deprecated("This API is experimental.")))
@property(nonatomic, readonly) BOOL isDouble;

/**
* Returns YES if the value is a float.
* Returns YES if the value's tag is Double.
*
* Note: Since float values are stored with a Double tag, this property will
* also be YES for values created from floats.
*
* @return A BOOL indicating whether the value is a float.
*/
Expand Down Expand Up @@ -208,6 +211,18 @@ __attribute__((deprecated("This API is experimental.")))
+ (instancetype)valueWithDouble:(ExecuTorchDoubleValue)value
NS_SWIFT_NAME(init(_:));

/**
* Creates an instance encapsulating a float value.
*
* Note: The underlying value will be stored with a tag of
* ExecuTorchValueTagDouble, as there is no distinct float tag.
*
* @param value A float value.
* @return A new ExecuTorchValue instance with a tag of ExecuTorchValueTagDouble.
*/
+ (instancetype)valueWithFloat:(ExecuTorchFloatValue)value
NS_SWIFT_NAME(init(_:));

/**
* Creates an instance encapsulating a scalar value.
*
Expand Down
5 changes: 5 additions & 0 deletions extension/apple/ExecuTorch/Exported/ExecuTorchValue.mm
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ + (instancetype)valueWithDouble:(ExecuTorchDoubleValue)value {
value:@(value)];
}

+ (instancetype)valueWithFloat:(ExecuTorchFloatValue)value {
return [[ExecuTorchValue alloc] initWithTag:ExecuTorchValueTagDouble
value:@(value)];
}

+ (instancetype)valueWithScalar:(ExecuTorchScalarValue)value {
return [[ExecuTorchValue alloc] initWithTag:deduceValueTag(value)
value:value];
Expand Down
Loading