pytorch/test/cpp
Tugsbayasgalan Manlaibaatar 4008df3507 Add property binding in torchbind (#50670)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/50670

This PR adds property support to Torchbind. There are two cases that it needs to work:

**Torchscript**
Inside Torchscript, we don't go through pybind so there is no issue with accessing properties through ClassType.

**Eager Mode**
In Eager Mode, Torchbind creates ScriptObject which we cannot dynamically add (aka access) properties after initializing it. (https://stackoverflow.com/questions/1325673/how-to-add-property-to-a-class-dynamically
) Therefore we created a Python wrapper (ScriptObjectWrapper) around ScriptObject where we can use property method to set properties.  By doing so, we can look up wrapped object's property through __getattr__ method of the ScriptObjectWrapper. This logic is inspired from https://github.com/pytorch/pytorch/pull/44324

Test Plan:
test cases in test_torchbind.py

Imported from OSS

Reviewed By: pbelevich

Differential Revision: D26632781

fbshipit-source-id: dd690887cfda0c48ff0d104aa240ce0ab09055bc
2021-03-03 14:25:52 -08:00
..
api Huber loss (#50553) 2021-03-02 17:30:45 -08:00
common
dist_autograd
jit Add property binding in torchbind (#50670) 2021-03-03 14:25:52 -08:00
lite_interpreter_runtime [PyTorch] update CMake to build libtorch lite (#51419) 2021-02-21 01:43:54 -08:00
rpc [RPC] Refactor rref_context to not use utils::Future (#51697) 2021-02-19 00:59:38 -08:00
tensorexpr [nnc] Test cases for uneven split + reorder (#53091) 2021-03-02 20:36:48 -08:00
__init__.py