Skip to content

[VectorLayout] Fix insertion of new constOp for non dominate issue. - #18894

Merged
raikonenfnu merged 1 commit into
iree-org:mainfrom
raikonenfnu:fixConstantLayout
Oct 24, 2024
Merged

raikonenfnu merged 1 commit into
iree-org:mainfrom
raikonenfnu:fixConstantLayout

Conversation

@raikonenfnu

Copy link
Copy Markdown
Collaborator

Main motivation of this patch is to resolve issue where we have the same constOp being used by multiple operations.

But with a twist where first time the constOp needs a layout is on a op that topologically comes after other ops that use constOp. This will generate a copy of constOp in the location right before the latter op, which is problematic because this constOp will be used by other ops before it.

Previously for the test added we get this error:

within split at contraction_layout.mlir:1 offset :24:10: note: see current operation: %9 = "arith.addf"(%8, %6) <{fastmath = #arith.fastmath<none>}> : (vector<96x64xf16>, vector<96x64xf16>) -> vector<96x64xf16>
within split at contraction_layout.mlir:1 offset :22:19: error: operand #1 does not dominate this use
    %scaled_rhs = arith.mulf %read_1, %cst_1 : vector<96x64xf16>

While minor, this is also problematic because this error seem to stopped layout analysis (but not fatally) S.T it fails to vector distribute in some cases, making it hard to debug.

Main motivation of this patch is to resolve issue where we have the same
constOp being used by multiple operations.

But with a twist where first time the constOp needs a layout is on a op
that topologically comes after other ops that use constOp. This will
generate a copy of constOp in the location right before the latter op,
which is problematic because this constOp will be used by other ops
before it.

Previously for the test added we get this error:
```
within split at contraction_layout.mlir:1 offset :24:10: note: see current operation: %9 = "arith.addf"(%8, %6) <{fastmath = #arith.fastmath<none>}> : (vector<96x64xf16>, vector<96x64xf16>) -> vector<96x64xf16>
within split at contraction_layout.mlir:1 offset :22:19: error: operand #1 does not dominate this use
    %scaled_rhs = arith.mulf %read_1, %cst_1 : vector<96x64xf16>
```

While minor, this is also problematic because this error seem to stopped
layout analysis (but not fatally) S.T it fails to vector distribute in
some cases, making it hard to debug.

Signed-off-by: Stanley Winata <[email protected]>
@raikonenfnu

raikonenfnu commented Oct 24, 2024 •

Copy link
Copy Markdown
Collaborator Author

Was quite tricky to debug since I thought it was related to layout analysis visitOperations mechanisms, but hopefully now This PR should fix: #18876 :)

(P.S seems like this was caused after an LLVM bump. I feel clone + replaceAllUses used to guarantee domination, but doesn't seem like it anymore)

@raikonenfnu
raikonenfnu merged commit e96e3c0 into iree-org:main Oct 24, 2024
Eliasj42 pushed a commit that referenced this pull request Oct 31, 2024
…18894)

Main motivation of this patch is to resolve issue where we have the same
constOp being used by multiple operations.

But with a twist where first time the constOp needs a layout is on a op
that topologically comes after other ops that use constOp. This will
generate a copy of constOp in the location right before the latter op,
which is problematic because this constOp will be used by other ops
before it.

Previously for the test added we get this error:
```
within split at contraction_layout.mlir:1 offset :24:10: note: see current operation: %9 = "arith.addf"(%8, %6) <{fastmath = #arith.fastmath<none>}> : (vector<96x64xf16>, vector<96x64xf16>) -> vector<96x64xf16>
within split at contraction_layout.mlir:1 offset :22:19: error: operand #1 does not dominate this use
    %scaled_rhs = arith.mulf %read_1, %cst_1 : vector<96x64xf16>
```

While minor, this is also problematic because this error seem to stopped
layout analysis (but not fatally) S.T it fails to vector distribute in
some cases, making it hard to debug.

Signed-off-by: Stanley Winata <[email protected]>
Signed-off-by: Elias Joseph <[email protected]>
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