pytorch
1bf3dc51 - [JIT] Add `__prepare_scriptable__` duck typing to allow replacing nn.modules with scriptable preparations (#45645)

Commit
4 years ago
[JIT] Add `__prepare_scriptable__` duck typing to allow replacing nn.modules with scriptable preparations (#45645) Summary: Fixes https://github.com/pytorch/pytorch/issues/45072 As discussed with zdevito gchanan cpuhrsch and suo, this change allows developers to create custom preparations for their modules before scripting. This is done by adding a `__prepare_scriptable__` method to a module which returns the prepared scriptable module out-of-place. It does not expand the API surface for end users. Prior art by jamesr66a: https://github.com/pytorch/pytorch/pull/42244 cc: zhangguanheng66 Pull Request resolved: https://github.com/pytorch/pytorch/pull/45645 Reviewed By: dongreenberg, ngimel Differential Revision: D24039990 Pulled By: zhangguanheng66 fbshipit-source-id: 4ddff2d353124af9c2ef22db037df7e3d26efe65
Author
Parents
Loading