From: Pieter Noordhuis Date: Fri, 29 Mar 2019 23:15:10 +0000 (-0700) Subject: Update argument names of torch::autograd::FunctionPostHook (#18140) X-Git-Tag: accepted/tizen/6.5/unified/20211028.231830~544 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=47e27723203e40074571fa58343dd7cfe3e88ab6;p=platform%2Fupstream%2Fpytorch.git Update argument names of torch::autograd::FunctionPostHook (#18140) Summary: They are called as (outputs, inputs) and were named (inputs, outputs). Possible follow up fix is to make the outputs argument an lvalue to allow for calling multiple post hooks without ever copying outputs vector. It looks like the copy is now forced because the hook takes a const reference as input and returns an value. This would change the prototype of the function, so needs further discussion. Pull Request resolved: https://github.com/pytorch/pytorch/pull/18140 Differential Revision: D14684498 Pulled By: pietern fbshipit-source-id: 1bd3ddbdd1ff7fe0a18241de5a9ec745a4e7ef07 --- diff --git a/torch/csrc/autograd/function_hook.h b/torch/csrc/autograd/function_hook.h index f3cf5b2..33970c1 100644 --- a/torch/csrc/autograd/function_hook.h +++ b/torch/csrc/autograd/function_hook.h @@ -16,7 +16,9 @@ struct FunctionPreHook { struct FunctionPostHook { virtual ~FunctionPostHook() = default; - virtual variable_list operator()(const variable_list& grad_input, const variable_list& grad_output) = 0; + virtual variable_list operator()( + const variable_list& outputs /* grad_inputs */, + const variable_list& inputs /* grad_outputs */) = 0; }; }} // namespace torch::autograd