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
331331- (nullable NSArray <ExecuTorchValue *> *)executeMethod : (NSString *)methodName
332332 withInputs : (NSArray <ExecuTorchValue *> *)values
333333 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 ;
338347 }
339- const auto result = _module->execute (methodName. UTF8String , inputs );
348+ const auto result = _module->execute (methodNameString );
340349 if (!result.ok ()) {
341350 if (error) {
342351 *error = ExecuTorchErrorWithCode ((ExecuTorchErrorCode)result.error ());
You can’t perform that action at this time.
0 commit comments