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

Scala/Java reshape problem #14590

Closed
lanking520 opened this issue Apr 2, 2019 · 4 comments
Closed

Scala/Java reshape problem #14590

lanking520 opened this issue Apr 2, 2019 · 4 comments
Labels
Bug Java Label to identify Java API component Operator Scala

Comments

@lanking520
Copy link
Member

lanking520 commented Apr 2, 2019

Currently I am facing an issue with Scala/Java. If tried to do the following reshape method, the function will fail:

package mxnet;

import org.apache.mxnet.javaapi.Context;
import org.apache.mxnet.javaapi.NDArray;
import org.apache.mxnet.javaapi.NDArray$;

public class Test {
    private static NDArray$ NDArray = NDArray$.MODULE$;
    public static void main(String[] args) {
        NDArray nd = NDArray.ones(Context.cpu(), new int[] {1, 384, 1});
        nd.reshape(new int[]{0, -3});
    }
}

Error:

Exception in thread "main" org.apache.mxnet.MXNetError: [20:03:16] src/ndarray/ndarray.cc:224: Check failed: shape_.Size() >= shape.Size() (384 vs. 18446744073709551613) NDArray.Reshape: target shape size is larger current shape

On the backend, this is being called:

_LIB.mxNDArrayReshape(handle, dims.length, dims, reshapeHandle)

However, Python seemed to be fine:

test = mx.nd.ones((1, 384, 1))
print(test.reshape((0, -3)))

I think this might be some bugs in the operator side.

@lanking520 lanking520 added Bug Scala Operator Java Label to identify Java API component labels Apr 2, 2019
@mxnet-label-bot
Copy link
Contributor

Hey, this is the MXNet Label Bot.
Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it.
Here are my recommended labels: Scala, Bug

@lanking520
Copy link
Member Author

Here is the corresponding Python method.

This method is being called:

_LIB.MXNDArrayReshape64(self.handle, len(shape), c_array(ctypes.c_int64, shape), reverse, ctypes.byref(handle)))

@lanking520
Copy link
Member Author

lanking520 commented Apr 2, 2019

Thanks @stu1130 finding, the Actual PR is here where Python made the switch:

#10360
#10767

Will raise a PR to update the corresponding Scala code

@lanking520
Copy link
Member Author

Close this one since the problem solved

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Java Label to identify Java API component Operator Scala
Projects
None yet
Development

No branches or pull requests

2 participants