diff --git a/extension/apple/ExecuTorch/Exported/ExecuTorchValue.h b/extension/apple/ExecuTorch/Exported/ExecuTorchValue.h index 2fd50e1b34f..7ef30588ed8 100644 --- a/extension/apple/ExecuTorch/Exported/ExecuTorchValue.h +++ b/extension/apple/ExecuTorch/Exported/ExecuTorchValue.h @@ -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. */ @@ -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. * diff --git a/extension/apple/ExecuTorch/Exported/ExecuTorchValue.mm b/extension/apple/ExecuTorch/Exported/ExecuTorchValue.mm index 2c4dacc891f..dd4eed7157e 100644 --- a/extension/apple/ExecuTorch/Exported/ExecuTorchValue.mm +++ b/extension/apple/ExecuTorch/Exported/ExecuTorchValue.mm @@ -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];