zhiics commented on a change in pull request #5989:
URL: https://github.com/apache/incubator-tvm/pull/5989#discussion_r449651385
##########
File path: src/runtime/contrib/coreml/coreml_runtime.mm
##########
@@ -199,29 +183,25 @@
}
}
-Module CoreMLRuntimeCreate(const std::string& model_dir) {
+Module CoreMLRuntimeCreate(const std::string& symbol, const std::string&
model_path) {
auto exec = make_object<CoreMLRuntime>();
- exec->Init(model_dir);
+ exec->Init(symbol, model_path);
return Module(exec);
}
TVM_REGISTER_GLOBAL("tvm.coreml_runtime.create").set_body([](TVMArgs args,
TVMRetValue* rv) {
- *rv = CoreMLRuntimeCreate(args[0]);
+ *rv = CoreMLRuntimeCreate(args[0], args[1]);
});
void CoreMLRuntime::SaveToBinary(dmlc::Stream* stream) {
- stream->Write((uint32_t)model_map_.size());
- for (const auto& kv : model_map_) {
- const std::string& model_name = kv.first;
- NSURL* url = kv.second->url_;
- NSFileWrapper* dirWrapper = [[[NSFileWrapper alloc] initWithURL:url
options:0
- error:nil]
autorelease];
- NSData* dirData = [dirWrapper serializedRepresentation];
- stream->Write(model_name);
- stream->Write((uint64_t)[dirData length]);
- stream->Write([dirData bytes], [dirData length]);
- LOG(INFO) << "Save " << model_name << " (" << [dirData length] << "
bytes)";
- }
+ NSURL* url = model_->url_;
+ NSFileWrapper* dirWrapper = [[[NSFileWrapper alloc] initWithURL:url options:0
+ error:nil]
autorelease];
+ NSData* dirData = [dirWrapper serializedRepresentation];
+ stream->Write(symbol_);
+ stream->Write((uint64_t)[dirData length]);
+ stream->Write([dirData bytes], [dirData length]);
+ LOG(INFO) << "Save " << symbol_ << " (" << [dirData length] << " bytes)";
Review comment:
change to DLOG?
##########
File path: src/runtime/contrib/coreml/coreml_runtime.mm
##########
@@ -174,17 +158,17 @@
CHECK(args[i].type_code() == kTVMDLTensorHandle || args[i].type_code()
== kTVMNDArrayHandle)
<< "Expect NDArray or DLTensor as inputs\n";
if (args[i].type_code() == kTVMDLTensorHandle) {
- model.SetInput([input_names[i] UTF8String], args[i]);
+ model_->SetInput([input_names[i] UTF8String], args[i]);
} else {
LOG(FATAL) << "Not implemented";
}
}
// Execute the subgraph.
- model.Invoke();
+ model_->Invoke();
// TODO: Support multiple outputs.
- NDArray out = model.GetOutput(0);
+ NDArray out = model_->GetOutput(0);
if (args[args.size() - 1].type_code() == kTVMDLTensorHandle) {
DLTensor* arg = args[args.size() - 1];
out.CopyTo(arg);
Review comment:
Are the ndarrays allocated by the host for both inputs and outputs? If
so, I think we might be able to do zero copy (in a separate PR).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]