Skip to content

Add new tile size for fp16 and fallback if vectorization is not possible - #3882

Merged
ThomasRaoux merged 3 commits into
iree-org:mainfrom
ThomasRaoux:enable_fp16_tiling
Nov 18, 2020
Merged

ThomasRaoux merged 3 commits into
iree-org:mainfrom
ThomasRaoux:enable_fp16_tiling

Conversation

@ThomasRaoux

Copy link
Copy Markdown
Contributor

For ARM, pick tile size based on the type for MatmulOp.
Make launchConfig decide if we should apply vectorization passes to allow fallback for small or none-aligned operations.

@antiagainst antiagainst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a few nits.

auto rhsType = op.inputs()[1].getType().cast<MemRefType>();
assert(lhsType.getElementType() == rhsType.getElementType());
// Pick ideal tile size based on the type.
SmallVector<int64_t, 4> ts;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we name it better to be clear? Something like workgroupLevel? (So we can name threadTs as invocationLevel.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

}

if (options.enableVectorization) {
if (launchConfig.useVectorize()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be nice to kill the cl option entirely and make vectorization on by default. Any remaining work for that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, I think it should all work at this point and we can enable it by default. I'll send another PR for that.

@MaheshRavishankar

Copy link
Copy Markdown
Collaborator

Adding an additional argument here seems to be a lot of work that needs to be repeated if we need new arguments. Can the getOpLaunchConfig method be refactored to return an Optional<OpLaunchConfig> (or some other name) where

struct OpLaunchConfig {
  std::array<int64_t, 3> workgroupSize = {1, 1, 1};
  std::array<int64_t, 3> numSubgroups = {1, 1, 1};
  bool vectorize = false;
}

Then we don't need to do this if we need new options. Note that this will also help in the process of eventually killing LaunchConfig that is giving me a cringe everytime I see it.

@MaheshRavishankar MaheshRavishankar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Requesting a change based on comment

@ThomasRaoux

Copy link
Copy Markdown
Contributor Author

Adding an additional argument here seems to be a lot of work that needs to be repeated if we need new arguments. Can the getOpLaunchConfig method be refactored to return an Optional<OpLaunchConfig> (or some other name) where

struct OpLaunchConfig {
  std::array<int64_t, 3> workgroupSize = {1, 1, 1};
  std::array<int64_t, 3> numSubgroups = {1, 1, 1};
  bool vectorize = false;
}

Then we don't need to do this if we need new options. Note that this will also help in the process of eventually killing LaunchConfig that is giving me a cringe everytime I see it.

Sounds good, I made a structure will all the dispatch level config info.

@MaheshRavishankar MaheshRavishankar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! Not blocking comment, but passing by reference can be problematic (I know I implemented it, but I shouldnt have done it that way in hind sight). Its easy to drop the & if you are passing to another function by reference and then you dont get what you want and its hard to trace down. I am attempting to move to use Optional<...> instead of LogicalResult ... (... &val)

@ThomasRaoux

Copy link
Copy Markdown
Contributor Author

Thanks! Not blocking comment, but passing by reference can be problematic (I know I implemented it, but I shouldnt have done it that way in hind sight). Its easy to drop the & if you are passing to another function by reference and then you dont get what you want and its hard to trace down. I am attempting to move to use Optional<...> instead of LogicalResult ... (... &val)

Would you also pull TileSizesListType in the structure as well? Maybe this structure should be part of LaunchConfig class altogether this way we don't have to manually copy each filed (seems error-prone). what do you think?
I can send another PR today to refactor this part so that we don't have to mix the functional part and refactoring too much.

@ThomasRaoux
ThomasRaoux merged commit 85efe00 into iree-org:main Nov 18, 2020
@ThomasRaoux
ThomasRaoux deleted the enable_fp16_tiling branch February 16, 2021 23:43
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