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

TOSA: concat: fix canonicalization that would result in concat with no operands #427

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

mgehre-amd
Copy link
Collaborator

The fold() of the concat had two issues:
a) It would fold concat (tensor<0x2>, tensor<0x4>), axis=1 -> tensor<0x6> into concat () (no operands) based on the observation that both operands have zero elements. This is invalid as concat needs to have at least one operand.

b) After that fix, it would fold concat (tensor<0x2>, tensor<0x4>), axis=1 -> tensor<0x6> int concat (tensor<0x4>), axis=1 -> tensor<0x6>. This is also invalid; even though the concat still produces the same number of elements (= none), shape relations are not corret (0x4 input, but 0x6 output).

I fixed that by only removing operands from the concat when

  • the operand has zero dim on the concatenation axis (i.e. it doesn't contribute to the result shape)
  • there is at least one operand left after removing

…o operands

The fold() of the concat had two issues:
a) It would fold `concat (tensor<0x2>, tensor<0x4>), axis=1 -> tensor<0x6>` into `concat ()` (no operands)
based on the observation that both operands have zero elements. This is invalid as concat needs to have
at least one operand.

b) After that fix, it would fold `concat (tensor<0x2>, tensor<0x4>), axis=1 -> tensor<0x6>`
int `concat (tensor<0x4>), axis=1 -> tensor<0x6>`. This is also invalid; even though the concat
still produces the same number of elements (= none), shape relations are not corret (0x4 input, but 0x6 output).

I fixed that by only removing operands from the concat when
- the operand has zero dim on the concatenation axis (i.e. it doesn't contribute to the result shape)
- there is at least one operand left after removing
@mgehre-amd mgehre-amd requested a review from jorickert December 16, 2024 11:00
@mgehre-amd mgehre-amd enabled auto-merge December 16, 2024 12:05
@mgehre-amd mgehre-amd merged commit 14e4586 into feature/fused-ops Dec 16, 2024
5 checks passed
@mgehre-amd mgehre-amd deleted the matthias.fix_concat_zero_fold branch December 16, 2024 12:31
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.

2 participants