Will torch.jit.unused support normal object class?

BobChen: <p>It seems that torch.jit.unused does not support normal object class. Is there any plans to support it? For now, the following codes will cause an error: <strong>'torch.jit.frontend.UnsupportedNodeError: with statements aren’t supported:'</strong></p>
<pre><code class="lang-auto">@torch.jit.script
class MyObject(object):
    def __init__(self):
        super().__init__()

    @torch.jit.unused
    def unsupported(self):
        with torch.no_grad():
            print('This is not supported by jit.')

    def supported(self, x):
        print('This is supported by jit.')
</code></pre>
<p>By the way, could anyone give some advices to handle this situation where classes with torchscript-unsupported attributes are used during torchscript inference process.</p>

driazati: <p>Right now everything that is in a <code>@torch.jit.script</code>ed class has to be TorchScript compatible, but we’re working on fixing it so <code>@ignore</code> and <code>@unused</code> work as they should. The best way around it for now is probably to use free-standing functions (which you can <code>@ignore</code>) that take the object as the first argument</p>

BobChen: <aside class="quote no-group" data-username="driazati" data-post="2" data-topic="76323" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/driazati/48/15393_2.png" class="avatar"> driazati:</div>
<blockquote>
<p>Right now everything that is in a <code>@torch.jit.script</code> ed class has to be TorchScript compatible, but we’re working on fixing it so <code>@ignore</code> and <code>@unused</code> work as they should. The best way around it for now is probably to use free-standing functions (which you can <code>@ignore</code> ) that take the object as the first argument</p>
</blockquote>
</aside>
<p>Got it, thank you very much:)</p>

Rick: <p><a class="mention" href="/u/driazati">@driazati</a> Thanks for the answer. Is there an issue where we can track the progress of the Python Object class <span class="mention">@ignore</span> and <span class="mention">@unused</span> support?</p>

Rick: <p>This feature will be released in TensorFlow 1.7. The pull request can be found <a href="https://github.com/pytorch/pytorch/pull/38522" rel="noopener nofollow ugc">here</a>.</p>

ptrblck: <aside class="quote no-group" data-username="Rick" data-post="5" data-topic="76323">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/rick/48/28307_2.png" class="avatar"> Rick:</div>
<blockquote>
<p>This feature will be released in TensorFlow 1.7.</p>
</blockquote>
</aside>
<p>I thought TF1.7 was already released in 2018 <img src="https://discuss.pytorch.org/images/emoji/apple/wink.png?v=12" title=":wink:" class="emoji" alt=":wink:" loading="lazy" width="20" height="20"></p>

Rick: <p><a class="mention" href="/u/ptrblck">@ptrblck</a> Haha <img src="https://discuss.pytorch.org/images/emoji/apple/rofl.png?v=9" title=":rofl:" class="emoji" alt=":rofl:">, typo, pytorch 1.7 ofcourse <img src="https://discuss.pytorch.org/images/emoji/apple/grin.png?v=9" title=":grin:" class="emoji" alt=":grin:">.</p>