Skip to content

[jit][ir] Add pretty printer for JIT IR#10319

Closed
driazati wants to merge 16 commits intopytorch:masterfrom
driazati:ir_pretty
Closed

[jit][ir] Add pretty printer for JIT IR#10319
driazati wants to merge 16 commits intopytorch:masterfrom
driazati:ir_pretty

Conversation

@driazati
Copy link
Contributor

@driazati driazati commented Aug 7, 2018

Adds some pretty-printing capability to the IR graph to make debugging easier/more human readable, see torch/csrc/jit/test_jit.cpp:925 and onwards for example outputs. Results aren't perfect yet but it's a start.

@driazati driazati changed the title Add pretty printer for JIT IR [ijt][ir] Add pretty printer for JIT IR Aug 7, 2018
@driazati driazati changed the title [ijt][ir] Add pretty printer for JIT IR [jit][ir] Add pretty printer for JIT IR Aug 7, 2018
Copy link
Contributor

@goldsborough goldsborough left a comment

Choose a reason for hiding this comment

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

Some C++-level comments, leaving the semantic check to JIT folks

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@zdevito
Copy link
Contributor

zdevito commented Aug 8, 2018

I don't have time for a detailed review right now, but a high-level comment: When storing meta-data for a particular pass like pretty printing, we do not modify structures in ir.h to hold it but instead create std::unordered_maps (e.g. std::unordred_map<Value*, std::string> original_name) that are local to the pass. This keeps implementation details of passes outside of the IR which is shared by many passes.

@ssnl ssnl added the oncall: jit Add this issue/PR to JIT oncall triage queue label Aug 14, 2018
@ssnl
Copy link
Collaborator

ssnl commented Aug 14, 2018

@goldsborough @zdevito seems that the comments are addressed

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

I think there are some soundness issues.

@driazati
Copy link
Contributor Author

Outputs are more verbose with the latest update but should be technically correct

Copy link
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

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

This is looking pretty good. I have a bunch of minor comments to address to clean up the code. It would also be good to follow up with a PR that minimizes the number of assignment statements that need to be outputted in many circumstances by attempting to reuse variable names when possible.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@driazati
Copy link
Contributor Author

@ezyang @zdevito Comments/correctness issues should be all addressed, is this ready to go?

Copy link
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

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

I think there are still a couple minor issues. Can you take a look and let me know?

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

test/test_jit.py Outdated

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@driazati
Copy link
Contributor Author

@pytorchbot retest this please

Copy link
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

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

This looks good now!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

David Riazati added 15 commits September 17, 2018 14:15
Summary:
Fixed nits, moved tests out to `test_jit.py` and exposed functionality
to Python via `graph.pretty_print()`

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:
Changed intermediate names to prefix with "t" instead of "%"

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:
Output is more verbose / looks less nice but is now correct
Statements are generated surrounding loops to match loop dependencies to
outputs

Test Plan:
New test in test_jit.py, see expected outputs

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:
* Moved all functionality to PrettyPrintPass struct, renamed methods
accordingly
* Removed unnecessary assignments of node outputs to loop outputs
* Removed alias for loop condition in case it is read after the loop

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ailzhang
Copy link
Contributor

@pytorchbot retest this please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants