Fatal error on dot operation between dense and sparse vectors
The following code
import mxnet as mx
from mxnet import ndarray as nd
a=nd.zeros((1,10),stype='csr')
b=nd.zeros(10,)
nd.dot(a,b)
fails with
15:00:49] /Users/travis/build/dmlc/mxnet-distro/mxnet-build/dmlc-core/include/dmlc/logging.h:308: [15:00:49] src/operator/tensor/./dot-inl.h:842: Check failed: inputs[1].shape().ndim() == 2 (1 vs. 2) sparse dot only supports 2 dimensional rhs
Stack trace returned 10 entries:
[bt] (0) 0 libmxnet.so 0x00000001096dc8d8 _ZN4dmlc15LogMessageFatalD2Ev + 40
[bt] (1) 1 libmxnet.so 0x0000000109959843 _ZN5mxnet2op12DotForwardExIN7mshadow3cpuEEEvRKN4nnvm9NodeAttrsERKNS_9OpContextERKNSt3__16vectorINS_7NDArrayENSB_9allocatorISD_EEEERKNSC_INS_9OpReqTypeENSE_ISJ_EEEESI_ + 2499
[bt] (2) 2 libmxnet.so 0x000000010a5b1d71 _ZZN5mxnet10imperative14PushFComputeExERKNSt3__18functionIFvRKN4nnvm9NodeAttrsERKNS_9OpContextERKNS1_6vectorINS_7NDArrayENS1_9allocatorISB_EEEERKNSA_INS_9OpReqTypeENSC_ISH_EEEESG_EEEPKNS3_2OpES6_RKNS_7ContextERKNSA_IPNS_6engine3VarENSC_ISY_EEEES12_RKNSA_INS_8ResourceENSC_IS13_EEEERKNSA_IPSB_NSC_IS18_EEEES1C_SL_ENKUlNS_10RunContextENSW_18CallbackOnCompleteEE_clES1D_S1E_ + 241
[bt] (3) 3 libmxnet.so 0x000000010a5b2427 _ZNSt3__110__function6__funcIZN5mxnet10imperative14PushFComputeExERKNS_8functionIFvRKN4nnvm9NodeAttrsERKNS2_9OpContextERKNS_6vectorINS2_7NDArrayENS_9allocatorISD_EEEERKNSC_INS2_9OpReqTypeENSE_ISJ_EEEESI_EEEPKNS5_2OpES8_RKNS2_7ContextERKNSC_IPNS2_6engine3VarENSE_IS10_EEEES14_RKNSC_INS2_8ResourceENSE_IS15_EEEERKNSC_IPSD_NSE_IS1A_EEEES1E_SN_EUlNS2_10RunContextENSY_18CallbackOnCompleteEE_NSE_IS1H_EEFvS1F_S1G_EEclEOS1F_OS1G_ + 55
[bt] (4) 4 libmxnet.so 0x000000010a54f532 _ZN5mxnet6engine14ThreadedEngine15ExecuteOprBlockENS_10RunContextEPNS0_8OprBlockE + 386
[bt] (5) 5 libmxnet.so 0x000000010a5526d1 _ZNSt3__110__function6__funcIZZN5mxnet6engine23ThreadedEnginePerDevice13PushToExecuteEPNS3_8OprBlockEbENKUlvE_clEvEUlvE_NS_9allocatorIS8_EEFvvEEclEv + 65
[bt] (6) 6 libmxnet.so 0x000000010a54fc28 _ZNSt3__114__thread_proxyINS_5tupleIJNS_8functionIFvvEEEEEEEEPvS6_ + 104
[bt] (7) 7 libsystem_pthread.dylib 0x00007fffc057293b _pthread_body + 180
[bt] (8) 8 libsystem_pthread.dylib 0x00007fffc0572887 _pthread_body + 0
[bt] (9) 9 libsystem_pthread.dylib 0x00007fffc057208d thread_start + 13
and kills python vm
dot is matrix dot operator. The shape should be (m, n) of lhs and (n, k) of rhs. I think this check inputs[1].shape().ndim() == 2 (1 vs. 2) makes sense.
You can replace b=nd.zeros(10,) with b=nd.zeros((10, 1))
@ZiyueHuang The following code works
>>> from mxnet import ndarray as nd
>>> a=nd.zeros(10)
>>> b=nd.zeros(10)
>>> nd.dot(a,b)
[ 0.]
<NDArray 1 @cpu(0)>
>>> a.shape
(10,)
>>> b.shape
(10,)
There is not consistent behavior between sparse and dense vectors.
OK, I see.
@ZiyueHuang Anyway, the dot operation causes the python VM to crash.
Proposed Labels : "Bug", "Sparse", "Breaking"
@sandeep-krishnamurthy @marfago this is fixed by the Exception handling change. Can this be closed ?