Support Kwargs in C++ Function/Method calls#19086
Closed
zdevito wants to merge 15 commits into
Closed
Conversation
Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp
Support Kwargs in C++ Function/Method calls Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp gh-metadata: pytorch pytorch 19086 gh/zdevito/13/head
Support Kwargs in C++ Function/Method calls Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp gh-metadata: pytorch pytorch 19086 gh/zdevito/13/head
Support Kwargs in C++ Function/Method calls Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp gh-metadata: pytorch pytorch 19086 gh/zdevito/13/head
Support Kwargs in C++ Function/Method calls Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp gh-metadata: pytorch pytorch 19086 gh/zdevito/13/head
Support Kwargs in C++ Function/Method calls Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp gh-metadata: pytorch pytorch 19086 gh/zdevito/13/head
ZolotukhinM
approved these changes
Apr 10, 2019
| void FunctionSchema::findErrorInKwargs(const std::vector<std::string>& kwargs) const { | ||
| // First check if any of the kwargs are unknown, i.e. don't match the name of | ||
| // any argument in the schema. | ||
| for (const auto& kwarg : kwargs) { |
There was a problem hiding this comment.
Why not std::find like in the loop below? Also, I wonder if it's worth putting both arguments and kwargs into an unordered_set.
Contributor
Author
There was a problem hiding this comment.
it needs to be a lambda variant because it is matching argument.name against kwarg. Not sure why it was count_if rather than find_if, I moved it from another file...
There was a problem hiding this comment.
Let's keep it as-is since it's just a move then. We can consider cleaning it up later.
| } | ||
| } | ||
|
|
||
| void FunctionSchema::checkAndNormalizeInputs(std::vector<IValue>& inputs, const std::unordered_map<std::string, IValue> & kwargs) const { |
Support Kwargs in C++ Function/Method calls Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp gh-metadata: pytorch pytorch 19086 gh/zdevito/13/head
Support Kwargs in C++ Function/Method calls Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp gh-metadata: pytorch pytorch 19086 gh/zdevito/13/head
Support Kwargs in C++ Function/Method calls Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp gh-metadata: pytorch pytorch 19086 gh/zdevito/13/head
This was referenced Apr 11, 2019
Support Kwargs in C++ Function/Method calls Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp gh-metadata: pytorch pytorch 19086 gh/zdevito/13/head
Support Kwargs in C++ Function/Method calls Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp gh-metadata: pytorch pytorch 19086 gh/zdevito/13/head
Support Kwargs in C++ Function/Method calls Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp gh-metadata: pytorch pytorch 19086 gh/zdevito/13/head
Support Kwargs in C++ Function/Method calls Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp gh-metadata: pytorch pytorch 19086 gh/zdevito/13/head
Support Kwargs in C++ Function/Method calls Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp gh-metadata: pytorch pytorch 19086 gh/zdevito/13/head
Support Kwargs in C++ Function/Method calls Summary: Adds a Kwargs optional argument to the operator() for Method and Function. Refactors logic from the python support for kwargs so that it can be shared Test Plan: test_jit.py TestJit.test_cpp gh-metadata: pytorch pytorch 19086 gh/zdevito/13/head
Contributor
zdevito
added a commit
to zdevito/ATen
that referenced
this pull request
Apr 13, 2019
Summary: Pull Request resolved: pytorch/pytorch#19086 ghimport-source-id: 7790a5cc6e32f6f72e92add0b9f76dfa49ad9859 Reviewed By: jamesr66a Differential Revision: D14875729 Pulled By: zdevito fbshipit-source-id: ad1e4542381d9c33722155459e794f1ba4660dbb
zhangguanheng66
pushed a commit
to zhangguanheng66/pytorch
that referenced
this pull request
May 6, 2019
Summary: Pull Request resolved: pytorch#19086 ghimport-source-id: 7790a5c Reviewed By: jamesr66a Differential Revision: D14875729 Pulled By: zdevito fbshipit-source-id: ad1e4542381d9c33722155459e794f1ba4660dbb
laurentdupin
pushed a commit
to laurentdupin/pytorch
that referenced
this pull request
Apr 24, 2026
Summary: Pull Request resolved: pytorch#19086 ghimport-source-id: 7790a5c Reviewed By: jamesr66a Differential Revision: D14875729 Pulled By: zdevito fbshipit-source-id: ad1e4542381d9c33722155459e794f1ba4660dbb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack:
Summary: Adds a Kwargs optional argument to the operator() for Method
and Function. Refactors logic from the python support for kwargs so
that it can be shared
Test Plan: test_jit.py TestJit.test_cpp
Differential Revision: D14875729