-
Notifications
You must be signed in to change notification settings - Fork 27.4k
autodiff for user script functions aka torch.jit.script for autograd.Function #22329
Copy link
Copy link
Closed
Labels
oncall: jitAdd this issue/PR to JIT oncall triage queueAdd this issue/PR to JIT oncall triage queuetriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
I got an error when use jit.script on some new layers(implemented in c++):
RuntimeError:
attribute lookup is not defined on python value of type 'FunctionMeta':
@torch.jit.script_method
def forward(self, x):
result = TopPoolFunction.apply(x)
~~~~~~~~~~~~~~~~~~~~~ <--- HERE
return result
here is my code:
class TopPoolFunction(Function):
@staticmethod
def forward(ctx, input):
output = top_pool.forward(input)[0]
ctx.save_for_backward(input)
return output
@staticmethod
def backward(ctx, grad_output):
input = ctx.saved_variables[0]
output = top_pool.backward(input, grad_output)[0]
return output
class TopPool(torch.jit.ScriptModule):
@torch.jit.script_method
def forward(self, x):
result = TopPoolFunction.apply(x)
return result
What is the proper way to use script on new layers, HELPPPP!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
oncall: jitAdd this issue/PR to JIT oncall triage queueAdd this issue/PR to JIT oncall triage queuetriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module