forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JIT] Add
torch._C.ScriptList
` (pytorch#52832)
Summary: Pull Request resolved: pytorch#52832 **Summary** This commit adds `torch._C.ScriptList`, a list type that has reference semantics across the Python/TorchScript boundary. That is, modifications made in TorchScript to instances of `torch._C.ScriptList` are visible in Python even when it is not returned from the function. `torch._C.ScriptList` is implemented using a modified version of pybind's `stl_bind.h`-style bindings attached to `ScriptList` and `ScriptListIterator`, wrapper classes around `c10::impl::GenericList` and `c10::impl::GenericList::iterator`. These bindings allow instances of `torch._C.ScriptList` to be used as if it were a regular `list` in Python. Reference semantics are achieved by simply retrieving the `IValue` contained in `ScriptList` in `toIValue` (invoked when converting Python arguments to `IValues` before calling TorchScript code). **Test Plan** This commit adds `TestScriptList` to `test_list_dict.py`, a set of tests that check that all of the common list operations are supported and that instances have reference semantics across the Python/TorchScript boundary. Test Plan: Imported from OSS Reviewed By: gmagogsfm Differential Revision: D29478121 Pulled By: SplitInfinity fbshipit-source-id: 652cc25cfa37debe28db9527504846f22abd8b54
- Loading branch information
1 parent
6e9e30c
commit 4a2e8b5
Showing
10 changed files
with
941 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.