pytorch/test/cpp
Martin Yuan 23c50a4a50 [PyTorch Mobile] Support torchbind custom classes in lite interpreter (#51432)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51432

ghstack-source-id: 120976584

torchbind is a convenient way to include custom class to both python and torchscript. CREATE_OBJECT is used to create an object of custom class.

CREATE_OBJECT was not supported by lite interpreter. The major reason was that for custom class directly defined in Python, there's no language parser in lite interpreter. It's still the case. However, for torchbind classes that are defined in C++, a python/torchscript parser is not needed.

This diff is to support the case of torchbind custom classes.
1. The class type can be resolved at import level.
2. If the class is not the supported torchbind class, an error message is provided at export stage. Workaround is also suggested.
3. Unit tests. C++: ```LiteInterpreterTest::BuiltinClass``` is added as an end-to-end test on supported class. Python: ```test_unsupported_createobject``` is changed to ```test_unsupported_classtype``` to test unsupported classes.

Test Plan: CI

Reviewed By: raziel

Differential Revision: D26168913

fbshipit-source-id: 74e8b6a12682ad8e9c39afdfd2b605c5f8e65427
2021-02-03 21:57:19 -08:00
..
api fix unflatten_dense_tensor when there is empty tensor inside (#50321) 2021-01-23 12:14:34 -08:00
common
dist_autograd Fix Windows build failure after DDP PR merged (#45335) 2020-09-25 12:37:50 -07:00
jit [PyTorch Mobile] Support torchbind custom classes in lite interpreter (#51432) 2021-02-03 21:57:19 -08:00
rpc Support device map for distributed autograd while using TensorPipe. (#44859) 2021-01-27 13:01:44 -08:00
tensorexpr [TensorExpr] Resubmit: Introduce ExternalCall nodes to TE IR. (#51594) 2021-02-03 10:22:54 -08:00
__init__.py remediation of S205607 2020-07-17 17:19:47 -07:00