Specialize optional tensor inputs to graphs in the JIT (#18360)
authorThomas Viehmann <tv.code@beamnet.de>
Sun, 24 Mar 2019 05:54:36 +0000 (22:54 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sun, 24 Mar 2019 06:00:37 +0000 (23:00 -0700)
commit7cc7ed1322405ba3c627b9c5661a330f92c4183d
tree40fe386c6d0183b455639fef9689d9856115c5ce
parent32d0e7e339d22636ccb43d5d8a85b70791dd2dba
Specialize optional tensor inputs to graphs in the JIT (#18360)

Summary:
This specializes optional tensor inputs to either a DimensionedTensorType or, when None is passed,
UndefinedTensor (aka AutogradZeroTensorType).
This works because we already have different specs and thus separate plans for the two cases.
It enhances the shape analysis - because now unwrapped optional tensors will have DimensionedTensorType with appropriate shape and required grad etc.
Also, when combined with "if-pruning" (which I understand #18259 works towards), we actually get much nicer concrete graphs, too.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18360

Differential Revision: D14590577

Pulled By: soumith

fbshipit-source-id: cac204a506d1d38b15703cbcc67a6b75fd4979f4
test/test_jit.py
torch/csrc/jit/argument_spec.h
torch/csrc/jit/passes/shape_analysis.cpp