Commit Graph

6 Commits

Author SHA1 Message Date
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