Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions extension/apple/ExecuTorch/Exported/ExecuTorchModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ - (instancetype)initWithFilePath:(NSString *)filePath
std::vector<std::string> dataFilePathsVector;
if (dataFilePaths != nil) {
for (NSString *dataFile in dataFilePaths) {
dataFilePathsVector.emplace_back(dataFile.UTF8String);
dataFilePathsVector.emplace_back(dataFile.UTF8String ?: "");
}
}
_module = std::make_unique<Module>(
filePath.UTF8String,
filePath.UTF8String ?: "",
dataFilePathsVector,
static_cast<Module::LoadMode>(loadMode)
);
Expand Down Expand Up @@ -314,7 +314,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);
Expand All @@ -325,11 +325,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;
Expand All @@ -352,7 +352,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());
Expand All @@ -366,7 +366,7 @@ - (nullable ExecuTorchMethodMetadata *)methodMetadata:(NSString *)methodName
- (nullable NSArray<ExecuTorchValue *> *)executeMethod:(NSString *)methodName
withInputs:(NSArray<ExecuTorchValue *> *)values
error:(NSError **)error {
const char *methodNameString = methodName.UTF8String;
const char *methodNameString = methodName.UTF8String ?: "";
__block auto errorCode = Error::Ok;
[values enumerateObjectsUsingBlock:^(ExecuTorchValue *value, NSUInteger index, BOOL *stop) {
errorCode = _module->set_input(methodNameString, toEValue(value), index);
Expand Down Expand Up @@ -497,7 +497,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);
Expand Down Expand Up @@ -537,7 +537,7 @@ - (BOOL)setInputs:(NSArray<ExecuTorchValue *> *)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);
Expand Down Expand Up @@ -580,7 +580,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);
Expand Down
Loading