Commit Graph

16 Commits

Author SHA1 Message Date
Oguz Ulgen
920f0426ae Add None return type to init -- tests rest (#132376)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132376
Approved by: https://github.com/jamesjwu
ghstack dependencies: #132335, #132351, #132352
2024-08-01 15:44:51 +00:00
Xuehai Pan
6ff1e43a41 [BE][Easy][13/19] enforce style for empty lines in import segments in test/j*/ (#129764)
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501. Most changes are auto-generated by linter.

You can review these PRs via:

```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/129764
Approved by: https://github.com/ezyang
2024-08-01 12:13:42 +00:00
Yuanhao Ji
604c9c5601 Enable UFMT on all of test/jit (#123623)
Partially addresses #123062

Ran lintrunner on:

- `test/jit`

with command:

```bash
lintrunner -a --take UFMT --all-files
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/123623
Approved by: https://github.com/ezyang
2024-04-11 23:45:05 +00:00
David Berard
f51a497f92 [JIT] add builtin functions for (complex, Tensor) (#73286)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/73286

Adds support in jit for op(complex, Tensor) for the following:
* add (+)
* mul (*)
* eq (==)
* ne (!=)
* sub (-)
* div (/)

These already worked in eager mode, but didn't work in jit.

Test Plan: Imported from OSS

Reviewed By: george-qi

Differential Revision: D34421794

Pulled By: davidberard98

fbshipit-source-id: 0aecec7d7da1dcf2bcceb6849d3049fe2b39076d
(cherry picked from commit 375998d38d60ab97f7be8d95dd7bdc10bd1f6417)
2022-02-24 18:40:47 +00:00
Jane Xu
09c7771e9c Set test owners for jit tests (#66808)
Summary:
Action following https://github.com/pytorch/pytorch/issues/66232

Pull Request resolved: https://github.com/pytorch/pytorch/pull/66808

Reviewed By: mrshenli

Differential Revision: D31761414

Pulled By: janeyx99

fbshipit-source-id: baf8c49ff9c4bcda7b0ea0f6aafd26380586e72d
2021-10-25 07:51:10 -07:00
anjali411
770f8cea2d Add support for real and imag tensor attributes (#54692)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/54692

Test Plan: Imported from OSS

Reviewed By: ejguan

Differential Revision: D28412240

Pulled By: anjali411

fbshipit-source-id: e6965c55539a44260a812fdaa4a982f02067bb05
2021-05-13 10:44:27 -07:00
anjali411
82d714935e [TS] Add complex support for more ops (#54541)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/54541

Test Plan: Imported from OSS

Reviewed By: SplitInfinity

Differential Revision: D27599114

Pulled By: anjali411

fbshipit-source-id: 182d4480fd788599c408bfaf0d23baf3d9a4e967
2021-05-12 23:33:29 -07:00
Sam Estep
e3900d2ba5 Add lint for unqualified noqa (#56272)
Summary:
As this diff shows, currently there are a couple hundred instances of raw `noqa` in the codebase, which just ignore all errors on a given line. That isn't great, so this PR changes all existing instances of that antipattern to qualify the `noqa` with respect to a specific error code, and adds a lint to prevent more of this from happening in the future.

Interestingly, some of the examples the `noqa` lint catches are genuine attempts to qualify the `noqa` with a specific error code, such as these two:
```
test/jit/test_misc.py:27:            print(f"{hello + ' ' + test}, I'm a {test}") # noqa E999
test/jit/test_misc.py:28:            print(f"format blank") # noqa F541
```
However, those are still wrong because they are [missing a colon](https://flake8.pycqa.org/en/3.9.1/user/violations.html#in-line-ignoring-errors), which actually causes the error code to be completely ignored:

- If you change them to anything else, the warnings will still be suppressed.
- If you add the necessary colons then it is revealed that `E261` was also being suppressed, unintentionally:
  ```
  test/jit/test_misc.py:27:57: E261 at least two spaces before inline comment
  test/jit/test_misc.py:28:35: E261 at least two spaces before inline comment
  ```

I did try using [flake8-noqa](https://pypi.org/project/flake8-noqa/) instead of a custom `git grep` lint, but it didn't seem to work. This PR is definitely missing some of the functionality that flake8-noqa is supposed to provide, though, so if someone can figure out how to use it, we should do that instead.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/56272

Test Plan:
CI should pass on the tip of this PR, and we know that the lint works because the following CI run (before this PR was finished) failed:

- https://github.com/pytorch/pytorch/runs/2365189927

Reviewed By: janeyx99

Differential Revision: D27830127

Pulled By: samestep

fbshipit-source-id: d6dcf4f945ebd18cd76c46a07f3b408296864fcb
2021-04-19 13:16:18 -07:00
nikithamalgi
5cd73df8f8 [Hackathon]Move complex tests to test_complex.py (#55514)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/55514

Test Plan: Imported from OSS

Reviewed By: pbelevich

Differential Revision: D27679881

Pulled By: nikithamalgifb

fbshipit-source-id: 8a4f4ab8f375187b72ede6feaea37ab546da6d3e
2021-04-12 20:35:36 -07:00
Nikita Shulga
0269a5f481 Re-enable cmath.sqrt(complex(-1,-0.0)) test (#54923)
Summary:
Both JITed and plan `cmath.sqrt(complex(-1, -0.0))` should return `-1j` after https://github.com/pytorch/pytorch/pull/54820 has been resolved.

Also, use f-string instead of `.format` method

Pull Request resolved: https://github.com/pytorch/pytorch/pull/54923

Reviewed By: anjali411

Differential Revision: D27415117

Pulled By: malfet

fbshipit-source-id: 52e182feca50b690684de87c99df0ad6bef1ab44
2021-03-30 07:25:26 -07:00
anjali411
1bccd48465 Allow creating SugaredValue for a complex valued IValue and deserialization logic for "infj" and "nanj" global constants (#54328)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/54328

Test Plan: Imported from OSS

Reviewed By: nikithamalgifb

Differential Revision: D27369134

Pulled By: anjali411

fbshipit-source-id: aec26750a6fc8917ee15306684b743d13a91570c
2021-03-29 14:46:29 -07:00
anjali411
d63dd07f06 Add JIT support for cmath unary ops (#54089)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/54089

**This PR adds:**
1. support for the following [cmath](https://docs.python.org/3/library/cmath.html) functions:
     - Power and logarithmic functions (`cmath.{exp, log, log10, sqrt}`)
     - Trigonometric functions (`cmath.{sin, cos, tan, asin, acos, atan}`)
     - Hyperbolic functions (`cmath.{sinh, cos, tanh, asinh, acosh, atanh}`)
     - `cmath.phase()`
2. `abs()`

**Future work:**
1. support
    - `cmath.{polar, rect}`
    - classification functions (`cmath.{isfinite, isnan, isinf, isclose}`)
    - constants (`cmath.{pi, e, inf, nan, infj, nanj}`)

Test Plan: Imported from OSS

Reviewed By: ezyang

Differential Revision: D27339149

Pulled By: anjali411

fbshipit-source-id: fe1a019c95adbc9f27f7948eb28c0c3b93d8c026
2021-03-26 22:55:34 -07:00
anjali411
f9ca0d87a7 Teach Python TS frontend to parse complex literals (#52881)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/52881

**This PR adds:**
1. logic to parse complex constants (complex literals of the form `bj`)
2. logic to parse complex lists
3. support for complex constructors: `complex(tensor/int/float/bool, tensor/int/float/bool)`
4. Limited operator support
     - `add`, `sub`, `mul`, `torch.tensor`, `torch.as_tensor`

**Follow-up work:**
1. Add complex support for unary and other registered ops.
2. support complex constructor with string as input (this is supported in Python eager mode).
3. Test all emitXYZ for all XYZ in `ir_emitter.cpp` (currently only emitConst, emitValueToTensor are tested). e.g., test loops etc.
4. onnx doesn't support complex tensors, so we should error out with a clear and descriptive error message.

Test Plan: Imported from OSS

Reviewed By: bdhirsh

Differential Revision: D27245059

Pulled By: anjali411

fbshipit-source-id: af043b5159ae99a9cc8691b5a8401503fa8d6f05
2021-03-24 08:12:17 -07:00
anjali411
f0006315a9 Add support for complex valued keys for dict in TS (#51472)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/51472

Test Plan: Imported from OSS

Reviewed By: ezyang

Differential Revision: D26177963

Pulled By: anjali411

fbshipit-source-id: 5841159c36b07290b1d88d4df27a0bf8c17d9df8
2021-02-01 22:40:01 -08:00
anjali411
508bab43e7 Support complex number list in JIT (#51145)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/51145

Test Plan: Imported from OSS

Reviewed By: SplitInfinity

Differential Revision: D26154025

Pulled By: anjali411

fbshipit-source-id: 74645f9b6467757ddb9d75846e778222109848f0
2021-01-31 23:54:14 -08:00
anjali411
f9f22c8b5c Add serialization logic for complex numbers (#51287)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51287

This reverts commit dfdb1547b9.

Test Plan: Imported from OSS

Reviewed By: SplitInfinity

Differential Revision: D26131165

Pulled By: anjali411

fbshipit-source-id: 047167fac594ddb670c5e169446e90e74991679a
2021-01-28 17:25:35 -08:00