Skip to content

[JIT] Support multiple outputs in subgraph matcher.#48992

Closed
ZolotukhinM wants to merge 7 commits intogh/ZolotukhinM/388/basefrom
gh/ZolotukhinM/388/head
Closed

[JIT] Support multiple outputs in subgraph matcher.#48992
ZolotukhinM wants to merge 7 commits intogh/ZolotukhinM/388/basefrom
gh/ZolotukhinM/388/head

Conversation

@ZolotukhinM
Copy link
Copy Markdown

@ZolotukhinM ZolotukhinM commented Dec 8, 2020

Stack from ghstack:

Differential Revision: D25388100

@facebook-github-bot facebook-github-bot added cla signed oncall: jit Add this issue/PR to JIT oncall triage queue labels Dec 8, 2020
ZolotukhinM pushed a commit that referenced this pull request Dec 8, 2020
ghstack-source-id: e6e27b0
Pull Request resolved: #48992
@dr-ci
Copy link
Copy Markdown

dr-ci bot commented Dec 8, 2020

💊 CI failures summary and remediations

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


  • 1/1 failures possibly* introduced in this PR
    • 1/1 non-CircleCI failure(s)

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.

This comment has been revised 19 times.

ZolotukhinM pushed a commit that referenced this pull request Dec 9, 2020
ghstack-source-id: a77969a
Pull Request resolved: #48992
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 9, 2020

Codecov Report

Merging #48992 (16dc3e4) into gh/ZolotukhinM/388/base (94a3d4b) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@                     Coverage Diff                     @@
##           gh/ZolotukhinM/388/base   #48992      +/-   ##
===========================================================
+ Coverage                    80.56%   80.59%   +0.03%     
===========================================================
  Files                         1874     1873       -1     
  Lines                       202776   202755      -21     
===========================================================
+ Hits                        163362   163406      +44     
+ Misses                       39414    39349      -65     

hlu1 pushed a commit to hlu1/pytorch that referenced this pull request Dec 9, 2020
Summary: Pull Request resolved: pytorch#48992

Differential Revision: D25388100

Test Plan: Imported from OSS

Pulled By: ZolotukhinM

fbshipit-source-id: 94a178680bcaf4ab7eece90dcb1f31a2ca9aad30
@ZolotukhinM ZolotukhinM changed the title [WIP][JIT] Support multiple outputs in subgraph matcher. [JIT] Support multiple outputs in subgraph matcher. Dec 14, 2020
ZolotukhinM pushed a commit that referenced this pull request Dec 14, 2020
ghstack-source-id: a551d41
Pull Request resolved: #48992
@ZolotukhinM ZolotukhinM requested review from bwasti and hlu1 December 14, 2020 04:53
Copy link
Copy Markdown
Contributor

@bwasti bwasti left a comment

Choose a reason for hiding this comment

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

lgtm

%z = my::op2(%x)
return (%y, %z))IR",
&pattern2);
// Not supported multi-output pattern
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why isn't this supported?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Because not the whole pattern is covered by a traversal up from the first output (%z = ... is not visited). I will add a comment.

}

bool SubgraphMatcher::isPatternOutput(const Value* v) const {
if (v->owningGraph() != &pattern_) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think it will hurt, but is this check necessary?

* but the latter is taken as non-const so that Match may contain non-const
* pointers. This enables clients of this API to use Match to drive mutations.
*
* Note [Multi-output Patterns]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the non-backtracking algorithm (O(M*N) I think: BFS at each node in the graph) or endowing an output ordering (via some kind of topo-sort) might be a good bootcamp task :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Mm, I don't know if such an algorithm exists, maybe I'm missing something? Will be happy to discuss it :)

* output and assume that it is sufficient to traverse up from it to match the
* entire pattern.
*
* Corrolary 1: the order of outputs in the pattern matters!
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does the order in which internal outputs are consumed matter?

graph(a, b):
  c = node0(a)
  d = node1(b)
  return c + d, d

vs

graph(a, b):
  d = node1(b)
  c = node0(a)
  return c + d, d

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No, that does not matter.

ZolotukhinM pushed a commit that referenced this pull request Dec 14, 2020
ghstack-source-id: 8f44738
Pull Request resolved: #48992
ZolotukhinM pushed a commit that referenced this pull request Dec 15, 2020
ghstack-source-id: 61f84f7
Pull Request resolved: #48992
ZolotukhinM pushed a commit that referenced this pull request Dec 15, 2020
ghstack-source-id: 313e558
Pull Request resolved: #48992
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@ZolotukhinM merged this pull request in 38a59a6.

@facebook-github-bot facebook-github-bot deleted the gh/ZolotukhinM/388/head branch December 19, 2020 15:18
hwangdeyu pushed a commit to hwangdeyu/pytorch that referenced this pull request Jan 6, 2021
Summary: Pull Request resolved: pytorch#48992

Differential Revision: D25388100

Test Plan: Imported from OSS

Reviewed By: heitorschueroff

Pulled By: ZolotukhinM

fbshipit-source-id: d95713af2220cf4f99ac92f59f8e5b902f2f3822
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants