[PyTorch Edge] Backport function for defaults args with out args, flag on (#63651)
authorChen Lai <chenlai@fb.com>
Tue, 21 Sep 2021 05:22:17 +0000 (22:22 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 21 Sep 2021 05:50:30 +0000 (22:50 -0700)
commit880098a7e34a20628f960daa8eab0eb1ad566c39
treef42cd4bd3900806a9b9ef21a2f75d51cdf059742
parent5826d207ad01f588833459b0c5f4fd05f765c276
[PyTorch Edge] Backport function for defaults args with out args, flag on (#63651)

Summary:
1. Enable support for operators with default args and out args. For `torch.add(x, h, out=x)`, the number of specified arguments will be 3 instead of 4.
2. Bump bytecode version from 6 to 7
3. Implement backport_v7_to_v6 function. Also slightly refactor the local_thread to allow re-emit operators.
4. unittest to cover backport function
5. Update expect result from 4 to 3 in unit test DefaultArgsWithOutArg to cover the number of specified arguments.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/63651

ghstack-source-id: 138539912

Test Plan:
```
caffe2/test/cpp/jit:jit - LiteInterpreterTest.DefaultArgsWithOutArg
caffe2/test/cpp/jit:jit - LiteInterpreterTest.DefaultArgsPinvWithOutArg
caffe2/test/cpp/jit:jit - LiteInterpreterTest.BackPortByteCodeModelAllVersions
```

Reviewed By: raziel, tugsbayasgalan

Differential Revision: D30454080

fbshipit-source-id: 357c50b96682430675142d20d688d1f64e1de307
caffe2/serialize/versions.h
test/cpp/jit/test_interpreter.cpp
test/cpp/jit/test_lite_interpreter.cpp
torch/csrc/jit/mobile/backport_manager.cpp
torch/csrc/jit/runtime/interpreter.h
torch/csrc/jit/serialization/export.h
torch/csrc/jit/serialization/export_module.cpp