-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcoreml2hwx.m
34 lines (26 loc) · 1 KB
/
coreml2hwx.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#import <Foundation/Foundation.h>
#import "coreml_util.h"
int main(int argc, char* argv[]) {
char* coreml_model_file;
const char* mobilenet = "/tmp/MobileNet.mlmodel";
if (argc < 2) {
coreml_model_file = (char*)mobilenet;
} else {
coreml_model_file = argv[1];
}
NSURL* testURL = [NSURL fileURLWithPath:[NSString stringWithUTF8String:coreml_model_file]];
NSLog(@"original mlmodel file: %@ ", [testURL absoluteURL]);
NSString* baseModelName = [[[NSString stringWithUTF8String:coreml_model_file] lastPathComponent]
stringByDeletingPathExtension];
NSURL* compiledURL = [MLModel compileModelAtURL:testURL error:nil];
NSString* espressonet = [[compiledURL path] stringByAppendingString:@"/model.espresso.net"];
NSLog(@"espresso model in mlmodelc directory: %@ ", espressonet);
int ret = mlmodelc_to_espresso_ir(espressonet);
if (ret)
exit(ret);
if (argc > 2)
ret = espresso_ir_hwx(baseModelName, true);
else
ret = espresso_ir_hwx(baseModelName, false);
return ret;
}