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

[luci/pass] Revise FuseInstanceNormPass V6 #14397

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions compiler/luci/pass/src/FuseInstanceNormPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ namespace
* V V V |
* mul_as_scaled_ifm mul_as_scaled_mean <-------------+
* | |
* | const_as_beta |
* | const_zero |
* | | V
* | +------> sub
* V |
Expand Down Expand Up @@ -721,16 +721,6 @@ template <> bool InstanceNormPattern::match<InstanceNormPattern::PatternVersion:
CHECK_OR_FALSE(is_instance_mean_v2(mean_of_ifm));
CHECK_OR_FALSE(ifm == mean_of_ifm->input());

// If const_as_beta has shape of '1 x chennel x (1 or input last dimension)'
uint32_t input_channel = ifm_circle->dim(1).value();
uint32_t input_last_dim = ifm_circle->dim(2).value();
const_as_beta = dynamic_cast<luci::CircleConst *>(sub->x());
CHECK_OR_FALSE(const_as_beta);
CHECK_OR_FALSE(const_as_beta->rank() == 3);
CHECK_OR_FALSE(
const_as_beta->dim(0).value() == 1 && const_as_beta->dim(1).value() == input_channel &&
(const_as_beta->dim(2).value() == 1 || const_as_beta->dim(2).value() == input_last_dim));
Comment on lines -727 to -732
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need to check the shape and the value of sub->x() (const_as_zero).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So we need to check all the values should be 0.0f too ?


luci::CircleRsqrt *rsqrt_should_be = nullptr;
luci::CircleMean *mean_of_ifm_should_be = nullptr;

Expand All @@ -741,11 +731,12 @@ template <> bool InstanceNormPattern::match<InstanceNormPattern::PatternVersion:
CHECK_OR_FALSE(rsqrt == rsqrt_should_be);
CHECK_OR_FALSE(mean_of_ifm == mean_of_ifm_should_be);

// mul_gamma is absent
// const_as_gamma assume to be 1.0
// create 1.0 gamma and 0.0 beta
auto graph = add_as_terminal->graph();
const_as_gamma = make_const_one(graph, 1.0f);
const_as_gamma->name(add_as_terminal->name() + "/gamma");
const_as_beta = make_const_one(graph, 0.0f);
const_as_beta->name(add_as_terminal->name() + "/beta");
Comment on lines +734 to +739
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these lines are unnecessary. *1 and +0 are Nop.

And, apply functions for version_5 and version_6 have to be updated too. There are no gamma and beta for those patterns, so reshape_gamma_beta function should not be called.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think these lines are unnecessary. *1 and +0 are Nop.

I don't understand the meaning. Maybe code example will help.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And, apply functions for version_5 and version_6 have to be updated too.

I cannot check for ver 5 as of now and do not want to mix for both version in one PR.


_matched = true;
return true;
Expand Down