(ctx, *output_grads)
| 387 | |
| 388 | @staticmethod |
| 389 | def backward(ctx, *output_grads): |
| 390 | ctx.input_tensors = [x.detach().requires_grad_(True) for x in ctx.input_tensors] |
| 391 | with torch.enable_grad(), torch.cuda.amp.autocast(**ctx.gpu_autocast_kwargs): |
| 392 | # Fixes a bug where the first op in run_function modifies the |
| 393 | # Tensor storage in place, which is not allowed for detach()'d |
| 394 | # Tensors. |
| 395 | shallow_copies = [x.view_as(x) for x in ctx.input_tensors] |
| 396 | output_tensors = ctx.run_function(*shallow_copies) |
| 397 | input_grads = torch.autograd.grad( |
| 398 | output_tensors, |
| 399 | ctx.input_tensors + ctx.input_params, |
| 400 | output_grads, |
| 401 | allow_unused=True, |
| 402 | ) |
| 403 | del ctx.input_tensors |
| 404 | del ctx.input_params |
| 405 | del output_tensors |
| 406 | return (None, None) + input_grads |
nothing calls this directly
no outgoing calls
no test coverage detected