Skip to content

Conversation

@yf225
Copy link
Contributor

@yf225 yf225 commented Nov 21, 2019

The original design of torch::nn::utils::clip_grad_norm_ / clip_grad_value_ takes input by non-const reference, which prevents users from passing rvalue reference as input into the functions. This PR changes the functions to take input by value, which 1. fixes the problem, 2. matches the Python version's semantics, 3. adheres to the C++ API convention that if a function modifies its input in-place, it should take that input by value.

@yf225 yf225 requested review from pbelevich and removed request for ebetica and goldsborough November 21, 2019 03:44
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yf225 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@yf225 yf225 added merged module: cpp Related to C++ API labels Nov 22, 2019
@facebook-github-bot facebook-github-bot deleted the cpp_fix_nn_utils_input_type branch July 13, 2020 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: cpp Related to C++ API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants