Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teach Python TS frontend to parse complex literals #52881

Closed
wants to merge 39 commits into from

Conversation

anjali411
Copy link
Contributor

@anjali411 anjali411 commented Feb 25, 2021

Stack from ghstack:

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.

Differential Revision: D27245059

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Feb 25, 2021

💊 CI failures summary and remediations

As of commit e851c1d (more details on the Dr. CI page):


  • 2/3 failures possibly* introduced in this PR
    • 1/2 non-scanned failure(s)
  • 1/3 broken upstream at merge base 91d37d7 since Mar 22

🕵️ 1 new failure recognized by patterns

The following CI failures do not appear to be due to upstream breakages:

See CircleCI build pytorch_xla_linux_bionic_py3_6_clang9_test (1/1)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Mar 24 03:01:27 ERROR: test_trace_and_metrics (__main__.ProfilerTest)
Mar 24 03:01:27 No trace event is collected. Automatically retrying.
Mar 24 03:01:27 
Mar 24 03:01:27 Starting to trace for 5000 ms. Remaining attempt(s): 0
Mar 24 03:01:27 2021-03-24 03:01:27.575034: E tensorflow/core/profiler/rpc/client/profiler_client.cc:154] Unavailable: failed to connect to all addresses
Mar 24 03:01:27 2021-03-24 03:01:27.575072: W tensorflow/core/profiler/rpc/client/capture_profile.cc:133] No trace event is collected from localhost:59597
Mar 24 03:01:27 2021-03-24 03:01:27.575087: W tensorflow/core/profiler/rpc/client/capture_profile.cc:145] localhost:59597 returned Unavailable: failed to connect to all addresses
Mar 24 03:01:27 No trace event is collected after 5 attempt(s). Perhaps, you want to try again (with more attempts?).
Mar 24 03:01:27 Tip: increase number of attempts with --num_tracing_attempts.
Mar 24 03:01:27 E
Mar 24 03:01:27 ======================================================================
Mar 24 03:01:27 ERROR: test_trace_and_metrics (__main__.ProfilerTest)
Mar 24 03:01:27 ----------------------------------------------------------------------
Mar 24 03:01:27 Traceback (most recent call last):
Mar 24 03:01:27   File "/var/lib/jenkins/workspace/xla/test/test_profiler.py", line 84, in test_trace_and_metrics
Mar 24 03:01:27     delay_ms=1000)
Mar 24 03:01:27   File "/opt/conda/lib/python3.6/site-packages/torch_xla-1.9-py3.6-linux-x86_64.egg/torch_xla/debug/profiler.py", line 85, in trace
Mar 24 03:01:27     options=options)
Mar 24 03:01:27 RuntimeError: No trace event was collected because there were no responses from clients or the responses did not have trace data.
Mar 24 03:01:27 
Mar 24 03:01:27 ----------------------------------------------------------------------
Mar 24 03:01:27 Ran 1 test in 41.294s

🚧 1 ongoing upstream failure:

These were probably caused by upstream breakages that are not fixed yet.


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Feb 25, 2021
@anjali411 anjali411 changed the title Teach Python TS frontend to parse complex literals [WIP] Teach Python TS frontend to parse complex literals Feb 25, 2021
anjali411 added a commit that referenced this pull request Feb 25, 2021
ghstack-source-id: 1c061f6ea7ab62f80bbb891b4dd98ec0771ea6a5
Pull Request resolved: #52881
@anjali411 anjali411 marked this pull request as draft March 2, 2021 00:16
anjali411 added a commit that referenced this pull request Mar 2, 2021
ghstack-source-id: 08935ee6a77fb3676773df1726c3b552e462afd9
Pull Request resolved: #52881
anjali411 added a commit that referenced this pull request Mar 2, 2021
ghstack-source-id: 86e0e04ffca5d9a40b0f5d3d43dc05a8610b8f3f
Pull Request resolved: #52881
Follow-up work:
1. Add complex support for the unary ops, and other registered ops
2. Extensive TS support for complex lists and dicts
3. Test all emitXYZ for all XYZ in `ir_emitter.cpp` (currently only emitConst, emitValueToTensor are tested). e.g., test loops etc.

[ghstack-poisoned]
Follow-up work:
1. Add complex support for the unary ops, and other registered ops
2. Extensive TS support for complex lists and dicts
3. Test all emitXYZ for all XYZ in `ir_emitter.cpp` (currently only emitConst, emitValueToTensor are tested). e.g., test loops etc.

[ghstack-poisoned]
**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. partial complex support for onnx (num -> tensor / tensor -> num)
5. 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).
2. Test all emitXYZ for all XYZ in `ir_emitter.cpp` (currently only emitConst, emitValueToTensor are tested). e.g., test loops etc.

[ghstack-poisoned]
**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. partial complex support for onnx (num -> tensor / tensor -> num)
5. 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).
2. Test all emitXYZ for all XYZ in `ir_emitter.cpp` (currently only emitConst, emitValueToTensor are tested). e.g., test loops etc.

[ghstack-poisoned]
Copy link

@SplitInfinity SplitInfinity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits

torch/csrc/jit/ir/ir.cpp Show resolved Hide resolved
torch/testing/_internal/common_methods_invocations.py Outdated Show resolved Hide resolved
torch/package/_mock.py Outdated Show resolved Hide resolved
torch/csrc/jit/frontend/ir_emitter.cpp Show resolved Hide resolved
**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. partial complex support for onnx (num -> tensor / tensor -> num)
5. 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).
2. Test all emitXYZ for all XYZ in `ir_emitter.cpp` (currently only emitConst, emitValueToTensor are tested). e.g., test loops etc.

[ghstack-poisoned]
**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.

[ghstack-poisoned]
**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.

[ghstack-poisoned]
@anjali411
Copy link
Contributor Author

anjali411 commented Mar 22, 2021

@BowenBao @SplitInfinity Removed all the onnx related changes from this PR. I'll add proper error checking for onnx in a follow-up PR!

**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.

Differential Revision: [D27245059](https://our.internmc.facebook.com/intern/diff/D27245059)

[ghstack-poisoned]
**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.

Differential Revision: [D27245059](https://our.internmc.facebook.com/intern/diff/D27245059)

[ghstack-poisoned]
**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.

Differential Revision: [D27245059](https://our.internmc.facebook.com/intern/diff/D27245059)

[ghstack-poisoned]
@anjali411 anjali411 requested review from SplitInfinity and removed request for SplitInfinity March 23, 2021 15:00
Copy link

@SplitInfinity SplitInfinity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find any reason to not approve. Please make sure to fix failing tests before landing.

**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.

Differential Revision: [D27245059](https://our.internmc.facebook.com/intern/diff/D27245059)

[ghstack-poisoned]
**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.

Differential Revision: [D27245059](https://our.internmc.facebook.com/intern/diff/D27245059)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

@anjali411 merged this pull request in f9ca0d8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed Merged module: complex Related to complex number support in PyTorch oncall: jit Add this issue/PR to JIT oncall triage queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants