(ctx, *output_grads)
| 158 | |
| 159 | @staticmethod |
| 160 | def backward(ctx, *output_grads): |
| 161 | ctx.input_tensors = [x.detach().requires_grad_(True) for x in ctx.input_tensors] |
| 162 | with torch.enable_grad(), torch.cuda.amp.autocast(**ctx.gpu_autocast_kwargs): |
| 163 | # Fixes a bug where the first op in run_function modifies the |
| 164 | # Tensor storage in place, which is not allowed for detach()'d |
| 165 | # Tensors. |
| 166 | shallow_copies = [x.view_as(x) for x in ctx.input_tensors] |
| 167 | output_tensors = ctx.run_function(*shallow_copies) |
| 168 | input_grads = torch.autograd.grad( |
| 169 | output_tensors, |
| 170 | ctx.input_tensors + ctx.input_params, |
| 171 | output_grads, |
| 172 | allow_unused=True, |
| 173 | ) |
| 174 | del ctx.input_tensors |
| 175 | del ctx.input_params |
| 176 | del output_tensors |
| 177 | return (None, None) + input_grads |
| 178 | |
| 179 | |
| 180 | def timestep_embedding(timesteps, dim, max_period=10000, repeat_only=False, dtype=torch.float32): |
nothing calls this directly
no outgoing calls
no test coverage detected