OliverColeman opened a new issue #17218: mxnet.ndarray.from_numpy() throws 
error for float16 dtype
URL: https://github.com/apache/incubator-mxnet/issues/17218
 
 
   ## Description
   When trying to convert a numpy array with dtype `float16` I get the error 
below. I looked through the code and it looks like it should be supported, but 
I've tried the latest production release (mxnet-cu101==1.5.1.post0) and the 
latest pre-release (mxnet-cu101==1.6.0b20191029) with no success.
   
   ### Error Message
   ```
   ValueError                                Traceback (most recent call last)
   <ipython-input-3-699ed656d29b> in <module>
         3 
         4 a = np.zeros((1, 1), dtype=np.float16)
   ----> 5 b = mx.ndarray.from_numpy(a)
   
   /opt/conda/lib/python3.7/site-packages/mxnet/ndarray/ndarray.py in 
from_numpy(ndarray, zero_copy)
      4268         raise ValueError("Only c-contiguous arrays are supported for 
zero-copy")
      4269     ndarray.flags['WRITEABLE'] = False
   -> 4270     c_obj = _make_dl_managed_tensor(ndarray)
      4271     handle = NDArrayHandle()
      4272     check_call(_LIB.MXNDArrayFromDLPackEx(ctypes.byref(c_obj), True, 
ctypes.byref(handle)))
   
   /opt/conda/lib/python3.7/site-packages/mxnet/ndarray/ndarray.py in 
_make_dl_managed_tensor(array)
      4257     def _make_dl_managed_tensor(array):
      4258         c_obj = DLManagedTensor()
   -> 4259         c_obj.dl_tensor = _make_dl_tensor(array)
      4260         c_obj.manager_ctx = _make_manager_ctx(array)
      4261         c_obj.deleter = dl_managed_tensor_deleter
   
   /opt/conda/lib/python3.7/site-packages/mxnet/ndarray/ndarray.py in 
_make_dl_tensor(array)
      4244     def _make_dl_tensor(array):
      4245         if str(array.dtype) not in DLDataType.TYPE_MAP:
   -> 4246             raise ValueError(str(array.dtype) + " is not supported.")
      4247         dl_tensor = DLTensor()
      4248         dl_tensor.data = array.ctypes.data_as(ctypes.c_void_p)
   
   ValueError: float16 is not supported.
   ```
   ## To Reproduce
   ```
   import numpy as np
   import mxnet as mx
   a = np.zeros((1, 1), dtype=np.float16)
   b = mx.ndarray.from_numpy(a)
   ```
   
   ## Environment
   ```
   ----------Python Info----------
   Version      : 3.7.4
   Compiler     : GCC 7.3.0
   Build        : ('default', 'Aug 13 2019 20:35:49')
   Arch         : ('64bit', '')
   ------------Pip Info-----------
   Version      : 19.2.3
   Directory    : /opt/conda/lib/python3.7/site-packages/pip
   ----------MXNet Info-----------
   Version      : 1.5.1
   Directory    : /opt/conda/lib/python3.7/site-packages/mxnet
   Num GPUs     : 2
   Commit Hash   : c9818480680f84daa6e281a974ab263691302ba8
   ----------System Info----------
   Platform     : Linux-4.15.0-55-generic-x86_64-with-debian-buster-sid
   system       : Linux
   node         : axl1
   release      : 4.15.0-55-generic
   version      : #60-Ubuntu SMP Tue Jul 2 18:22:20 UTC 2019
   ----------Hardware Info----------
   machine      : x86_64
   processor    : x86_64
   Architecture:        x86_64
   CPU op-mode(s):      32-bit, 64-bit
   Byte Order:          Little Endian
   CPU(s):              4
   On-line CPU(s) list: 0-3
   Thread(s) per core:  1
   Core(s) per socket:  4
   Socket(s):           1
   NUMA node(s):        1
   Vendor ID:           AuthenticAMD
   CPU family:          23
   Model:               17
   Model name:          AMD Ryzen 3 2200G with Radeon Vega Graphics
   Stepping:            0
   CPU MHz:             1439.174
   CPU max MHz:         3500.0000
   CPU min MHz:         1600.0000
   BogoMIPS:            6986.88
   Virtualization:      AMD-V
   L1d cache:           32K
   L1i cache:           64K
   L2 cache:            512K
   L3 cache:            4096K
   NUMA node0 CPU(s):   0-3
   Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge 
mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt 
pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid 
aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes 
xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a 
misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb 
bpext perfctr_llc mwaitx hw_pstate sme ssbd ibpb vmmcall fsgsbase bmi1 avx2 
smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 xsaves 
clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean 
flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif 
overflow_recov succor smca
   ----------Network Test----------
   Setting timeout: 10
   Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0203 
sec, LOAD: 0.6295 sec.
   Timing for GluonNLP GitHub: https://github.com/dmlc/gluon-nlp, DNS: 0.0064 
sec, LOAD: 0.5858 sec.
   Timing for GluonNLP: http://gluon-nlp.mxnet.io, DNS: 0.2835 sec, LOAD: 
1.0021 sec.
   Timing for D2L: http://d2l.ai, DNS: 0.3187 sec, LOAD: 0.2566 sec.
   Timing for D2L (zh-cn): http://zh.d2l.ai, DNS: 0.0743 sec, LOAD: 0.3067 sec.
   Timing for FashionMNIST: 
https://repo.mxnet.io/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, 
DNS: 0.2324 sec, LOAD: 0.7845 sec.
   Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.1998 sec, LOAD: 
1.2013 sec.
   Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0397 sec, 
LOAD: 0.3711 sec.
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to