Cryptic error message from torch.jit.save

Hi All,

I am transforming a tts model into torchscript model. I was able to execute torch.jit.script(tts_model) call successfully without any errors. However, when I call torch.jit.save afterwards, I encounter a runtime error:

    712 See :func:`torch.jit.save <torch.jit.save>` for details.
    713 """
    714 print(f"got here {self.original_name}, {str(f)}, {kwargs}")
--> 715 return self._c.save(str(f), **kwargs)

RuntimeError: Tensors of type UndefinedTensorImpl do not have strides

I am not sure how to interpret this error message correctly and figuring out where in my code may lead to this error. Any one can give me some clues? The model is big, I haven’t got a minimal example to reproduce this error yet.
hmmm, perhaps my partial quantization of the model may have something to do with this.

Do you have a minimal, executable code snippet which would reproduce the error in the latest release, and could post it here, please?

I have found the issue in one of the modules. It turned out that it has a forward method like
def forward(self, x, mask=None)
The default value for the mask input triggered the runtime error. Replacing the method signature with
def forward(self, x, mask: Optional[torch.Tensor]=None) resolves the issue.

torch.jit.script didn’t seem to be able to pick out this issue.