This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Make promote single iteration optional on affine-loop-normalize
ClosedPublic

Authored by bondhugula on Nov 7 2022, 8:05 PM.

Details

Summary

Make promote single iteration optional on affine-loop-normalize:
introduce a command-line flag and an argument on the utility. Disable it
by default since such a promotion isn't normally expected with loop
normalization: it could drop certain structure or information on the
loops that a user wanted to preserve.

Diff Detail

Event Timeline

bondhugula created this revision.Nov 7 2022, 8:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 7 2022, 8:05 PM
bondhugula requested review of this revision.Nov 7 2022, 8:05 PM

We initially added this to --affine-loop-normalize. Probably it's not the best place but removing loops as part of canonicalization or a common simplification pass that is run all over the pipeline can be problematic as it drops information about the input dimensions. This may prevent or make some transformations harder. I'd suggest that we use the loop specific normalization pass or create a new pass to simplify loops and other control-flow structures. What do you think?

We initially added this to --affine-loop-normalize. Probably it's not the best place but removing loops as part of canonicalization or a common simplification pass that is run all over the pipeline can be problematic as it drops information about the input dimensions. This may prevent or make some transformations harder. I'd suggest that we use the loop specific normalization pass or create a new pass to simplify loops and other control-flow structures. What do you think?

Another alternative/solution is to perform this promotion under a pass option? Can be enabled or disabled and perhaps disabled by default?

We initially added this to --affine-loop-normalize. Probably it's not the best place but removing loops as part of canonicalization or a common simplification pass that is run all over the pipeline can be problematic as it drops information about the input dimensions. This may prevent or make some transformations harder. I'd suggest that we use the loop specific normalization pass or create a new pass to simplify loops and other control-flow structures. What do you think?

Another alternative/solution is to perform this promotion under a pass option? Can be enabled or disabled and perhaps disabled by default?

Thanks. I just noticed that it's already part of affine-loop-normalize - had forgotten about it. Perhaps we should either remove or disable it by default from there as well for the reasons you mention.

556 LogicalResult mlir::normalizeAffineFor(AffineForOp op) {
557   if (succeeded(promoteIfSingleIteration(op)))
558     return success();

Yeah, sorry, my comment sounded as if we had removed it from affine-loop-normalize and that's not the case :). A flag or a new pass sound good to me.

Revise to add flag on affine-loop-normalize pass.

bondhugula retitled this revision from [MLIR] Add promote single iteration loop to simplify-affine-structures to [MLIR] Make promote single iteration optional on affine-loop-normalize.
bondhugula edited the summary of this revision. (Show Details)

Update commit summary.

Yeah, sorry, my comment sounded as if we had removed it from affine-loop-normalize and that's not the case :). A flag or a new pass sound good to me.

Done - added a flag.

dcaballe accepted this revision.Nov 28 2022, 11:09 AM

Thanks!

This revision is now accepted and ready to land.Nov 28 2022, 11:09 AM