wkcn edited a comment on issue #14030: The bug in MXTVMBridge
URL: 
https://github.com/apache/incubator-mxnet/issues/14030#issuecomment-459551740
 
 
   @tqchen 
   Is it possible to provide an API like this to avoid the problem of ABI 
compatibility.
   
   ```c++
   class PackedFunc {
    public:
     using FType = std::function<void(TVMArgs args, TVMRetValue* rv)>;
     PackedFunc() {
       SetRemoteCallPacked();
     };
     explicit PackedFunc(FType body) : body_(body) {
       SetRemoteCallPacked();
     }
     void CallPacked(TVMArgs args, TVMRetValue* rv) const {
       _RemoteCallPacked(this, args, rv);
     }
     template <typename... Args>
     inline TVMRetValue operator()(Args&&... args) const {
       const int kNumArgs = sizeof...(Args);
       const int kArraySize = kNumArgs > 0 ? kNumArgs : 1;
       TVMValue values[kArraySize];
       int type_codes[kArraySize];
       detail::for_each(TVMArgsSetter(values, type_codes),
                        std::forward<Args>(args)...);
       TVMRetValue rv;
       _RemoteCallPacked(this, TVMArgs(values, type_codes, kNumArgs), &rv);
       return rv;
     }
    private:
     inline void _CallPacked(TVMArgs args, TVMRetValue* rv) const {
       body_(args, rv);
     }
     void SetRemoteCallPacked() {
       _RemoteCallPacked = [](const PackedFunc* func, TVMArgs args, 
TVMRetValue* rv) {
         func->_CallPacked(args, rv);
       };
     }
     void (*_RemoteCallPacked)(const PackedFunc* func, TVMArgs args, 
TVMRetValue* rv);
    private:
     FType body_;
   ...
   };
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to