Support FC (Caffe2) -> Gemm (ONNX) with variable input shape. (#16184)
authorTongliang Liao <xkszltl@gmail.com>
Thu, 14 Feb 2019 01:08:40 +0000 (17:08 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 14 Feb 2019 01:12:34 +0000 (17:12 -0800)
commita670824fee57a2b261168a2bfcfc1f4e008d8d4a
tree7c3201d9b7ad34df443b682f4f234162ae50ed2c
parent2ad5dcbbe4a1bc355c6103e9317693fa0bda6cf8
Support FC (Caffe2) -> Gemm (ONNX) with variable input shape. (#16184)

Summary:
For >2D input, previously the code uses static shape captured during tracing and reshape before/after `Gemm`.
Now we add `-1` to the first `Reshape`, and uses `Shape(X) => Slice(outer) => Concat(with -1 for inner) => Reshape` for the second.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16184

Differential Revision: D14070754

Pulled By: ezyang

fbshipit-source-id: 86c69e9b254945b3406c07e122e57a00dfeba3df
caffe2/onnx/onnx_exporter.cc
caffe2/python/onnx/tests/c2_ref_test.py