I am currently trying to integrate PyTorch into my project on c++ side. I notice that It seems there is no complex type similarity of k (ex: kfloat…), but the pytorch implementation does have complex…
I am wondering if it is possible to initialize a complex type tensor/scalar/storage?
Thanks, I only want to get the Scalar, not Scalar to tensor. So basically just do this?
auto base = c10::Scalar(c10::complex<double>(1.0, 2.0));
Is this equivilent to the python code of:
base = 1.0 + 2.0j;
Since the default dtype for scalar is double not float.
Another question is that, when I try to print out the complex tensor using the std::cout method, the imaginary part didn’t get printed out.
Here is a simple example:
auto a = at::tensor({c10::complex<double>(1, 0.5), c10::complex<double>(1, 0.5)}, at::dtype(at::kComplexFloat));
std::cout << a << std::endl;
What I got:
[W Copy.cpp:219] Warning: Casting complex values to real discards the imaginary part (function operator())
1
1
So, how can I print out the value of a complex tensor including the imaginary part?
Much appreciated.