Skip to content

Instantly share code, notes, and snippets.

@rohan-varma
Created November 20, 2020 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohan-varma/19af18ebadb54a4deb4fbfa1e82dde01 to your computer and use it in GitHub Desktop.
Save rohan-varma/19af18ebadb54a4deb4fbfa1e82dde01 to your computer and use it in GitHub Desktop.
class MyModule(torch.jit.ScriptModule):
def __init__(self):
super().__init__()
@torch.jit.script_method
def method(self, x):
return x
def forward(self) -> Tensor:
res_tensor = torch.ones(2, 2)
return self.method(res_tensor)
@torch.jit.script
def construct_my_script_module() -> torch.jit.ScriptModule:
return MyModule()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment