Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine error checks in onnxruntime/core/providers/coreml/model/model.mm. #18620

Merged
merged 1 commit into from
Nov 29, 2023
Merged
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
8 changes: 4 additions & 4 deletions onnxruntime/core/providers/coreml/model/model.mm
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Status CreateInputFeatureProvider(const std::unordered_map<std::string, OnnxTens
deallocator:^(void* /* bytes */) {
}
error:&error];
ORT_RETURN_IF(multi_array == nil,
ORT_RETURN_IF(error != nil || multi_array == nil,
"Failed to create MLMultiArray for feature: ", name,
(error != nil) ? MakeString(", error: ", [[error localizedDescription] UTF8String]) : "");

Expand All @@ -170,7 +170,7 @@ Status CreateInputFeatureProvider(const std::unordered_map<std::string, OnnxTens

auto* feature_provider = [[MLDictionaryFeatureProvider alloc] initWithDictionary:feature_dictionary
error:&error];
ORT_RETURN_IF(feature_provider == nil,
ORT_RETURN_IF(error != nil || feature_provider == nil,
"Failed to create MLDictionaryFeatureProvider",
(error != nil) ? MakeString(", error: ", [[error localizedDescription] UTF8String]) : "");

Expand Down Expand Up @@ -303,12 +303,12 @@ - (void)dealloc {
}

- (Status)loadModel {
NSError* error = nil;
NSURL* modelUrl = [NSURL URLWithString:coreml_model_path_];
if (modelUrl == nil) {
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Failed to create model URL from path");
}

NSError* error = nil;
NSURL* compileUrl = [MLModel compileModelAtURL:modelUrl error:&error];

if (error != nil) {
Expand All @@ -324,7 +324,7 @@ - (Status)loadModel {
: MLComputeUnitsAll;
_model = [MLModel modelWithContentsOfURL:compileUrl configuration:config error:&error];

if (_model == nil) {
if (error != nil || _model == nil) {
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Failed to create MLModel",
(error != nil) ? MakeString(", error: ", [[error localizedDescription] UTF8String]) : "");
}
Expand Down
Loading