(ctx, *output_grads)
| 370 | |
| 371 | @staticmethod |
| 372 | def backward(ctx, *output_grads): |
| 373 | ctx.input_tensors = [x.detach().requires_grad_(True) for x in ctx.input_tensors] |
| 374 | with torch.enable_grad(), \ |
| 375 | torch.cuda.amp.autocast(**ctx.gpu_autocast_kwargs): |
| 376 | # Fixes a bug where the first op in run_function modifies the |
| 377 | # Tensor storage in place, which is not allowed for detach()'d |
| 378 | # Tensors. |
| 379 | shallow_copies = [x.view_as(x) for x in ctx.input_tensors] |
| 380 | output_tensors = ctx.run_function(*shallow_copies) |
| 381 | input_grads = torch.autograd.grad( |
| 382 | output_tensors, |
| 383 | ctx.input_tensors + ctx.input_params, |
| 384 | output_grads, |
| 385 | allow_unused=True, |
| 386 | ) |
| 387 | del ctx.input_tensors |
| 388 | del ctx.input_params |
| 389 | del output_tensors |
| 390 | return (None, None) + input_grads |
nothing calls this directly
no outgoing calls
no test coverage detected