diff --git a/extension/apple/ExecuTorch/Exported/ExecuTorchModule.mm b/extension/apple/ExecuTorch/Exported/ExecuTorchModule.mm index 7dda8898e25..12939c595f4 100644 --- a/extension/apple/ExecuTorch/Exported/ExecuTorchModule.mm +++ b/extension/apple/ExecuTorch/Exported/ExecuTorchModule.mm @@ -319,7 +319,7 @@ - (BOOL)isLoaded { - (BOOL)loadMethod:(NSString *)methodName error:(NSError **)error { - const auto errorCode = _module->load_method(methodName.UTF8String); + const auto errorCode = _module->load_method(methodName.UTF8String ?: ""); if (errorCode != Error::Ok) { if (error) { *error = ExecuTorchErrorWithCode((ExecuTorchErrorCode)errorCode); @@ -363,7 +363,7 @@ - (BOOL)loadMethod:(NSString *)methodName // passed through to program_->load_method and is not cached on the C++ // Module. ARC keeps `options` alive for the duration of this call via // the parameter, so no extra retention is needed here. - const auto errorCode = _module->load_method(methodName.UTF8String, + const auto errorCode = _module->load_method(methodName.UTF8String ?: "", /*planned_memory=*/nullptr, /*event_tracer=*/nullptr, [options cppMap]); @@ -377,11 +377,11 @@ - (BOOL)loadMethod:(NSString *)methodName } - (BOOL)isMethodLoaded:(NSString *)methodName { - return _module->is_method_loaded(methodName.UTF8String); + return _module->is_method_loaded(methodName.UTF8String ?: ""); } - (BOOL)unloadMethod:(NSString *)methodName { - const auto didUnload = _module->unload_method(methodName.UTF8String); + const auto didUnload = _module->unload_method(methodName.UTF8String ?: ""); [_inputs removeObjectForKey:methodName]; [_outputs removeObjectForKey:methodName]; return didUnload; @@ -404,7 +404,7 @@ - (BOOL)unloadMethod:(NSString *)methodName { - (nullable ExecuTorchMethodMetadata *)methodMetadata:(NSString *)methodName error:(NSError **)error { - const auto result = _module->method_meta(methodName.UTF8String); + const auto result = _module->method_meta(methodName.UTF8String ?: ""); if (!result.ok()) { if (error) { *error = ExecuTorchErrorWithCode((ExecuTorchErrorCode)result.error()); @@ -549,7 +549,7 @@ - (BOOL)setInput:(ExecuTorchValue *)value forMethod:(NSString *)methodName atIndex:(NSInteger)index error:(NSError **)error { - const auto errorCode = _module->set_input(methodName.UTF8String, toEValue(value), index); + const auto errorCode = _module->set_input(methodName.UTF8String ?: "", toEValue(value), index); if (errorCode != Error::Ok) { if (error) { *error = ExecuTorchErrorWithCode((ExecuTorchErrorCode)errorCode); @@ -589,7 +589,7 @@ - (BOOL)setInputs:(NSArray *)values for (ExecuTorchValue *value in values) { inputs.push_back(toEValue(value)); } - const auto errorCode = _module->set_inputs(methodName.UTF8String, inputs); + const auto errorCode = _module->set_inputs(methodName.UTF8String ?: "", inputs); if (errorCode != Error::Ok) { if (error) { *error = ExecuTorchErrorWithCode((ExecuTorchErrorCode)errorCode); @@ -632,7 +632,7 @@ - (BOOL)setOutput:(ExecuTorchValue *)value forMethod:(NSString *)methodName atIndex:(NSInteger)index error:(NSError **)error { - const auto errorCode = _module->set_output(methodName.UTF8String, toEValue(value), index); + const auto errorCode = _module->set_output(methodName.UTF8String ?: "", toEValue(value), index); if (errorCode != Error::Ok) { if (error) { *error = ExecuTorchErrorWithCode((ExecuTorchErrorCode)errorCode);