From: Michael Dagitses Date: Thu, 26 Aug 2021 11:42:36 +0000 (-0700) Subject: use `const auto&` as type for grad alias (#63949) X-Git-Tag: accepted/tizen/8.0/unified/20231005.095509~699 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=61d88cdd1c5fe7cf91b6ee0a71a250e3a6f61878;p=platform%2Fupstream%2Fpytorch.git 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 --- 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,