diff options
author | Elias Ellison <eellison@fb.com> | 2019-01-18 11:17:34 -0800 |
---|---|---|
committer | Facebook Github Bot <facebook-github-bot@users.noreply.github.com> | 2019-01-18 11:25:01 -0800 |
commit | d4f6befc93938e5462b186f76405b544e50fab60 (patch) | |
tree | ae89c058415b5d62c28ca56189a4d607d591b7c3 /aten | |
parent | da578b7dcf43bab88a3f0d407cb8a31c10a79557 (diff) | |
download | pytorch-d4f6befc93938e5462b186f76405b544e50fab60.tar.gz pytorch-d4f6befc93938e5462b186f76405b544e50fab60.tar.bz2 pytorch-d4f6befc93938e5462b186f76405b544e50fab60.zip |
Add implicit optional unwrapping (#15587)
Summary:
Add support for type inference for optional type refinement.
If a conditional is of the form "x is None" or "x is not None", or is a boolean expression containing multiple none checks, the proper type refinements are inserted in each branch.
For example:
if optional_tensor is not None and len(optional_tensor) < 2:
# optional_tensor is a Tensor
if optional_tensor1 is not None and optional_tensor2 is not None:
# both optional_tensor1 and optional_tensor2 are Tensors
TODO:
- not run an op for unchecked unwrap optional in the interpreter
- potentially refine types to prim::None (omitted for now to simply things & because it's not an actual use cause).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15587
Differential Revision: D13733810
Pulled By: eellison
fbshipit-source-id: 57c32be9f5a09ab5542ba0144a6059b96de23d7a
Diffstat (limited to 'aten')
-rw-r--r-- | aten/src/ATen/core/interned_strings.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/aten/src/ATen/core/interned_strings.h b/aten/src/ATen/core/interned_strings.h index 5e9144b07c..049f5adc91 100644 --- a/aten/src/ATen/core/interned_strings.h +++ b/aten/src/ATen/core/interned_strings.h @@ -88,6 +88,7 @@ namespace c10 { _(aten, index_put_) \ _(aten, device) \ _(aten, len) \ + _(prim, unchecked_unwrap_optional)\ FORALL_ATEN_BASE_SYMBOLS(_) \ _(onnx, Add) \ _(onnx, Concat) \ |