Repository navigation
[Codegen] Crop partial reads instead of padding by a negative amount - #25330
Conversation
egebeysel
left a comment
There was a problem hiding this comment.
Why do we not have any regression tests? If the existing ones do not cover the additional behavior, I think it'd be nice to add some. Besides that LGTM % a few things my agent found that look reasonable.
| if (failed(paddedShape)) { | ||
| continue; | ||
| } | ||
| Value cropped = createCropToPaddedShape(builder, op.getLoc(), input->get(), |
There was a problem hiding this comment.
What guarantees that *paddedShape covers every element the op reads? With eight iterations, d1 floordiv 16 reads element zero every time, but the standalone masking pass crops tensor<1x1xf32> to tensor<1x0xf32> here and still succeeds. Could we bail out before changing any operands for maps the shape helper doesn’t support, and add this as a negative lit test?
|
|
||
| FailureOr<linalg::PadTilingInterfaceResult> result = | ||
| linalg::rewriteAsPaddedOp(b, tilingInterfaceOp, options); | ||
| cropAndPadTilingInterfaceOp(b, tilingInterfaceOp, options); |
There was a problem hiding this comment.
If the helper declines that map, LinalgGenericOpInterface::getMaskedImplementation still dereferences result->paddedOp. Can we check failed(result) there and return failure(), like the online attention model does? The outer pass already handles skipping the op
Padding an operation to tile-aligned sizes sizes each input to the region the padded loops read. A strided or dilated window can leave trailing elements of an input unread, so that region can be smaller than the input. The padding then needed a negative amount, which tensor.pad rejects, and compilation failed, for example for grouped convolutions on gfx942. Such inputs are now cropped to the region that is read before they are padded, wherever IREE pads operations through the TilingInterface. Signed-off-by: Jelle Schuhmacher <[email protected]> Assisted-by: Claude Code
Assisted-by: Claude Code Signed-off-by: Jelle Schühmacher <[email protected]>
3c02921 to
650fc13
Compare
|
Thanks @egebeysel! |
When padding an op to tile-aligned sizes, an input can be larger than the
region the padded loops read, for example when a strided window leaves the last
column unread. Padding it then needs a negative amount, and compilation fails:
Such inputs are now cropped with
tensor.extract_sliceto the region that isread, and then padded. The new
cropAndPadTilingInterfaceOphelper is used byGPUPadConvsandTensorMaskingOpInterface, so the fix applies to everybackend.
Assisted-by: Claude Code