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: 'torch.jit.frontend.UnsupportedNodeError: with statements aren’t supported:'
@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.')
By the way, could anyone give some advices to handle this situation where classes with torchscript-unsupported attributes are used during torchscript inference process.
Right now everything that is in a @torch.jit.scripted class has to be TorchScript compatible, but we’re working on fixing it so @ignore and @unused work as they should. The best way around it for now is probably to use free-standing functions (which you can @ignore) that take the object as the first argument