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

[draft][luci/pass] Introduce FuseGRU Pass #14252

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

chunseoklee
Copy link
Contributor

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]

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
Copy link
Contributor

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

Comment on lines 270 to 274
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;
Copy link
Contributor

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
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const GRUPatternBase *_p;
// initialized at ctor
const GRUPatternBase *_p;

break;

default:
assert(false);
Copy link
Contributor

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>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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);
Copy link
Contributor

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
Copy link
Contributor

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()));
Copy link
Contributor

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.

@jinevening
Copy link
Contributor

jinevening commented Oct 29, 2024

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.

@chunseoklee
Copy link
Contributor Author

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]>
@seanshpark
Copy link
Contributor

@chunseoklee , how about splitting this PR to several small ones, so that review takes shorter.

@chunseoklee
Copy link
Contributor Author

chunseoklee commented Oct 30, 2024

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

@chunseoklee chunseoklee changed the title [luci/pass] Introduce FuseGRU Pass [draft][luci/pass] Introduce FuseGRU Pass Oct 30, 2024
@chunseoklee chunseoklee marked this pull request as draft October 30, 2024 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants