Hi, this is is because there is no single “graph”, there are two separate graphs, one for each overload. I could maybe add an api for something like model.forwards.graphs, or model.forward.graph_for_types(1) to get the graph for a specific overload.
Generally, overloads should be usable and work as you expect when they are contained in other modules but you may run into a little bit of difficulty if you are interacting with them as a top level module. They’re still an internal feature but will be cleaned up and released probably in the next release or the one after.
Since default type is torch.Tensor, the corresponding graph is obtained. So is there any ways to obtain one single torchscript for all overloads for now?
The MyModule you’re using only takes a Tensor. If you want to access the int graph you could try using a different module with the submodule that takes in an int.
Sorry to dredge this one up but I had exactly the same problem, I was hoping I could ask @eellison how this works exactly?
Generally, overloads should be usable and work as you expect when they are contained in other modules
I get the idea: Once you call forward, then the torchscript can inspect types and choose the right graph? But is it possible to get a reference for some documentation to fully understand how this works (or to the code that does this)? I don’t quite understand why forward is treated differently - when this error occurs I can still call the other functions which have been overloaded.
Hi @Padarn_Wilson, the reason there aren’t good docs for this is because it wasn’t fully finished. there are still a few rough edges as you are encountering.
I don’t quite understand why forward is treated differently - when this error occurs I can still call the other functions which have been overloaded.
Hmm, what do you mean exactly ? Not sure I follow.
From the discussion above I understood that when .forward is invoked it will also do the job of inferring which overloaded functions to call based on the types present… but rereading it I realise I had my understanding a bit confused. I think it is clear now.