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.

[Numpy] Bug of basic indexing #16887

Description

@sxjscience

Found this bug when writing random test cases for symbolic indexing.

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

a = mx.np.random.normal(0, 1, (5, 5, 5, 5))
b = mx.np.random.normal(0, 1, (5, 5, 5, 5))
index1 = (slice(3, 0, -1), slice(1, 0, -1), slice(2, 0, -1), slice(3, 0, -1))
index2 = (slice(2, 3, 2), slice(0, 1, 2), slice(1, 2, 2), slice(1, 3, 2))

class Foo(gluon.HybridBlock):
    def hybrid_forward(self, F, x, y):
        return (x[()][index1] + y[()][index1])[index2]

net = Foo()
with mx.autograd.record():
    out = net(a, b)

Error:

MXNetError: [07:04:22] src/ndarray/ndarray.cc:263: Check failed: shape_.Size() == shape.Size() (2 vs. 1) : NDArray.Reshape: target shape must have the same size as current shape when recording with autograd.
Stack trace:
  [bt] (0) /home/ubuntu/mxnet/python/mxnet/../../lib/libmxnet.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x32) [0x7f1da2489c42]
  [bt] (1) /home/ubuntu/mxnet/python/mxnet/../../lib/libmxnet.so(mxnet::NDArray::ReshapeWithRecord(mxnet::TShape const&)+0x187) [0x7f1da59d4877]
  [bt] (2) /home/ubuntu/mxnet/python/mxnet/../../lib/libmxnet.so(MXNDArrayReshape64+0xa7) [0x7f1da612f2e7]
  [bt] (3) /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(ffi_call_unix64+0x4c) [0x7f1e6fc14e20]
  [bt] (4) /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(ffi_call+0x2eb) [0x7f1e6fc1488b]
  [bt] (5) /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(_ctypes_callproc+0x49a) [0x7f1e6fc0f01a]
  [bt] (6) /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so(+0x9fcb) [0x7f1e6fc02fcb]
  [bt] (7) /usr/bin/python3(PyObject_Call+0x47) [0x5c3bd7]
  [bt] (8) /usr/bin/python3(PyEval_EvalFrameEx+0x4f2f) [0x5354af]

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions