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] Add TaggedShapeAnalyzer::init() in RmUnnTransNetPass #14152

Merged
merged 5 commits into from
Oct 4, 2024

Conversation

zetwhite
Copy link
Contributor

@zetwhite zetwhite commented Oct 2, 2024

This PR adds the TaggedShapeAnalyzer::init() function. The init() function explicitly checks some conditions that have to be met for the analyzer.

ONE-DCO-1.0-Signed-off-by: seunghui youn [email protected]

This PR adds TaggedShapeAnalyzer::init() function.
The init() function explicitly checks some conditions that have be met for the analyzer.

ONE-DCO-1.0-Signed-off-by: seunghui youn <[email protected]>
@zetwhite zetwhite marked this pull request as ready for review October 2, 2024 11:41
Comment on lines 91 to 94
std::vector<int32_t> _in_shape;
std::vector<int32_t> _front_perm;
std::vector<int32_t> _mid_shape;
std::vector<int32_t> _back_perm;
Copy link
Contributor Author

@zetwhite zetwhite Oct 2, 2024

Choose a reason for hiding this comment

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

this member will be initialized in init() and will used in other member functions.

I'm planning to change other methods like this - https://github.com/Samsung/ONE/pull/14150/files#r1784062781.

@zetwhite zetwhite requested a review from a team October 2, 2024 11:50
@zetwhite zetwhite added the PR/ready for review It is ready to review. Please review it. label Oct 2, 2024
Comment on lines 274 to 277
template <loco::DataType DType>
bool TaggedShapeAnalyzer::init(const luci::CircleTranspose *front_transpose,
const luci::CircleReshape *mid_reshape,
const luci::CircleTranspose *back_transpose)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(note)
This is the main change - introduce this init() function to explicitly check the analyzer's working condition.

  • Before

    • conditions(c1 and c2) are checked in callers and some conditions(c3) are not clearly checked
  • After

    • all conditions are checked in this init() function.
    • if init() function fails it means that - the analyzer didn't support this case

Copy link
Contributor

@jinevening jinevening Oct 4, 2024

Choose a reason for hiding this comment

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

Introducing init looks good to me. It's much clearer than before.

I think DType is not a good template parameter. It's the dtype of indices of reshape and dtype of indices of transpose. They don't have to be the same, so the checks in line 292 and 294 are too restrictive. One more concern is that users should call init to support S64 dtype, which looks verbose.

How about handling S32/S64 inside extract_const? It will simplify the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you very much for your detailed review!

I think DType is not a good template parameter.

I agree with your points.

How about handling S32/S64 inside extract_const? It will simplify the function.

Good idea. I updated this PR. Could you take another look?

}
else if (dtype == loco::DataType::S64)
{
int64_t max_i32 = static_cast<int64_t>(std::numeric_limits<int32_t>::max());
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add #include <limits> to fix build error.

Copy link
Contributor

@jinevening jinevening left a comment

Choose a reason for hiding this comment

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

LGTM

@jinevening jinevening merged commit a661f4b into Samsung:master Oct 4, 2024
9 checks passed
Copy link
Contributor

@shs-park shs-park left a comment

Choose a reason for hiding this comment

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

Oh, the code is merged.
Anyway, I left a comment but the code LGTM.
=)

auto rank = node->rank();
for (auto i = 0u; i < rank; ++i)
{
uint32_t v = node->dim(i).value();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it okay to not consider the 64-bit range?

Suggested change
uint32_t v = node->dim(i).value();
uint64_t v = node->dim(i).value();

Copy link
Contributor Author

@zetwhite zetwhite Oct 4, 2024

Choose a reason for hiding this comment

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

@shs-park Thank you for the review!

uint32_t value(void) const { return _value; }

loco::Dimension only holds uint32_t values. So we don't need to handle int64_t for this function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR/ready for review It is ready to review. Please review it.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants