use const auto& as type for grad alias (#63949)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/63949

This is an extension of the discussion in
https://github.com/pytorch/pytorch/pull/63040#discussion_r687793027.

Test Plan: Imported from OSS

Reviewed By: albanD

Differential Revision: D30546789

Pulled By: dagitses

fbshipit-source-id: 3046aff4f129d5492d73dfb67717a824e16ffee8
This commit is contained in:
Michael Dagitses 2021-08-26 04:42:36 -07:00 committed by Facebook GitHub Bot
parent 5757d03145
commit 61d88cdd1c

View File

@ -479,7 +479,7 @@ def process_function(info: DifferentiabilityInfo, template: CodeTemplate) -> str
body: List[str] = [] body: List[str] = []
if uses_single_grad(info): if uses_single_grad(info):
body.append('auto& grad = grads[0];') body.append('const auto& grad = grads[0];')
def emit_derivative( def emit_derivative(
derivative: Derivative, derivative: Derivative,