pytorch/test/expect/TestScript.test_python_frontend.expect
David Riazati 0481a7710d Support for type annotations instead of torch.jit.annotate() (#21390)
Summary:
This adds support for PEP 526 style annotations on assignments in place of
`torch.jit.annotate()`, so

```python
a = torch.jit.annotate(List[int], [])
```

turns into

```python
a : List[int] = []
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/21390

Differential Revision: D15790937

Pulled By: driazati

fbshipit-source-id: 0cc204f7209a79839d330663cc6ba8320d3a4120
2019-06-12 15:51:46 -07:00

81 lines
1.6 KiB
Plaintext

(def
(ident fn)
(decl
(list
(param
(ident x)
(option)
(option)
(False))
(param
(ident y)
(option)
(option)
(False))
(param
(ident z)
(option)
(option)
(False)))
(option))
(list
(assign
(variable (ident q))
(None)
(option))
(assign
(variable (ident q))
(-
(+
(variable (ident x))
(variable (ident y)))
(apply
(.
(variable (ident z))
(ident sigmoid))
(list)
(list)))
(option))
(expression statement
(apply
(variable (ident print))
(list (variable (ident q)))
(list)))
(assign
(variable (ident w))
(unary minus
(variable (ident z)))
(option))
(if
(and
(and
(not (variable (ident x)))
(not (variable (ident y))))
(variable (ident z)))
(list
(assign
(variable (ident m))
(if
(not (variable (ident z)))
(variable (ident x))
(variable (ident y)))
(option)))
(list))
(while
(and
(<
(variable (ident x))
(variable (ident y)))
(>
(variable (ident y))
(variable (ident z))))
(list
(assign
(variable (ident q))
(variable (ident x))
(option))))
(assert
(eq (const 1) (const 1))
(option (string_literal hello)))
(return (variable (ident x)))))