So I have been trying to rebuild the MNIST example from the Pytorch C++ Frontend tutorial.
However, I get a c10::Error at the following line:
torch::Tensor d_loss_real = torch::binary_cross_entropy(real_output, real_labels);
real_output and real_labels are simply tensor, and neither of them is null.
This is how the error code reads:
Unhandled exception at 0x00007FF873E03B29 in MNIST_Example.exe: Microsoft C++ exception: c10::Error at memory location 0x0000000E2C35CED0.
Weirdly enough, I cannot even step into the function using the debugger (Yes I enabled it, it works on other functions). Wrapping the whole thing in a try catch and printing exception.what() simply gets me
Some more infos:
- Windows 10 using Visual Studio
- Llibtorch debug version without GPU Support (also I do not have a GPU if that is relevant)
- .dll files are in the same folder as .exe
- build system is CMake
Any tipps would be greatly appreciated.
If this helps, I provide the call stack as shown by Visual studio:
> MNIST_Example.exe!main() Line 165 C++
MNIST_Example.exe!invoke_main() Line 79 C++
MNIST_Example.exe!__scrt_common_main_seh() Line 288 C++
MNIST_Example.exe!__scrt_common_main() Line 331 C++
MNIST_Example.exe!mainCRTStartup() Line 17 C++
The line 165 is the one where binary_cross_entropy is called.
I have added the .pdb in order to debug torch_cpu.dll and I found that it is looking for a File called “Functions.cpp”. I found that file on Github here:
But I do not know why the file is not included in my libtorch files and whether it is smart to simply throw it in there manually?
Weirdly enough, according to the pytorch docs, the Functions.h header, where this function is declared, is not actually included by any File called Functions.cpp.