Perform reshape of tensor in JAVA.pytorch

Hi, I have python code
and converting the code to android, and I have question of some commands of pythons.

First, my python code is unsqueeze(x.0) where x is pytorch.tensor.
e.g) when unsqueeze(x,0) is performed, shape of x will be [3,2,4] to [1,3,2,4] <-- add just 1 dimension

  1. in JAVA, can I do it how…?? (java command is so unusual for me… please help)

  2. Also, I want to reorder the pytorch.tensor in JAVA
    e.g) [3,2,4] to [2,4,3]
    in python it is performed by torch.from_numpy(x).permute(2, 0, 1)
    In JAVA, how to can I do it? (JAVA command is fine to me… I found some java function code or package that support reshape in python where the input is array… in pytorch.java… what is the type of tensor? it is array?)

thank you.

hi @SungmanHong Bro, did you found any workaround for the above task. I am also stuck on the above?

You can find Jave API Doc in this page (bottom): https://github.com/pytorch/pytorch/tree/master/android
I just paste it here: pytorch_android 1.9.0 API

Java API is mainly for model inference and there’s no such tensor operation API in Java. You may manipulate the raw data before constructing the tensor, or put these operations into a model.