mxnet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] wkcn edited a comment on issue #14030: The bug in MXTVMBridge
Date Fri, 01 Feb 2019 00:05:51 GMT
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?
   It may be available 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:
     void SetRemoteCallPacked() {
       _RemoteCallPacked = [](const PackedFunc* func, TVMArgs args, TVMRetValue* rv) {
         func->body_(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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message