I am working on a custom model
MY_MODEL_CLASS (inhereting from Pytorch nn.module).
I can convert the model to TorchScript via:
torchscript_model = torch.jit.trace(torch_model, input)
However, there is some control flow that needs to be handled, so I want to use a
@torch.jit.script decorator for a method
MY_SCRIPT_DECORATED_CLASS_METHOD of this model. In this method, another class method
MY_MODEL_CLASS is called.
When I now try to convert the model with tracing plus the decorator, I get the following error:
‘Tensor (inferred)’ object has no attribute or method ‘USED_IN_SCRIPTED_CLASS_METHOD’.:
I see that the same thing happens for member variables of the model that are used in this scripted function. I am a bit lost in this case what causes this.
I am also not sure what
'Tensor (inferred)' refers to, since I was expecting this to rather see the name
Do you now what causes this?
How could I debug this?