You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/07/03 06:37:08 UTC

[GitHub] [incubator-tvm] kazum opened a new pull request #5989: [BYOC][COREML] Handle one symbol for each runtime

kazum opened a new pull request #5989:
URL: https://github.com/apache/incubator-tvm/pull/5989


   It's no longer necessary to handle multiple subgraphs in one runtime thanks to the change of #5770, which simplifies the CoreML runtime a bit.
   
   @zhiics @mbaret @FrozenGene Please help this to review.
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-tvm] kazum commented on a change in pull request #5989: [BYOC][COREML] Handle one symbol for each runtime

Posted by GitBox <gi...@apache.org>.
kazum commented on a change in pull request #5989:
URL: https://github.com/apache/incubator-tvm/pull/5989#discussion_r454246121



##########
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:
       Yes, will do it in the next 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:
users@infra.apache.org



[GitHub] [incubator-tvm] zhiics commented on pull request #5989: [BYOC][COREML] Handle one symbol for each runtime

Posted by GitBox <gi...@apache.org>.
zhiics commented on pull request #5989:
URL: https://github.com/apache/incubator-tvm/pull/5989#issuecomment-658260820


   Thanks @kazum 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [incubator-tvm] zhiics commented on a change in pull request #5989: [BYOC][COREML] Handle one symbol for each runtime

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org



[GitHub] [incubator-tvm] zhiics merged pull request #5989: [BYOC][COREML] Handle one symbol for each runtime

Posted by GitBox <gi...@apache.org>.
zhiics merged pull request #5989:
URL: https://github.com/apache/incubator-tvm/pull/5989


   


----------------------------------------------------------------
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:
users@infra.apache.org