Skip to content
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] Inconsistency between HybridBlock and Block #16279

Description

@sxjscience

There are lots of operators that have inconsistent behaviors between hybridized and not-hybridized versions.

import mxnet as mx
from mxnet.gluon import HybridBlock

class Foo2(HybridBlock):
    def hybrid_forward(self, F, a):
        return a[0]


b1 = Foo2(prefix='hybridized')
b1.hybridize()
b2 = Foo2(prefix='no_hybrid')

out1 = b1(mx.nd.ones((10,)))
out2 = b2(mx.nd.ones((10,)))
print(out1)
print(out2)
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
<NDArray 10 @cpu(0)>

[1.]
<NDArray 1 @cpu(0)>

Even if we use the numpy interface, the following code cannot run:

import mxnet as mx
from mxnet.gluon import HybridBlock
mx.npx.set_np()


class Foo2(HybridBlock):
    def hybrid_forward(self, F, a):
        return a[0]


b1 = Foo2(prefix='hybridized')
b1.hybridize()
b2 = Foo2(prefix='no_hybrid')

out1 = b1(mx.np.ones((10,)))
out2 = b2(mx.np.ones((10,)))
print(out1)
print(out2)
      6 class Foo2(HybridBlock):
      7     def hybrid_forward(self, F, a):
----> 8         return a[0]
      9 
     10 

~/mxnet/python/mxnet/symbol/numpy/_symbol.py in __getitem__(self, key)
     49         num_outputs = _num_outputs(self)
     50         if num_outputs == 1:
---> 51             raise NotImplementedError
     52         if not isinstance(key, int):
     53             raise NotImplementedError

NotImplementedError: 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions