This repository was archived by the owner on Nov 17, 2023. It is now read-only.
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
[Bug][Numpy] get_constant is not supported in numpy #16642
Closed
Description
Description
import mxnet as mx
import numpy as np
from mxnet.gluon import HybridBlock
mx.npx.set_np()
class Foo(HybridBlock):
def __init__(self, prefix=None, params=None):
super(Foo, self).__init__(prefix=prefix, params=params)
self.weight = self.params.get_constant('const', np.ones((10, 10)))
def hybrid_forward(self, F, x, weight):
return x, weight.astype(np.float32)
foo = Foo()
foo.hybridize()
foo.initialize()
Error Message
TypeError: Operator `_copyto` registered in backend is known as `_copyto` in Python. This is a legacy operator which can only write to legacy ndarrays, while received an MXNet numpy ndarray. Please call `as_nd_ndarray()` upon the numpy ndarray to convert it to a legacy ndarray, and then feed the converted array to this operator.