-
Notifications
You must be signed in to change notification settings - Fork 29
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
Canonicalizers for doubly strided ops such as npu.dma_cpy_nd #680
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a canonicalizer upstream here that does this, but it is a bit hard-coded for tensor.extract_slice
like op that have a single offset
, size
and stride
. It should be split up to handle each of the offset
, size
and stride
separately. Then you could reuse that here. Maybe just use the same style here to be consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, should help make IR more compact and readable! Would be great to do for all doubly strided ops in one go I think.
Actually, if your wait for this PR (llvm/llvm-project#104488) it might get even easier |
3f0ca36
to
1de7f26
Compare
@MaheshRavishankar thanks for the pointer, I've changed to use the same style for now. |
8e99191
to
a0a4bad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a few small nits
@@ -93,6 +90,70 @@ TileOp CoreOp::getTileOp() { | |||
// AMDAIE_DmaCpyNdBaseOp | |||
//===----------------------------------------------------------------------===// | |||
|
|||
namespace { | |||
// Simplified from upstream MLIR's foldDynamicIndexList: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Simplified from upstream MLIR's foldDynamicIndexList: | |
/// Simplified from upstream MLIR's foldDynamicIndexList: |
Nit, but IREE uses ///
for function/class comments.
// Based on upstream MLIR's | ||
// OpWithOffsetSizesAndStridesConstantArgumentFolder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Based on upstream MLIR's | |
// OpWithOffsetSizesAndStridesConstantArgumentFolder | |
/// Based on upstream MLIR's | |
/// OpWithOffsetSizesAndStridesConstantArgumentFolder |
Nit, but IREE uses /// for function/class comments.
// Build a NpuDmaCpyNdOp with mixed static and dynamic entries and target | ||
// and source BD IDs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Build a NpuDmaCpyNdOp with mixed static and dynamic entries and target | |
// and source BD IDs. | |
/// Build a NpuDmaCpyNdOp with mixed static and dynamic entries and target | |
/// and source BD IDs. |
Ok I'll use /// by default in future. As this particular file uses both /// and // quite a lot I'm not going to update this PR. |
Doubly strided ops have, for both source and target, and for all of offsets/sizes/strides, 2 fields:
For example it might be
The size of dynamic is always exactly equal to the number of appearances of kDynamic in the static vector. This pass does the following: it checks if any of the Values in dynamic are actually MLIR constants, and if they are then it removes the Value from the dynamic vector and updates the corresponding index in static. So for example if
v0
above is actuallythen this canonicalization updates dynamic/static to