-
Notifications
You must be signed in to change notification settings - Fork 6.8k
The problem of ABI compatibility in MXTVMBridge #14030
Comments
Hey, this is the MXNet Label Bot. |
In pip we use symbol whitelist https://github.com/apache/incubator-mxnet/blob/master/make/config/libmxnet.ver. Is any required function missing from this list? @tqchen |
Because the bridge uses c++ std::function, it requires a common ABI between the two in order to make things work, so build from source is indeed the best way |
@mxnet-label-bot add [question] |
@tqchen 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_;
...
}; |
The problem is related to TVM, so I open an issue in TVM project. |
Description
Hi, there.
I would like to use
MXTVMBridge
to accelerate my project, but there is a flaky problem.The example works when MXNet is built from source by myself, but it doesn't work when MXNet is installed by PIP.
Environment info (Required)
Package used (Python/R/Scala/Julia):
Python
Build info (Required if built from source)
Compiler (gcc/clang/mingw/visual studio): gcc
MXNet commit hash:
e37ff53
Build config:
make -j 5 USE_OPENCV=0 USE_BLAS=openblas
Minimum reproducible example
https://github.com/wkcn/test_tvm_bridge
In this example, tvm_packed_func.h is simplyfied from TVM.
Steps to reproduce
What have you tried to solve it?
In the function
SetMXTVMBridge
of the reproducible example,args.num_args
is wrong andargs.values[0].v_str
is sometimes wrong when MXNet is installed by pip, namelypip install mxnet --pre
.However, the result is correct when MXNet is built by myself,
make -j 5 USE_OPENCV=1 USE_BLAS=openblas
in the latest MXNet source.In the PR #9880, merrymercy met a similar problem. #9880 (comment)
It seems the temporary variable
TVMArgs {"WrapAsyncCall", PackedFunc(mxnet::WrapAsyncCall)}
is released before callingfregister
in the functionMXTVMBridge
because of optimization of compiler.Thanks!
The text was updated successfully, but these errors were encountered: