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

[Bug][Numpy] get_constant is not supported in numpy #16642

Closed
sxjscience opened this issue Oct 27, 2019 · 1 comment · Fixed by #16637
Closed

[Bug][Numpy] get_constant is not supported in numpy #16642

sxjscience opened this issue Oct 27, 2019 · 1 comment · Fixed by #16637

Comments

@sxjscience
Copy link
Member

sxjscience commented Oct 27, 2019

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.
@reminisce
Copy link
Contributor

Fixed in #16637.

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.

2 participants