}
id<MTLFunction> func = [_library newFunctionWithName:[NSString stringWithUTF8String:kernel.c_str()]];
TORCH_CHECK(func, "Failed to load the Metal Shader function: ", kernel);
- NSError* errors;
+ NSError* errors = nil;
state = [_device newComputePipelineStateWithFunction:func error:&errors];
TORCH_CHECK(state, errors.localizedDescription.UTF8String);
_pipelineCache[kernel] = state;
floatArgIndex++;
}
}
- NSError* errors;
+ NSError* errors = nil;
id<MTLFunction> func = [_library newFunctionWithName:[NSString stringWithUTF8String:kernel.c_str()]
constantValues:constantValues
error:&errors];
_modelPath = [self _save:modelSpecs
identifier:[NSString stringWithCString:identifier.c_str()
encoding:NSUTF8StringEncoding]];
- NSError* error;
+ NSError* error = nil;
NSURL* compiledModelPath = nil;
if (@available(iOS 11.0, macOS 10.13, *)) {
compiledModelPath =
- (id<MLFeatureProvider>)forwardWithInputs:
(const std::vector<PTMCoreMLFeatureSpecs>&)inputs {
- NSError* error;
+ NSError* error = nil;
PTMCoreMLFeatureProvider* inputFeature = [[PTMCoreMLFeatureProvider alloc]
initWithFeatureSpecs:inputs
CoreMLVersion:self.coreMLVersion];
if (inputFeature == nil) {
- NSLog(@"inputFeature is not initialized.");
return nil;
}
if (@available(iOS 11.0, macOS 10.13, *)) {
return outputFeature;
} else {
- TORCH_CHECK("Core ML is available on iOS 11.0 and above");
+ TORCH_CHECK(false, "Core ML is available on iOS 11.0 and above");
return nil;
}
}
- (BOOL)cleanup {
NSFileManager* fileManager = [NSFileManager defaultManager];
- NSError* error;
+ NSError* error = nil;
if (![fileManager fileExistsAtPath:_modelPath]) {
[fileManager removeItemAtPath:_modelPath error:&error];
}