I overcome the error by placing at the top of the file a: #pragma optimize ("", off)
However, errors continue. Applying the Debug files of LibTorch and the DebuGame mode of Unreal Engine I realized that the error starts from loading of the model.
First, I ran the test by serializing a sample Libtorch model.
import torch
import torchvision

# An instance of your model.
model = torchvision.models.resnet18 ()

# An example input you would normally provide to your model's forward () method.
example = torch.rand (1, 3, 224, 224)

# Use torch.jit.trace to generate a torch.jit.ScriptModule via tracing.
traced_script_module = torch.jit.trace (model, example)

traced_script_module.save ("modelG.pt")

After, I load the model in the constructor of my application in unreal engine and I get an error with fopen.cpp when I try to load the model:
string name_model = "C:/Users/Jorge/PycharmProjects/CreateTestModels/modelG.pt";
torch::jit::script::Module module = torch::jit::load(name_model.c_str());


01FopenError1368×1062 117 KB

Please, could someone give me a suggestion on how to overcome this new runtime error?