question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not use torch.jit.script to export model

See original GitHub issue

torch.jit.frontend.NotSupportedError: Compiled functions can’t take variable number of arguments or use keyword-only arguments with defaults: at /usr/local/lib/python3.7/dist-packages/torch/autograd/function.py:26:25 def mark_dirty(self, *args): ~~~~~ <— HERE r"""Marks given tensors as modified in an in-place operation.

    **This should be called at most once, only from inside the**
    :func:`forward` **method, and all arguments should be inputs.**

    Every tensor that's been modified in-place in a call to :func:`forward`
    should be given to this function, to ensure correctness of our checks.
    It doesn't matter whether the function is called before or after
    modification.

‘SwishImplementation’ is being compiled since it was called from ‘torch.efficientnet_pytorch.utils.MemoryEfficientSwish.forward’

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

4reactions
burnmyletterscommented, Apr 17, 2020

It seems, that you need to make model.set_swish(False) before exporting the model.

1reaction
Vozfcommented, Mar 10, 2021

But what is jit.script is needed? For instance for jit.trace after quantization isn’t working

Read more comments on GitHub >

github_iconTop Results From Across the Web

TorchScript — PyTorch 1.13 documentation
This makes it possible to train models in PyTorch using familiar tools in Python and then export the model via TorchScript to a...
Read more >
Export to TorchScript - Hugging Face
TorchScript does not allow you to export models that have tied weights, so it is necessary to untie and clone the weights beforehand....
Read more >
Using TorchScript to serialize and deploy model
Models in TorchANI's model zoo support TorchScript. TorchScript is a way to create serializable and optimizable models from PyTorch code. It allows users...
Read more >
Google Universal Image Embedding | Kaggle
I have a pre-trained model that uses efficientnet as backbone, and I cant export it with torch.jit.script issue, but torch.jit.trace worked. So I...
Read more >
How to convert your PyTorch model to TorchScript | djl
This works best when your model doesn't have control flow. If you do have control ... In DJL, we use tracing to create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found