Skip to content

Commit f873ada

Browse files
Handle more Value types in Module. (#9699)
Summary: #8363 Reviewed By: bsoyluoglu Differential Revision: D71936820 Co-authored-by: Anthony Shoumikhin <[email protected]>
1 parent 9cfaeac commit f873ada

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

extension/apple/ExecuTorch/Exported/ExecuTorchModule.mm

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ static inline EValue toEValue(ExecuTorchValue *value) {
2424
ET_CHECK(nativeTensor);
2525
return *nativeTensor;
2626
}
27+
if (value.isDouble) {
28+
return EValue(value.doubleValue);
29+
}
30+
if (value.isInteger) {
31+
return EValue(static_cast<int64_t>(value.intValue));
32+
}
33+
if (value.isBoolean) {
34+
return EValue(value.boolValue);
35+
}
2736
ET_CHECK_MSG(false, "Unsupported ExecuTorchValue type");
2837
return EValue();
2938
}
@@ -33,6 +42,22 @@ static inline EValue toEValue(ExecuTorchValue *value) {
3342
auto nativeInstance = make_tensor_ptr(value.toTensor());
3443
return [ExecuTorchValue valueWithTensor:[[ExecuTorchTensor alloc] initWithNativeInstance:&nativeInstance]];
3544
}
45+
if (value.isDouble()) {
46+
return [ExecuTorchValue valueWithDouble:value.toDouble()];
47+
}
48+
if (value.isInt()) {
49+
return [ExecuTorchValue valueWithInteger:value.toInt()];
50+
}
51+
if (value.isBool()) {
52+
return [ExecuTorchValue valueWithBoolean:value.toBool()];
53+
}
54+
if (value.isString()) {
55+
const auto stringView = value.toString();
56+
NSString *string = [[NSString alloc] initWithBytes:stringView.data()
57+
length:stringView.size()
58+
encoding:NSUTF8StringEncoding];
59+
return [ExecuTorchValue valueWithString:string];
60+
}
3661
ET_CHECK_MSG(false, "Unsupported EValue type");
3762
return [ExecuTorchValue new];
3863
}

0 commit comments

Comments
 (0)