In principle, if all you need is dynamic shape, we could use trace and use symbolic input shape. But for now our PyTorch frontend doesn’t support dynamic input shape. See How to setting model compiled from pytorch with mutable input size
The problem with scripting is that we end up too many garbage like you saw, because all python constructs will appear as op. Things like aten::warn
, aten::format
, prim::RaiseException
etc.
Probably the best approach is this WIP PR WIP/RFC: initial stab at TorchScript fallback by t-vi · Pull Request #7401 · apache/tvm · GitHub