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

Gather op implementation [#1015] #1151

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Gather op implementation [#1015] #1151

wants to merge 1 commit into from

Conversation

ddilbazTT
Copy link
Contributor

@ddilbazTT ddilbazTT commented Nov 4, 2024

Gather op is lowered into embedding. Used TTIR pass 38a4a46. Used Jackson's embedding fixes from e798a17 PR. Blocked by tt-metal issue 14584.

@ddilbazTT ddilbazTT force-pushed the ddilbaz/gather branch 2 times, most recently from c05933b to b833e79 Compare November 5, 2024 04:31
: public OpConversionPattern<ttir::GatherOp> {
using OpConversionPattern<ttir::GatherOp>::OpConversionPattern;

LogicalResult checkBasicLegality(ttir::GatherOp op,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something that operation verifiers can't catch?

Copy link
Contributor

Choose a reason for hiding this comment

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

We should use verifiers for these scenarios. The only place I think it makes sense to do it outside of the verifiers is in dialects that we don't control, like StableHLO - I don't know if there's a better way to do it though.

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 the intention was to keep stablehlo to ttir conversion layer as thin as possible. Whilst using verifiers, we would mark valid stablehlo gather ops as invalid since they cannot be lowered into embedding. We followed the TTIR to TTIR Pattern Matching approach. I'm not sure if one approach is better than the other.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sdjordjevicTT / @svuckovicTT, this is during conversion and is checking to see if the matchAndRewrite (see below) is possible, i.e. we're able to legally convert the op, which is separate from verification.

Copy link
Contributor

Choose a reason for hiding this comment

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

This one is especially complicated because TTIR gather is a legal op in TTIR, but this rewrite pattern is trying to decomp into embedding op. This is because stablehlo does not have embedding, it's using the more general op gather.

Gather op is lowered into embedding. Used TTIR pass from 38a4a46. Used
embedding fixes from e798a17. Blocked by tt-metal issue 14584.
: public OpConversionPattern<ttir::GatherOp> {
using OpConversionPattern<ttir::GatherOp>::OpConversionPattern;

LogicalResult checkBasicLegality(ttir::GatherOp op,
Copy link
Contributor

Choose a reason for hiding this comment

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

@sdjordjevicTT / @svuckovicTT, this is during conversion and is checking to see if the matchAndRewrite (see below) is possible, i.e. we're able to legally convert the op, which is separate from verification.

: public OpConversionPattern<ttir::GatherOp> {
using OpConversionPattern<ttir::GatherOp>::OpConversionPattern;

LogicalResult checkBasicLegality(ttir::GatherOp op,
Copy link
Contributor

Choose a reason for hiding this comment

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

This one is especially complicated because TTIR gather is a legal op in TTIR, but this rewrite pattern is trying to decomp into embedding op. This is because stablehlo does not have embedding, it's using the more general op gather.

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.

6 participants