Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

nd.sparse.clip operation return type is different from the input #12787

Closed
ssbusc1 opened this issue Oct 11, 2018 · 1 comment · Fixed by #14856
Closed

nd.sparse.clip operation return type is different from the input #12787

ssbusc1 opened this issue Oct 11, 2018 · 1 comment · Fixed by #14856

Comments

@ssbusc1
Copy link

ssbusc1 commented Oct 11, 2018

As per the documentation at https://mxnet.incubator.apache.org/api/python/ndarray/sparse.html#mxnet.ndarray.sparse.clip, the nd.sparse.clip operation should return a CSR for a CSR input. But it is returning a RowSparseNDArray. This seems like a bug, as clipping may only be one of multiple steps in processing the sparse input, and the change in type adds friction.

Test case:

a = nd.ones((2, 3)) * 2
a.asnumpy()
array([[ 2., 2., 2.],
           [ 2., 2., 2.]], dtype=float32)
b = a.tostype(‘csr’)
b
<CSRNDArray 2x3 @cpu(0)>
 
b.asnumpy()
array([[ 2., 2., 2.],
            [ 2., 2., 2.]], dtype=float32)

nd.sparse.clip(b, 0, 1)
<RowSparseNDArray 2x3 @cpu(0)>

Diagnostics:

----------Python Info----------
('Version      :', '2.7.12')
('Compiler     :', 'GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)')
('Build        :', ('default', 'Jun 29 2016 14:05:02'))
('Arch         :', ('64bit', ''))
------------Pip Info-----------
('Version      :', '18.1')
('Directory    :', '/usr/local/lib/python2.7/site-packages/pip')
----------MXNet Info-----------
('Version      :', '1.3.0')
('Directory    :', '/usr/local/lib/python2.7/site-packages/mxnet')
('Commit Hash   :', 'b3be92f4a48bce62a5a8424271871c2f81c8f7f1')
----------System Info----------
('Platform     :', 'Darwin-15.6.0-x86_64-i386-64bit')
('system       :', 'Darwin')
('node         :', '<redacted>')
('release      :', '15.6.0')
('version      :', 'Darwin Kernel Version 15.6.0: Thu Jun 21 20:07:40 PDT 2018; root:xnu-3248.73.11~1/RELEASE_X86_64')
----------Hardware Info----------
('machine      :', 'x86_64')
('processor    :', 'i386')
machdep.cpu.brand_string: Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C
machdep.cpu.leaf7_features: SMEP ERMS RDWRFSGS TSC_THREAD_OFFSET BMI1 AVX2 BMI2 INVPCID FPU_CSDS
machdep.cpu.extfeatures: SYSCALL XD 1GBPAGE EM64T LAHF LZCNT RDTSCP TSCI
----------Network Test----------
Setting timeout: 10
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0122 sec, LOAD: 1.0105 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0220 sec, LOAD: 0.7401 sec.
Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0586 sec, LOAD: 0.5175 sec.
Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0217 sec, LOAD: 0.4796 sec.
Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.0927 sec, LOAD: 0.6083 sec.
Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.0297 sec, LOAD: 0.6817 sec.
@piyushghai
Copy link
Contributor

@ssbusc1 Thanks for filing this issue! We will look into this.
@mxnet-label-bot [Bug, Sparse]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants