You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
Hello everyone,
I am trying to use sparse tensors to save memory in my Transformer architecture and I'm applying F.sparse.cast_storage on an attention weights tensor.
As you can see the sparseNDArray is densified on the fly to produce output (because value is not sparse). Then, I return a dense output and a sparse attn_weights.
Output will be finally used to compute the loss, and attn_weights for plotting if necessary.
The error occurs when I'm updating the loss metric which is calling asnumpy internally.
Traceback (most recent call last):
File "/home/wallart/workspaces/Transformer/trainer/transformer_trainer.py", line 77, in train
self._loss_metric.update(0, [l * self._opts.batch_size for l in losses])
File "/opt/miniconda3/envs/intelpython3/lib/python3.6/site-packages/mxnet-1.6.0-py3.6.egg/mxnet/metric.py", line 1687, in update
loss = ndarray.sum(pred).asscalar()
File "/opt/miniconda3/envs/intelpython3/lib/python3.6/site-packages/mxnet-1.6.0-py3.6.egg/mxnet/ndarray/ndarray.py", line 2553, in asscalar
return self.asnumpy()[0]
File "/opt/miniconda3/envs/intelpython3/lib/python3.6/site-packages/mxnet-1.6.0-py3.6.egg/mxnet/ndarray/ndarray.py", line 2535, in asnumpy
ctypes.c_size_t(data.size)))
File "/opt/miniconda3/envs/intelpython3/lib/python3.6/site-packages/mxnet-1.6.0-py3.6.egg/mxnet/base.py", line 255, in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [10:01:05] src/operator/tensor/././cast_storage-inl.cuh:470: Check failed: dns.shape_.ndim() == 2 (4 vs. 2)
The issue occurs both on MXNet 1.5.1 and 1.6.0.rc0.
Everything works if I disable the F.sparse.cast_storage call
EDIT : F.sparse.cast_storage(attn_weights * sparse_attn, 'csr').asnumpy() produces the same error. Seems that CSR Sparse api only support 2D data (my tensor is 4D). I will switch to row_sparse format.
Is it planned in the future ? Or at least have an argument to sparsity last two axis of a tensor
EDIT2 : Can someone change the label to feature request ? I can't do it.
The text was updated successfully, but these errors were encountered:
Hello everyone,
I am trying to use sparse tensors to save memory in my Transformer architecture and I'm applying F.sparse.cast_storage on an attention weights tensor.
As you can see the sparseNDArray is densified on the fly to produce output (because value is not sparse). Then, I return a dense output and a sparse attn_weights.
Output will be finally used to compute the loss, and attn_weights for plotting if necessary.
The error occurs when I'm updating the loss metric which is calling asnumpy internally.
The issue occurs both on MXNet 1.5.1 and 1.6.0.rc0.
Everything works if I disable the F.sparse.cast_storage call
EDIT : F.sparse.cast_storage(attn_weights * sparse_attn, 'csr').asnumpy() produces the same error. Seems that CSR Sparse api only support 2D data (my tensor is 4D). I will switch to row_sparse format.
Is it planned in the future ? Or at least have an argument to sparsity last two axis of a tensor
EDIT2 : Can someone change the label to feature request ? I can't do it.
The text was updated successfully, but these errors were encountered: