MCPcopy Create free account
hub / github.com/openai/point-e / backward

Method backward

point_e/models/checkpoint.py:43–60  ·  view source on GitHub ↗
(ctx, *output_grads)

Source from the content-addressed store, hash-verified

41
42 @staticmethod
43 def backward(ctx, *output_grads):
44 ctx.input_tensors = [x.detach().requires_grad_(True) for x in ctx.input_tensors]
45 with torch.enable_grad():
46 # Fixes a bug where the first op in run_function modifies the
47 # Tensor storage in place, which is not allowed for detach()'d
48 # Tensors.
49 shallow_copies = [x.view_as(x) for x in ctx.input_tensors]
50 output_tensors = ctx.run_function(*shallow_copies)
51 input_grads = torch.autograd.grad(
52 output_tensors,
53 ctx.input_tensors + ctx.input_params,
54 output_grads,
55 allow_unused=True,
56 )
57 del ctx.input_tensors
58 del ctx.input_params
59 del output_tensors
60 return (None, None) + input_grads

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected