I’m new to Pytorch and it C++ API. I followed the this tutorial 1 in order to learn how to load and process a .pt file in C++.
Unfortunately, while the code is built correctly, and loads the pt file without errors, when I try to execute something from the saved module, it raises the following error:

terminate called after throwing an instance of 'std::runtime_error'
  what():  The following operation failed in the TorchScript interpreter.
Traceback of TorchScript, serialized code (most recent call last):
  File "code/__torch__.py", line 11, in forward
    if bool(torch.gt(torch.sum(input), 0)):
      weight = self.weight
      output = torch.mv(weight, input)
               ~~~~~~~~ <--- HERE
    else:
      weight0 = self.weight

Traceback of TorchScript, original code (most recent call last):
  File "torchScript.py", line 10, in forward
    def forward(self, input):
        if input.sum() > 0:
            output = self.weight.mv(input)
                     ~~~~~~~~~~~~~~ <--- HERE
        else:
            output = self.weight + input
RuntimeError: vector + matrix @ vector expected, got 1, 2, 4

Aborted (core dumped)

How can I fix it ?
Thank you in advance