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] The argument parser of some operators cannot parse numpy integers or mx.numpy integers correctly. #16855

Description

@sxjscience
import mxnet as mx
import numpy as np
mx.npx.set_np()
a = mx.np.ones((10, 10))
b = mx.np.split(a, np.int32(1))

Error:

ValueError: indices_or_sections must either int, or tuple / list / set of ints

The reason is that we are testing against the python int here:
https://github.com/apache/incubator-mxnet/blob/4f14bf4fe51b586f86a1e7bd38b8282997e6ffbb/python/mxnet/ndarray/numpy/_op.py#L2733

One way to solve the problem is to see if the indices_or_sections belongs to integer_types:
https://github.com/apache/incubator-mxnet/blob/4f14bf4fe51b586f86a1e7bd38b8282997e6ffbb/python/mxnet/base.py#L49

However, this will still be problematic, because the interger_types do not include the mxnet.numpy integers, i.e the following script will still raise the error:

import mxnet as mx
import numpy as np
mx.npx.set_np()
a = mx.np.ones((10, 10))
b = mx.np.split(a, mx.np.int32(1))

We will need some one to look at the problem @reminisce @haojin2 .

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions