Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible NDArray Splicing Bug #383

Closed
gatordevin opened this issue Nov 27, 2020 · 2 comments · Fixed by #550
Closed

Possible NDArray Splicing Bug #383

gatordevin opened this issue Nov 27, 2020 · 2 comments · Fixed by #550
Labels
bug Something isn't working

Comments

@gatordevin
Copy link

Hey all. I may have encountered an issue with NDIndex splicing of NDArrays when using splice increments.

Exception in thread "main" ai.djl.engine.EngineException: MXNet engine call failed: MXNetError: Check failed: src.Size() == dst->Size() (3 vs. 2) : Cannot reshape array of size 3 into shape [1,2]

NDManager manager = NDManager.newBaseManager();
NDArray targetBox = manager.ones(new Shape(1, 5));
targetBox.set(new NDIndex(":, 0::2"), array -> array.mul(-1).add(1));

Code to reproduce the error is shown above. If one of the lines is changed to the following it works as expected with no issues. Splicing could be running too far off the array so the size is different but I am not sure.
targetBox.set(new NDIndex(":, 1::2"), array -> array.mul(-1).add(1));

@gatordevin gatordevin added the bug Something isn't working label Nov 27, 2020
@lanking520
Copy link
Contributor

Can you provide the corresponding numpy behavior if you would like to do something similar? @zachgk

@stu1130
Copy link
Contributor

stu1130 commented Dec 3, 2020

I can't find similar numpy function that do the same thing. The closest one is

a = np.ones((1,5))
a[:,0::2] *= -1
a[:,0::2] += 1

The error is from https://github.com/awslabs/djl/blob/ea501c9bdce9695c973beb32439bb90f135730ed/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/MxNDArrayIndexer.java#L75. @zachgk Could you take a look at set method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants