I am trying to build an executable using C++ and design a function having multi-dim tensor array value.
#include <iostream>
#include <torch/script.h>
int main() {
torch::Tensor tensor = torch::rand({1, 400, 400});
/* print out or return 'tensor' value somehow*/
return 0
}
And I would like to get the tensor value from Python side using the executable file.
Although there are some posts about retrieving stdout of executable in Python using subprocess (such as this example), I don't see approaches on how to get the numerically equal variable value of cpp function in Python using executable.
Even if I try to std::cout tensor value in cpp, the printed value is cutoff as below. So, it is not numerically equal with the original value in cpp.
...
2.5478e-01 2.9543e-01 9.1405e-01 7.1981e-01
6.6557e-01 1.6238e-01 3.8278e-01 4.9424e-01
5.1383e-01 1.6593e-01 8.5924e-01 3.8744e-01
9.9829e-01 4.2506e-02 1.2164e-01 8.0078e-03
4.3933e-02 9.7834e-01 9.4632e-01 5.5783e-01
6.2664e-01 6.1711e-02 1.9250e-01 9.3781e-01
8.9360e-01 8.6810e-01 2.5314e-01 8.9651e-01
1.2310e-01 6.8445e-02 8.3720e-01 5.6933e-01
[ CPUFloatType{1,400,400} ]
Can I get any advices on this issue? Thank you very much.