File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
extension/apple/ExecuTorch/Exported Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -331,12 +331,21 @@ - (nullable ExecuTorchMethodMetadata *)methodMetadata:(NSString *)methodName
331
331
- (nullable NSArray <ExecuTorchValue *> *)executeMethod : (NSString *)methodName
332
332
withInputs : (NSArray <ExecuTorchValue *> *)values
333
333
error : (NSError **)error {
334
- std::vector<EValue> inputs;
335
- inputs.reserve (values.count );
336
- for (ExecuTorchValue *value in values) {
337
- inputs.push_back (toEValue (value));
334
+ const char *methodNameString = methodName.UTF8String ;
335
+ __block auto errorCode = Error::Ok;
336
+ [values enumerateObjectsUsingBlock: ^(ExecuTorchValue *value, NSUInteger index, BOOL *stop) {
337
+ errorCode = _module->set_input (methodNameString, toEValue (value), index);
338
+ if (errorCode != Error::Ok) {
339
+ *stop = YES ;
340
+ }
341
+ }];
342
+ if (errorCode != Error::Ok) {
343
+ if (error) {
344
+ *error = ExecuTorchErrorWithCode ((ExecuTorchErrorCode)errorCode);
345
+ }
346
+ return nil ;
338
347
}
339
- const auto result = _module->execute (methodName. UTF8String , inputs );
348
+ const auto result = _module->execute (methodNameString );
340
349
if (!result.ok ()) {
341
350
if (error) {
342
351
*error = ExecuTorchErrorWithCode ((ExecuTorchErrorCode)result.error ());
You can’t perform that action at this time.
0 commit comments