-
Notifications
You must be signed in to change notification settings - Fork 158
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
[draft][luci/pass] Introduce FuseGRU Pass #14252
base: master
Are you sure you want to change the base?
Conversation
This PR introduces FuseGRUPass for fusing decomposed gru pattern into single CircleGRU. ONE-DCO-1.0-Signed-off-by: Artem Balyshev <[email protected]> ONE-DCO-1.0-Signed-off-by: Chunseok Lee <[email protected]>
if (_while_node == nullptr) | ||
return false; | ||
|
||
// 1 - check condition graph: only one Less operation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only one Less operation
and below condition doesn't match.
- 1/ fix comment like
Less operation should exist
- 2/ fix implementation to check only one
Less
exist
if (fc_nodes.size() != 2 or mul_nodes.size() != 3 or logistic_nodes.size() != 2 or | ||
split_nodes.size() != 2 or add_nodes.size() != 6 or gather_nodes.size() != 1 or | ||
reshape_nodes.size() != 1 or sub_nodes.size() != 1 or tanh_nodes.size() != 1 or | ||
split_out_nodes.size() != 6) | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I commented in the draft code, I don't agree on only check number of Ops to check.
split_out_nodes.size() != 6) | ||
return false; | ||
|
||
// Check structure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the algorithm of below check codes.
Please explain what is happening.
luci::CircleGRU *create_circle_gru(loco::Graph *graph); | ||
|
||
private: | ||
const GRUPatternBase *_p; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const GRUPatternBase *_p; | |
// initialized at ctor | |
const GRUPatternBase *_p; |
break; | ||
|
||
default: | ||
assert(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's throw instead of assert
} | ||
else | ||
{ | ||
bias_ih_cloned = _p->_pattern_last_node->graph()->nodes()->create<luci::CircleOutputExclude>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bias_ih_cloned = _p->_pattern_last_node->graph()->nodes()->create<luci::CircleOutputExclude>(); | |
bias_ih_cloned = graph->nodes()->create<luci::CircleOutputExclude>(); |
?
|
||
luci::CircleGRU *FuseGRU::create_circle_gru(loco::Graph *graph) | ||
{ | ||
assert(graph); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this graph
and _p->_pattern_last_node->graph()
are different, please add a not about this.
As I understand, we're looking with multiple sub graph
objects so graph
ptr can be different.
* | | ||
* [Out_1] | ||
*/ | ||
class GRUPattern1 final : public GRUPatternBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume 1
suffix in GRUPattern1
is to prepare more patterns.
Please leave a note about thus.
Or please use just GRUPattern
here and later we can rename this when we add more patterns.
|
||
g.init(); | ||
|
||
EXPECT_FALSE(pass.run(g.g())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding a note about what negative would help understanding FuseGRUTestNegGraph
.
It's a bunch of nodes connected and I can't catch what it's doing.
Co-authored-by: SaeHie Park <[email protected]>
Co-authored-by: SaeHie Park <[email protected]>
BTW, what happens to the dead subgraphs after fusion? We have dead node elimination passes, but AFAIK we don't have such a pass for dead subgraphs. If dead subgraphs are not removed in the model, model size may be increased. |
the draft has deal subgraph elimination pass :) I will submit it soon |
Co-authored-by: Hyukjin Jeong <[email protected]>
@chunseoklee , how about splitting this PR to several small ones, so that review takes shorter. |
I will try, but I am not sure that how to split FUseGRUPass.cpp into smaller ones. Then, I will change this PR to draft state. |
Co-authored-by: Hyukjin Jeong <[email protected]>
This PR introduces FuseGRUPass for fusing decomposed gru pattern into single CircleGRU.
draft : #14237
issue : #12263
ONE-DCO-1.0-Signed-off-by: Artem Balyshev [email protected]
ONE-DCO-1.0-Signed-off-by: Chunseok Lee [email protected]