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 2019/11/08 19:21:30 UTC

[GitHub] [incubator-tvm] tqchen edited a comment on issue #4280: [tvm][runtime] A minimum runtime for external library

tqchen edited a comment on issue #4280: [tvm][runtime] A minimum runtime for external library
URL: https://github.com/apache/incubator-tvm/pull/4280#issuecomment-551957000
 
 
   To followup on the discussion thread. While we understand that the current PR achieves the purpose of supporting external library by a different kind of wrapping, it does brings additional code that has duplicated functionality with DSOModule.
   
   Unless there is a strong reason to do so, I think we should not introduce the new Extern runtime. Instead, let us document the DSOModule's calling convention clearly and rewrite compilers to generate functions that can be loaded by the DSO module. That is, instead of generating a function with the extern calling convention, generate a function that takes the following signature
   
   ```c++
   // the original foo you intended to generate
   void foo_(float* a, int N, float* b, int M, float* c) {
      bar(...);
      foobar(...);
   }
   
   // DSOModule compatible c function that can be compiled by gcc.
   extern "C" int foo(TVMValue* value, int *type_code, int nargs) {
      CHECK_EQ(nargs, 2);
      DLTensor* arg0 = static_cast<DLTensor*>(value.v_handle);
      DLTensor* arg1 = static_cast<DLTensor*>(value.v_handle);
   
      foo_(static_cast<float*>(args0->data), args0->shape[0],
              static_cast<float*>(args1->data), args1->shape[0]));
   }
   ```
   
   The main rationale behind the suggestion is that we want to avoid code specializations and reduce future technical debts. As we can see the current PR introduces special changes to several locations to support the new mode. Which increases the cost of maintaining the separate loading mechanism.
   
   
   

----------------------------------------------------------------
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


With regards,
Apache Git Services