Expose dim() on type and use it in ONNX symbolics (#15933)
authorJames Reed <jamesreed@fb.com>
Fri, 11 Jan 2019 22:51:17 +0000 (14:51 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 11 Jan 2019 22:54:19 +0000 (14:54 -0800)
commit1235aa4fca55cea7c87febcc2761b84bf3114f1a
tree9d04ea4b1cf157058c806034d576193880d52f56
parent253b680928906693365879905f716d268efaf837
Expose dim() on type and use it in ONNX symbolics (#15933)

Summary:
While integrating fork/join into production translation, we found that trying to export `transpose()` where the input is of `TensorType` (rather than `CompleteTensorType`) failed. This is not ideal, since `TensorType` still contains the number of dimensions of the tensor, and that's all the `transpose` symbolic needs.

This PR introduces a pybind binding for `dim()` on `TensorType` (and `CompleteTensorType` by inheritance). We now use this in places where it logically makes sense in the symbolics: those symbolics which only require knowledge of the number of dimensions rather than concrete sizes.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15933

Differential Revision: D13639657

Pulled By: jamesr66a

fbshipit-source-id: 6e50e407e93060085fd00a686a928764d0ec888d
test/test_jit.py
torch/csrc/jit/python_ir.cpp
torch/onnx/symbolic.py