-
Notifications
You must be signed in to change notification settings - Fork 159
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] Support CircleGRU #12319
[DRAFT] Support CircleGRU #12319
Conversation
29060f0
to
6ee3e3e
Compare
@@ -58,6 +58,7 @@ class CircleOpRegistry | |||
REG_TFL_OP(BATCH_MATMUL, CircleOpBatchMatMul); | |||
REG_TFL_OP(BCQ_FULLY_CONNECTED, CircleOpBCQFullyConnected); | |||
REG_TFL_OP(BCQ_GATHER, CircleOpBCQGather); | |||
REG_TFL_OP(CIR_GRU, CircleOpCircleGRU); |
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.
REG_TFL_OP(CIR_GRU, CircleOpCircleGRU); | |
REG_TFL_OP(GRU, CircleOpGRU); |
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.
or,
1/ to prepare tflite introduces GRU,
2/ two Circle
looks odd
REG_TFL_OP(CIR_GRU, CircleOpCircleGRU); | |
REG_TFL_OP(CIR_GRU, CircleOpCirGRU); |
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 think second variant better to avoid future problems with tflite GRU 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.
Done
@@ -64,6 +64,7 @@ enum Activation { | |||
NONE = 0; | |||
RELU = 1; | |||
RELU6 = 3; | |||
TANH = 4; |
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.
Q) is this necessary for our model?
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.
Remove it, thank you
@@ -541,6 +541,13 @@ class BuiltinOptionsExtractor final | |||
to_circle_actfunc(node->fusedActivationFunction())) | |||
.Union(); | |||
} | |||
flatbuffers::Offset<void> visit(luci::CircleGRU *node) |
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.
CircleGRU
-> need to sync name with chef.
I don't think there is one exact answer so we may need to discuss.
if (num_fc != 2 or num_mul != 3 or num_logistic != 2 or num_split != 2 or num_add != 6 or | ||
num_gather != 1 or num_reshape != 1 or num_sub != 1 or num_tanh != 1 or num_split_out != 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.
I don't think counting elements can provide correct condition.
And tracking the graph for exact Op type looks laborious job.
But we may have to do with some good graph traversal codes.
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.
Okay, I will change it further )
May need
You may know that you can create |
Q) do you not have a plan to implement luci-interpreter ? |
cloned->rank(node->rank()); | ||
|
||
// values | ||
switch (node->dtype()) |
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.
Q) do we need all these implemented types?
if (not while_out_node) | ||
continue; | ||
|
||
if (fuse_gru(while_out_node)) |
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.
Q) are other sub graphs like the body graph removed?
I don't recall we had some method to remove graph in the Module.
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.
Q) are other sub graphs like the body graph removed?
Actually - no. We need to support some methods to remove subgraphs in the Module
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.
What do you think about add a new option that will leave only the main sub-graph, and delete others? Smth like --use_only_main_graph
and use fuse_gru and use_only_main_graph together. Otherwise, we need to transfer/save the luci::Module entity to CircleOptimizer to remove unnecessary graphs
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.
Otherwise, we need to transfer/save the luci::Module entity to CircleOptimizer to remove unnecessary graphs
Maybe some kind of eliminate dead sub-graph...
1/ As of now, all sub-graphs having ID > 0 are used by some other sub-graph (usually ID == 0).
(I'm not sure this will hold in the future)
2/ We can use void CircleOptimizer::optimize(luci::Module *m) const
3/ Add something like EliminateDeadSubgraphPass
(maybe with --elminate-dead-graph
option or run this for default without any options)
4/ Traverse main graph and mark sub-graphs that are used
5/ Traverse used sub-graphs and mark other used sub-graphs too
6/ Delete sub-graphs that are not marked
Can this be feasible ?
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.
Can this be feasible ?
I think yes, good idea to add EliminateDeadSubgraphPass
and run this for default
I'm not sure if this operation is needed in luci-interpreter, so now I don't have this in plan. But if you think it's better to add it, I'll do it) |
Current purpose I have is to validate fusion implementation through value test (as mathematical equivalence). |
I got assertion tflchef-reverse: /ONE/compiler/tflchef/tflite/src/RecipeChef.cpp:77: std::unique_ptrtflchef::ModelRecipe tflchef::generate_recipe(const tflite::Model*): Assertion `tflite_import.num_subgraph() == 1' failed. |
current tflchef-reverse seems to supports only single subgraph model. |
This draft supports CircleGRU in compiler. ONE-DCO-1.0-Signed-off-by: Artem Balyshev <[email protected]>
…ypes in FuseCirGruPass.
4ed032d
to
aac9083
Compare
Done, added it |
@seanshpark, can I split this draft into PRs? For |
Yes, let's go :) I didn't look deeper into the draft codes... I check while review with PRs. |
This draft supports CircleGRU in compiler.
for issue: #12320
related issue: #12263
ONE-DCO-1.0-Signed-off-by: Artem Balyshev [email protected]