Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions shap_e/models/nn/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def checkpoint(

class CheckpointFunction(torch.autograd.Function):
@staticmethod
@custom_fwd
@custom_fwd(device_type='cuda')
def forward(ctx, run_function, length, *args):
ctx.run_function = run_function
ctx.length = length
Expand All @@ -40,7 +40,7 @@ def forward(ctx, run_function, length, *args):
return output_tensors

@staticmethod
@custom_bwd
@custom_bwd(device_type='cuda')
def backward(ctx, *output_grads):
inputs = ctx.saved_tensors
input_tensors = inputs[: ctx.length]
Expand All @@ -58,7 +58,7 @@ def backward(ctx, *output_grads):

class CheckpointFunctionGradFunction(torch.autograd.Function):
@staticmethod
@custom_fwd
@custom_fwd(device_type='cuda')
def forward(ctx, run_function, length_1, length_2, *args):
ctx.run_function = run_function
ctx.length_1 = length_1
Expand All @@ -83,7 +83,7 @@ def forward(ctx, run_function, length_1, length_2, *args):
return input_grads

@staticmethod
@custom_bwd
@custom_bwd(device_type='cuda')
def backward(ctx, *all_output_grads):
args = ctx.saved_tensors
input_tensors = [x.detach().requires_grad_(True) for x in args[: ctx.length_1]]
Expand Down