From 61d88cdd1c5fe7cf91b6ee0a71a250e3a6f61878 Mon Sep 17 00:00:00 2001 From: Michael Dagitses Date: Thu, 26 Aug 2021 04:42:36 -0700 Subject: [PATCH] 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 --- tools/autograd/gen_autograd_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/autograd/gen_autograd_functions.py b/tools/autograd/gen_autograd_functions.py index 7d852ad..08136ab 100644 --- a/tools/autograd/gen_autograd_functions.py +++ b/tools/autograd/gen_autograd_functions.py @@ -479,7 +479,7 @@ def process_function(info: DifferentiabilityInfo, template: CodeTemplate) -> str body: List[str] = [] if uses_single_grad(info): - body.append('auto& grad = grads[0];') + body.append('const auto& grad = grads[0];') def emit_derivative( derivative: Derivative, -- 2.7.4