pytorch torch.jit.trace returns function instead of torch.jit.ScriptModule
I need to run in c++ a pre-trained pytorch nn model (trained in python) to make predictions.

To do so, I'm following the instructions on how to load a pytorch model in c++ given here: https://pytorch.org/tutorials/advanced/cpp_export.html

But when I try to get the torch.jit.ScriptModule via tracing as stated in the first step of the tutorial:

    traced_script_module =
        torch.jit.trace(model, (input_tensor_1, input_tensor_2))


Instead of returning a torch.jit.ScriptModule, it returns a function:

    print(type(traced_script_module))
    &lt;type 'function'&gt;


Which, when I run:

    traced_script_module.save("model.pt")


then leads into the following error:

Traceback (most recent call last):
  File "serialize_model.py", line 60, in &lt;module&gt;
    traced_script_module.save("model.pt")
AttributeError: 'function' object has no attribute 'save'


Any ideas on what I'm doing wrong?

Thanks for asking Jatentaki. I was using PyTorch 0.4 in Python and when I updated to 1.0 it worked.
