apache / mxnet

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more
https://mxnet.apache.org
Apache License 2.0
20.78k stars 6.79k forks source link

[Numpy] Numpy Interface does not support float16 #18398

Open sxjscience opened 4 years ago

sxjscience commented 4 years ago

Reproducible example:

import mxnet as mx
mx.npx.set_np()
net = mx.gluon.nn.Dense(16, in_units=32)
net.collect_params()
net.cast(mx.np.float16)
net.initialize()

Error:

~/mxnet/python/mxnet/numpy/random.py in uniform(low, high, size, dtype, ctx, out)
    135     inequality condition.
    136     """
--> 137     return _mx_nd_np.random.uniform(low, high, size=size, ctx=ctx, dtype=dtype, out=out)
    138 
    139 

~/mxnet/python/mxnet/ndarray/numpy/random.py in uniform(low, high, size, dtype, ctx, out)
    135     if size == ():
    136         size = None
--> 137     return _api_internal.uniform(low, high, size, ctx, dtype, out)
    138 
    139 

~/mxnet/python/mxnet/_ffi/_ctypes/function.py in __call__(self, *args)
    113                 self.handle, values, tcodes, ctypes.c_int(num_args),
    114                 ctypes.byref(ret_val), ctypes.byref(ret_tcode)) != 0:
--> 115             raise get_last_ffi_error()
    116         _ = temp_args
    117         _ = args

MXNetError: Traceback (most recent call last):
  File "../src/imperative/./imperative_utils.h", line 262
MXNetError: Check failed: outputs[i]->dtype() == out_types[i] (2 vs. 0) : 0-th output has invalid dtype. Expecting 0 got 2 in operator _npi_uniform
zheyuye commented 4 years ago

And the same error was thrown facing float64