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?
   ```c++
   
   class PackedFunc {
    public:
     using FType = std::function<void(TVMArgs args, TVMRetValue* rv)>;
     PackedFunc() {
       RemoteCallPacked = [](const PackedFunc* func, TVMArgs args, TVMRetValue* 
rv) {
         func->CallPacked(args, rv);
       };
     };
     void (*RemoteCallPacked)(const PackedFunc* func, TVMArgs args, 
TVMRetValue* rv);
     explicit PackedFunc(FType body) : body_(body) {}
     inline void CallPacked(TVMArgs args, TVMRetValue* rv) const {
       body_(args, rv);
     }
     static void CallPacked(PackedFunc *func, TVMArgs args, TVMRetValue* rv) {
       func->CallPacked(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:
     FType body_;
   };
   ...
   };
   ```
   The outside program calls `RemoteCallPacked` to avoid the problem of ABI 
compatibility.

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