Open igolan opened 5 years ago
Was this ever resolved or was a work around ever found?
You can consider trying https://github.com/apache/incubator-mxnet/tree/83797400128d41910d87e957131f29fd466f4777/example/extensions/lib_custom_op instead of the Python-level custom operator. But I'm not sure if it has been tested with conditional operator yet.
Heres the full stack trace from the given example on v1.8 MX:
#0 0x00007fffdee8748d in std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > mxnet::op::custom::List<(CustomOpPropCallbacks)1>(nnvm::NodeAttrs const&) () from /home/ubuntu/18_fixes/python/mxnet/../../lib/libmxnet.so
#1 0x00007fffdee77bd8 in mxnet::op::custom::AttrParser(nnvm::NodeAttrs*) ()
from /home/ubuntu/18_fixes/python/mxnet/../../lib/libmxnet.so
#2 0x00007fffe54d8a32 in nnvm::Symbol::CreateFunctor(nnvm::Op const*, std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >) ()
from /home/ubuntu/18_fixes/python/mxnet/../../lib/libmxnet.so
#3 0x00007fffe3c492d1 in MXSymbolCreateAtomicSymbol () from /home/ubuntu/18_fixes/python/mxnet/../../lib/libmxnet.so
#4 0x00007ffff6607ec0 in ffi_call_unix64 () from /home/ubuntu/anaconda3/lib/python3.6/lib-dynload/../../libffi.so.6
#5 0x00007ffff660787d in ffi_call () from /home/ubuntu/anaconda3/lib/python3.6/lib-dynload/../../libffi.so.6
#6 0x00007ffff681cdae in _ctypes_callproc ()
from /home/ubuntu/anaconda3/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so
#7 0x00007ffff681d7e5 in PyCFuncPtr_call ()
Its failing in the MXNet Python Custom Op, but on the C++ side here: https://github.com/apache/incubator-mxnet/blob/v1.x/src/operator/custom/custom.cc#L106 after it calls back into Python here: https://github.com/apache/incubator-mxnet/blob/v1.x/python/mxnet/operator.py#L733
Simple fix seems to be adding **kwargs
to the IdentityOPProp
constructor like:
@mx.operator.register("identityop")
class IdentityOPProp(mx.operator.CustomOpProp):
def __init__(self, **kwargs):
super(IdentityOPProp, self).__init__(True)
print('IdentityOPProp: %s' % kwargs)
Now it works and prints:
IdentityOPProp: {'__subgraph_name__': 'cond_else0'}
[[3.]]
<NDArray 1x1 @cpu(0)>
[[3.]]
<NDArray 1x1 @cpu(0)>
So the question is, how/why is __subgraph_name__
getting added to this op's attributes?
That does look like the issue we're having. I'll try that workaround. Thanks!
Description
symbol.contrib.cond
operator does not support custom operator execution.Environment info (Required)
I'm using Pyton
Build info (Required if built from source)
N/A
Error Message:
Minimum reproducible example
Steps to reproduce
Run code above
What have you tried to solve it?
I suspect it has something to do with custom operators being executed imperatively (?) Might be related to #12154 , #11641 and #16182 .
*I'm not sure that the custom operator implementation is not missing something, I attached an example with simple identity custom operator (which doesn't work).