Pytorch C++ c10::Error

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

Unknown Exception

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:

 	KernelBase.dll!00007ffc0d563b29()	Unknown
 	vcruntime140d.dll!00007ffc018bb1f0()	Unknown
 	torch_cpu.dll!00007ffb9561c8fb()	Unknown
 	torch_cpu.dll!00007ffb955f1886()	Unknown
 	torch_cpu.dll!00007ffb955df815()	Unknown
 	torch_cpu.dll!00007ffb955de778()	Unknown
 	torch_cpu.dll!00007ffb95e8bb75()	Unknown
 	torch_cpu.dll!00007ffb95304f42()	Unknown
 	torch_cpu.dll!00007ffb95305067()	Unknown
 	torch_cpu.dll!00007ffb91bec6f2()	Unknown
 	torch_cpu.dll!00007ffb91beea6c()	Unknown
 	torch_cpu.dll!00007ffb91bec5c6()	Unknown
 	torch_cpu.dll!00007ffb91bf4b01()	Unknown
 	torch_cpu.dll!00007ffb91bae475()	Unknown
>	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++
 	kernel32.dll!00007ffc0fa07bd4()	Unknown
 	ntdll.dll!00007ffc1042ce51()	Unknown

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.