Skip to content

[mlir][scf] scf.for support inline which contains affine map op. #124082

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ def ExecuteRegionOp : SCF_Op<"execute_region", [
// ForOp
//===----------------------------------------------------------------------===//

def ForOp : SCF_Op<"for",
[AutomaticAllocationScope, DeclareOpInterfaceMethods<LoopLikeOpInterface,
def ForOp : SCF_Op<"for", [
AffineScope, AutomaticAllocationScope,
DeclareOpInterfaceMethods<LoopLikeOpInterface,
Copy link
Member

Choose a reason for hiding this comment

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

I think AffineScope should not be introduced in the loop. In the loop, the SSA value generated each time may change, so it is very likely that they are not valid symbols. For example, if a function returns an Index type, the SSA value will change. In addition, the value of the passed parameter, such as memref<?x?xf32>, memref.dim may also change after the function call is completed. Introducing AffineScope here will make all the above values ​​become valid symbols.

The key to the problem should be that your function is in the top level of AffineScope, and the values ​​inside it are all valid symbols, but after being inlined, it is placed in the for loop and they become illegal symbols.

Maybe you should run your function through a lower-affine pass before inlining it.

Copy link
Author

Choose a reason for hiding this comment

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

谢谢!

["getInitsMutable", "getLoopResults", "getRegionIterArgs",
"getLoopInductionVars", "getLoopLowerBounds", "getLoopSteps",
"getLoopUpperBounds", "getYieldedValuesMutable",
Expand Down
Loading