Repository navigation
[MLIR] make One-Shot and SCF bufferization TensorLikeType-aware - #189073
Conversation
|
@llvm/pr-subscribers-mlir-scf @llvm/pr-subscribers-mlir Author: Dmitrii Makarenko (Devjiu) ChangesFix bufferization inconsistencies between builtin tensor types and custom TensorLikeType implementations across One-Shot analysis/module paths and SCF bufferization interfaces. The main issue was a mix of TensorType/RankedTensorType checks in places that need TensorLikeType-aware handling. This could leave function-boundary equivalence/aliasing incomplete for custom tensor-like types, leading to spurious SCF loop equivalence verification failures. This change:
Potential follow-ups / known risk areas:
Patch is 58.47 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/189073.diff 8 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
index c7775f2407ebd..c96309f3e81d5 100644
--- a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
+++ b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
@@ -25,21 +25,20 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
alias at runtime.
}];
let cppNamespace = "::mlir::bufferization";
- let methods = [
- InterfaceMethod<
- /*desc=*/[{
+ let methods =
+ [InterfaceMethod<
+ /*desc=*/[{
Return `true` if the given Value may bufferize to a new buffer
allocation. If it is statically unknown that the given Value
bufferizes to a buffer allocation, `true` should be returned.
}],
- /*retType=*/"bool",
- /*methodName=*/"bufferizesToAllocation",
- /*args=*/(ins "::mlir::Value":$value),
- /*methodBody=*/"",
- /*defaultImplementation=*/"return false;"
- >,
- InterfaceMethod<
- /*desc=*/[{
+ /*retType=*/"bool",
+ /*methodName=*/"bufferizesToAllocation",
+ /*args=*/(ins "::mlir::Value":$value),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/"return false;">,
+ InterfaceMethod<
+ /*desc=*/[{
Return `true` if the given OpOperand bufferizes to a memory read. This
method will never be called on OpOperands that do not have a tensor
type.
@@ -50,18 +49,18 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
considers OpOperands of unknown ops (that do not implement this
interface) as reading OpOperands.
}],
- /*retType=*/"bool",
- /*methodName=*/"bufferizesToMemoryRead",
- /*args=*/(ins "::mlir::OpOperand &":$opOperand,
- "const ::mlir::bufferization::AnalysisState &":$state),
- /*methodBody=*/"",
- /*defaultImplementation=*/[{
+ /*retType=*/"bool",
+ /*methodName=*/"bufferizesToMemoryRead",
+ /*args=*/
+ (ins "::mlir::OpOperand &":$opOperand,
+ "const ::mlir::bufferization::AnalysisState &":$state),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
// Does not have to be implemented for ops without tensor OpOperands.
llvm_unreachable("bufferizesToMemoryRead not implemented");
- }]
- >,
- InterfaceMethod<
- /*desc=*/[{
+ }]>,
+ InterfaceMethod<
+ /*desc=*/[{
Return `true` if the given OpOperand bufferizes to a memory write.
This method will never be called on OpOperands that do not have a
@@ -78,20 +77,20 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
considers OpOperands of unknown ops (that do not implement this
interface) as writing OpOperands.
}],
- /*retType=*/"bool",
- /*methodName=*/"bufferizesToMemoryWrite",
- /*args=*/(ins "::mlir::OpOperand &":$opOperand,
- "const ::mlir::bufferization::AnalysisState &":$state),
- /*methodBody=*/"",
- /*defaultImplementation=*/[{
+ /*retType=*/"bool",
+ /*methodName=*/"bufferizesToMemoryWrite",
+ /*args=*/
+ (ins "::mlir::OpOperand &":$opOperand,
+ "const ::mlir::bufferization::AnalysisState &":$state),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
// Does not have to be implemented for ops without tensor OpOperands.
// Does not have to be implemented for OpOperands that do not have an
// aliasing Value.
llvm_unreachable("bufferizesToMemoryWrite not implemented");
- }]
- >,
- InterfaceMethod<
- /*desc=*/[{
+ }]>,
+ InterfaceMethod<
+ /*desc=*/[{
Return `true` if the operation bufferizes to IR that performs only
element-wise accesses on the specified tensor operands. (The operands
must have the same shape.) The `bufferize` method must be implemented
@@ -135,18 +134,18 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
ignored. A conservative implementation of this interface method may
always return "false".
}],
- /*retType=*/"bool",
- /*methodName=*/"bufferizesToElementwiseAccess",
- /*args=*/(ins "const ::mlir::bufferization::AnalysisState &":$state,
- "::llvm::ArrayRef<::mlir::OpOperand *>":$opOperands),
- /*methodBody=*/"",
- /*defaultImplementation=*/[{
+ /*retType=*/"bool",
+ /*methodName=*/"bufferizesToElementwiseAccess",
+ /*args=*/
+ (ins "const ::mlir::bufferization::AnalysisState &":$state,
+ "::llvm::ArrayRef<::mlir::OpOperand *>":$opOperands),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
// It is always safe to assume that the op is not element-wise.
return false;
- }]
- >,
- InterfaceMethod<
- /*desc=*/[{
+ }]>,
+ InterfaceMethod<
+ /*desc=*/[{
Return `true` if the given OpResult bufferizes to a memory write.
This is the same property as `bufferizesToMemoryWrite`, but from The
perspective of OpResults.
@@ -191,20 +190,20 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
OpResult defined inside the scf.if op) bufferizes to a memory
write.
}],
- /*retType=*/"bool",
- /*methodName=*/"resultBufferizesToMemoryWrite",
- /*args=*/(ins "::mlir::OpResult":$opResult,
- "const ::mlir::bufferization::AnalysisState &":$state),
- /*methodBody=*/"",
- /*defaultImplementation=*/[{
+ /*retType=*/"bool",
+ /*methodName=*/"resultBufferizesToMemoryWrite",
+ /*args=*/
+ (ins "::mlir::OpResult":$opResult,
+ "const ::mlir::bufferization::AnalysisState &":$state),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
assert(opResult.getDefiningOp() == $_op.getOperation() &&
"invalid OpResult");
return ::mlir::bufferization::detail::defaultResultBufferizesToMemoryWrite(
opResult, state);
- }]
- >,
- InterfaceMethod<
- /*desc=*/[{
+ }]>,
+ InterfaceMethod<
+ /*desc=*/[{
Return `true` if the given OpOperand must bufferize in-place. Alias
sets and inplace attributes will be set up accordingly before making
any other bufferization decisions. This method will never be called on
@@ -214,17 +213,17 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
be extended in the future. Unranked tensors are used with external
functions only.
}],
- /*retType=*/"bool",
- /*methodName=*/"mustBufferizeInPlace",
- /*args=*/(ins "::mlir::OpOperand &":$opOperand,
- "const ::mlir::bufferization::AnalysisState &":$state),
- /*methodBody=*/"",
- /*defaultImplementation=*/[{
+ /*retType=*/"bool",
+ /*methodName=*/"mustBufferizeInPlace",
+ /*args=*/
+ (ins "::mlir::OpOperand &":$opOperand,
+ "const ::mlir::bufferization::AnalysisState &":$state),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
return ::llvm::isa<::mlir::UnrankedTensorType>(opOperand.get().getType());
- }]
- >,
- InterfaceMethod<
- /*desc=*/[{
+ }]>,
+ InterfaceMethod<
+ /*desc=*/[{
Return the Values that may alias with a given OpOperand when
bufferized in-place. This method will never be called on OpOperands
that do not have a tensor type.
@@ -280,20 +279,20 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
%r = "dummy.alias_or_copy(%t) : (tensor<10xf32>) -> (tensor<10xf32>)"
```
}],
- /*retType=*/"::mlir::bufferization::AliasingValueList",
- /*methodName=*/"getAliasingValues",
- /*args=*/(ins "::mlir::OpOperand &":$opOperand,
- "const ::mlir::bufferization::AnalysisState &":$state),
- /*methodBody=*/"",
- /*defaultImplementation=*/[{
+ /*retType=*/"::mlir::bufferization::AliasingValueList",
+ /*methodName=*/"getAliasingValues",
+ /*args=*/
+ (ins "::mlir::OpOperand &":$opOperand,
+ "const ::mlir::bufferization::AnalysisState &":$state),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
// Does not have to be implemented for ops without tensor OpOperands.
assert(::llvm::isa<::mlir::TensorType>(opOperand.get().getType()) &&
"expected OpOperand with tensor type");
llvm_unreachable("getAliasingValues not implemented");
- }]
- >,
- InterfaceMethod<
- /*desc=*/[{
+ }]>,
+ InterfaceMethod<
+ /*desc=*/[{
Return the OpOperands that alias with a given Value when bufferized
in-place. This method will never be called on Values that do not
have a tensor type.
@@ -352,20 +351,20 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
%r = tensor.empty() : tensor<10xf32>
```
}],
- /*retType=*/"::mlir::bufferization::AliasingOpOperandList",
- /*methodName=*/"getAliasingOpOperands",
- /*args=*/(ins "::mlir::Value":$value,
- "const ::mlir::bufferization::AnalysisState &":$state),
- /*methodBody=*/"",
- /*defaultImplementation=*/[{
- assert(isa<::mlir::TensorType>(value.getType()) &&
+ /*retType=*/"::mlir::bufferization::AliasingOpOperandList",
+ /*methodName=*/"getAliasingOpOperands",
+ /*args=*/
+ (ins "::mlir::Value":$value,
+ "const ::mlir::bufferization::AnalysisState &":$state),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
+ assert(isa<::mlir::bufferization::TensorLikeType>(value.getType()) &&
"expected tensor type");
return ::mlir::bufferization::detail::defaultGetAliasingOpOperands(
value, state);
- }]
- >,
- InterfaceMethod<
- /*desc=*/[{
+ }]>,
+ InterfaceMethod<
+ /*desc=*/[{
Resolve all inplacability conflicts by inserting explicit
`bufferization.alloc_tensor` ops. Examples of inplacability conflicts
are read-after-write conflicts or writes into non-writable buffers.
@@ -378,21 +377,22 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
This method can query analysis information from the given analysis
state.
}],
- /*retType=*/"::llvm::LogicalResult",
- /*methodName=*/"resolveConflicts",
- /*args=*/(ins "::mlir::RewriterBase &":$rewriter,
- "const ::mlir::bufferization::AnalysisState &":$analysisState,
- "const ::mlir::bufferization::BufferizationState &":$bufferizationState),
- /*methodBody=*/"",
- /*defaultImplementation=*/[{
+ /*retType=*/"::llvm::LogicalResult",
+ /*methodName=*/"resolveConflicts",
+ /*args=*/
+ (ins "::mlir::RewriterBase &":$rewriter,
+ "const ::mlir::bufferization::AnalysisState &":$analysisState,
+ "const ::mlir::bufferization::BufferizationState "
+ "&":$bufferizationState),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
auto bufferizableOp =
::llvm::cast<BufferizableOpInterface>($_op.getOperation());
return bufferizableOp.resolveTensorOpOperandConflicts(
rewriter, analysisState, bufferizationState);
- }]
- >,
- InterfaceMethod<
- /*desc=*/[{
+ }]>,
+ InterfaceMethod<
+ /*desc=*/[{
Bufferize this op, i.e., rewrite it into a memref-based equivalent.
Buffers of tensor SSA values can be retrieved via `getBuffer`.
Uses of tensor results of the existing tensor op can be replaced with
@@ -429,19 +429,19 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
suggestion to make sure IR is valid at every point in time and could
be done differently).
}],
- /*retType=*/"::llvm::LogicalResult",
- /*methodName=*/"bufferize",
- /*args=*/(ins "::mlir::RewriterBase &":$rewriter,
- "const ::mlir::bufferization::BufferizationOptions &":$options,
- "::mlir::bufferization::BufferizationState &":$state),
- /*methodBody=*/"",
- /*defaultImplementation=*/[{
+ /*retType=*/"::llvm::LogicalResult",
+ /*methodName=*/"bufferize",
+ /*args=*/
+ (ins "::mlir::RewriterBase &":$rewriter,
+ "const ::mlir::bufferization::BufferizationOptions &":$options,
+ "::mlir::bufferization::BufferizationState &":$state),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
llvm_unreachable("bufferize not implemented");
return ::mlir::failure();
- }]
- >,
- InterfaceMethod<
- /*desc=*/[{
+ }]>,
+ InterfaceMethod<
+ /*desc=*/[{
Return `true` if the given Value can be written to in-place. Value is
either an OpResult of this operation or a BlockArgument of a block of
this operation.
@@ -456,17 +456,17 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
operation. This method conservatively returns `false`. This method
will never be called on BlockArguments that do not have a tensor type.
}],
- /*retType=*/"bool",
- /*methodName=*/"isWritable",
- /*args=*/(ins "::mlir::Value":$value,
- "const ::mlir::bufferization::AnalysisState &":$state),
- /*methodBody=*/"",
- /*defaultImplementation=*/[{
+ /*retType=*/"bool",
+ /*methodName=*/"isWritable",
+ /*args=*/
+ (ins "::mlir::Value":$value,
+ "const ::mlir::bufferization::AnalysisState &":$state),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
return ::llvm::isa<::mlir::OpResult>(value);
- }]
- >,
- InterfaceMethod<
- /*desc=*/[{
+ }]>,
+ InterfaceMethod<
+ /*desc=*/[{
Return `true` if the `uRead` and `uWrite` do not constitute a RaW
conflict. If they are conflicting or if it is unknown whether they are
conflicting, return `false`. This method will never be called with
@@ -478,18 +478,17 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
to be conflicting and do not force out-of-place bufferization. (There
may still be other conflicts that do.)
}],
- /*retType=*/"bool",
- /*methodName=*/"isNotConflicting",
- /*args=*/(ins "::mlir::OpOperand *":$uRead,
- "::mlir::OpOperand *":$uWrite,
- "const ::mlir::bufferization::AnalysisState &":$state),
- /*methodBody=*/"",
- /*defaultImplementation=*/[{
+ /*retType=*/"bool",
+ /*methodName=*/"isNotConflicting",
+ /*args=*/
+ (ins "::mlir::OpOperand *":$uRead, "::mlir::OpOperand *":$uWrite,
+ "const ::mlir::bufferization::AnalysisState &":$state),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
return false;
- }]
- >,
- InterfaceMethod<
- /*desc=*/[{
+ }]>,
+ InterfaceMethod<
+ /*desc=*/[{
Return `failure` if this op does not pass the analysis. This method
is run during One-Shot Bufferize (after all post-analysis steps). If
the op does not pass the analysis, bufferization is aborted.
@@ -497,16 +496,15 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
This method can be used to check expected invariants and limitations
of the current bufferization implementation.
}],
- /*retType=*/"::llvm::LogicalResult",
- /*methodName=*/"verifyAnalysis",
- /*args=*/(ins "const ::mlir::bufferization::AnalysisState &":$state),
- /*methodBody=*/"",
- /*defaultImplementation=*/[{
+ /*retType=*/"::llvm::LogicalResult",
+ /*methodName=*/"verifyAnalysis",
+ /*args=*/(ins "const ::mlir::bufferization::AnalysisState &":$state),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
return ::mlir::success();
- }]
- >,
- InterfaceMethod<
- /*desc=*/[{
+ }]>,
+ InterfaceMethod<
+ /*desc=*/[{
Return the bufferized type of the given tensor value (without
bufferizing the IR). The value is either a BlockArgument of a block
that belongs to this op or an OpResult of the given op.
@@ -525,24 +523,25 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
Note: This interface method should never be called directly from user
code. Always use `bufferization::getBufferType`.
}],
- /*retType=*/"::mlir::FailureOr<::mlir::bufferization::BufferLikeType>",
- /*methodName=*/"getBufferType",
- /*args=*/(ins "::mlir::Value":$value,
- "const ::mlir::bufferization::BufferizationOptions &":$options,
- "const ::mlir::bufferization::BufferizationState &":$state,
- "::llvm::SmallVector<::mlir::Value> &":$invocationStack),
- /*methodBody=*/"",
- /*defaultImplementation=*/[{
+ /*retType=*/
+ "::mlir::FailureOr<::mlir::bufferization::BufferLikeType>",
+ /*methodName=*/"getBufferType",
+ /*args=*/
+ (ins "::mlir::Value":$value,
+ "const ::mlir::bufferization::BufferizationOptions &":$options,
+ "const ::mlir::bufferization::BufferizationState &":$state,
+ "::llvm::SmallVector<::mlir::Value> &":$invocationStack),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
assert(getOwnerOfValue(value) == $_op.getOperation() &&
"expected that value belongs to this op");
assert(invocationStack.back() == value &&
"inconsistant invocation stack");
return ::mlir::bufferization::detail::defaultGetBufferType(
value, options, state, invocationStack);
- }]
- >,
- InterfaceMethod<
- /*desc=*/[{
+ }]>,
+ InterfaceMethod<
+ /*desc=*/[{
Return `true` if the given region of this op is repetitive. By default
this information is queried from the `RegionBranchOpInterface`. Ops
that do not implement this inferface can override this method to
@@ -555,17 +554,16 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
that are executed multiple times. This is described in more detail in
documentation of One-Shot Analysis.
}],
- /*retType=*/"bool",
- /*methodName=*/"isRepetitiveRegion",
- /*args=*/(ins "unsigned":$index),
- /*methodBody=*/"",
- /*defaultImplementation=*/[{
+ /*retType=*/"bool",
+ /*methodName=*/"isRepetitiveRegion",
+ /*args=*/(ins "unsigned":$index),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
return ::mlir::bufferization::detail::defaultIsRepetitiveRegion(
::llvm::cast<BufferizableOpInterface>($_op.getOperation()), index);
- }]
- >,
- InterfaceMet...
[truncated]
|
|
@matthias-springer This pr is an extension of the work that was done in PR #159766 and several similar ones. Also, I wanted to add a custom TensorLikeType coverage test for Could you clarify if the current |
matthias-springer
left a comment
There was a problem hiding this comment.
Overall, this makes sense to me. For changes to scf.forall, please reach out @Groverkss or @MaheshRavishankar.
| @@ -25,21 +25,20 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> { | |||
| alias at runtime. | |||
| }]; | |||
| let cppNamespace = "::mlir::bufferization"; | |||
| let methods = [ | |||
| InterfaceMethod< | |||
There was a problem hiding this comment.
Can you undo these indentation changes? They make it difficult to review this PR. There also seem to be some inconsistencies in the indentation now.
ee09aea to
7115bfb
Compare
|
@matthias-springer, gentle reminder to take a look |
|
@matthias-springer, reminder to take a look. Sorry for pinging |
|
@matthias-springer ping to take a look |
38194ab to
5e60afb
Compare
| return op->emitError("inconsistent memory space on then/else branches"); | ||
|
|
||
| // Layout maps are different: Promote to fully dynamic layout map. | ||
| return cast<BufferLikeType>(getMemRefTypeWithFullyDynamicLayout( |
There was a problem hiding this comment.
Add a TODO here that this part of the implementation is still hard-coded to memref.
There was a problem hiding this comment.
Added, please check. I hope all suspicious points are covered with TODO
Fix bufferization inconsistencies between builtin tensor types and custom TensorLikeType implementations across One-Shot analysis/module paths and SCF bufferization interfaces. The main issue was a mix of TensorType/RankedTensorType checks in places that need TensorLikeType-aware handling. This could leave function-boundary equivalence/aliasing incomplete for custom tensor-like types, leading to spurious SCF loop equivalence verification failures. This change: - switches relevant One-Shot analysis/module checks from TensorType/ RankedTensorType to TensorLikeType; - updates generic/default aliasing utilities to treat TensorLikeType consistently; - updates SCF BufferizableOpInterface implementations (for/while/if/yield related paths) to use TensorLikeType/BufferLikeType where appropriate; - updates test custom ops to provide required aliasing/getBufferType hooks for custom tensor-like types; - refreshes and renames custom_types SCF tests to explicitly check memref replacement after bufferization. Potential follow-ups / known risk areas: - SCF.Forall shared_outs still has RankedTensorType assumptions in signatures/ paths and should be audited for full TensorLikeType coverage. - SCF.For and SCF.While resolveConflicts call allocateTensorForShapedValue, which currently assumes ranked tensor/memref copy paths; this may still be a limitation for some tensor-like/unranked scenarios. Signed-off-by: Dmitrii Makarenko <[email protected]>
47c5bc1 to
8f6f535
Compare
|
@matthias-springer Sorry for the extra ping, and thank you for taking a look. |
…#189073) Fix bufferization inconsistencies between builtin tensor types and custom TensorLikeType implementations across One-Shot analysis/module paths and SCF bufferization interfaces. The main issue was a mix of TensorType/RankedTensorType checks in places that need TensorLikeType-aware handling. This could leave function-boundary equivalence/aliasing incomplete for custom tensor-like types, leading to spurious SCF loop equivalence verification failures. This change: - switches relevant One-Shot analysis/module checks from TensorType/ RankedTensorType to TensorLikeType; - updates generic/default aliasing utilities to treat TensorLikeType consistently; - updates SCF BufferizableOpInterface implementations (for/while/if/yield related paths) to use TensorLikeType/BufferLikeType where appropriate; - updates test custom ops to provide required aliasing/getBufferType hooks for custom tensor-like types; - refreshes and renames custom_types SCF tests to explicitly check memref replacement after bufferization. Potential follow-ups / known risk areas: - SCF.Forall shared_outs still has RankedTensorType assumptions in signatures/ paths and should be audited for full TensorLikeType coverage. - SCF.For and SCF.While resolveConflicts call allocateTensorForShapedValue, which currently assumes ranked tensor/memref copy paths; this may still be a limitation for some tensor-like/unranked scenarios. --------- Signed-off-by: Dmitrii Makarenko <[email protected]>
- Add missing BufferizableOpInterface methods to DispatchTensorLoadOp. Due to llvm/llvm-project#189073 changed One-Shot Analysis, module bufferize, and SCF bufferization to use TensorLikeType instead of TensorType. - Upgrade to Bazel 8.6.0 to align with LLVM. As llvm/llvm-project#192518 bumped rules_python from 1.6.3 to 1.9.0 Assisted-by: Cursor (Claude) --------- Signed-off-by: Yu-Zhewen <[email protected]>
- Add missing BufferizableOpInterface methods to DispatchTensorLoadOp. Due to llvm/llvm-project#189073 changed One-Shot Analysis, module bufferize, and SCF bufferization to use TensorLikeType instead of TensorType. - Upgrade to Bazel 8.6.0 to align with LLVM. As llvm/llvm-project#192518 bumped rules_python from 1.6.3 to 1.9.0 Assisted-by: Cursor (Claude) --------- Signed-off-by: Yu-Zhewen <[email protected]>
- Add missing BufferizableOpInterface methods to DispatchTensorLoadOp. Due to llvm/llvm-project#189073 changed One-Shot Analysis, module bufferize, and SCF bufferization to use TensorLikeType instead of TensorType. - Upgrade to Bazel 8.6.0 to align with LLVM. As llvm/llvm-project#192518 bumped rules_python from 1.6.3 to 1.9.0 Assisted-by: Cursor (Claude) --------- Signed-off-by: Yu-Zhewen <[email protected]>
…#189073) Fix bufferization inconsistencies between builtin tensor types and custom TensorLikeType implementations across One-Shot analysis/module paths and SCF bufferization interfaces. The main issue was a mix of TensorType/RankedTensorType checks in places that need TensorLikeType-aware handling. This could leave function-boundary equivalence/aliasing incomplete for custom tensor-like types, leading to spurious SCF loop equivalence verification failures. This change: - switches relevant One-Shot analysis/module checks from TensorType/ RankedTensorType to TensorLikeType; - updates generic/default aliasing utilities to treat TensorLikeType consistently; - updates SCF BufferizableOpInterface implementations (for/while/if/yield related paths) to use TensorLikeType/BufferLikeType where appropriate; - updates test custom ops to provide required aliasing/getBufferType hooks for custom tensor-like types; - refreshes and renames custom_types SCF tests to explicitly check memref replacement after bufferization. Potential follow-ups / known risk areas: - SCF.Forall shared_outs still has RankedTensorType assumptions in signatures/ paths and should be audited for full TensorLikeType coverage. - SCF.For and SCF.While resolveConflicts call allocateTensorForShapedValue, which currently assumes ranked tensor/memref copy paths; this may still be a limitation for some tensor-like/unranked scenarios. --------- Signed-off-by: Dmitrii Makarenko <[email protected]>
…#189073) Fix bufferization inconsistencies between builtin tensor types and custom TensorLikeType implementations across One-Shot analysis/module paths and SCF bufferization interfaces. The main issue was a mix of TensorType/RankedTensorType checks in places that need TensorLikeType-aware handling. This could leave function-boundary equivalence/aliasing incomplete for custom tensor-like types, leading to spurious SCF loop equivalence verification failures. This change: - switches relevant One-Shot analysis/module checks from TensorType/ RankedTensorType to TensorLikeType; - updates generic/default aliasing utilities to treat TensorLikeType consistently; - updates SCF BufferizableOpInterface implementations (for/while/if/yield related paths) to use TensorLikeType/BufferLikeType where appropriate; - updates test custom ops to provide required aliasing/getBufferType hooks for custom tensor-like types; - refreshes and renames custom_types SCF tests to explicitly check memref replacement after bufferization. Potential follow-ups / known risk areas: - SCF.Forall shared_outs still has RankedTensorType assumptions in signatures/ paths and should be audited for full TensorLikeType coverage. - SCF.For and SCF.While resolveConflicts call allocateTensorForShapedValue, which currently assumes ranked tensor/memref copy paths; this may still be a limitation for some tensor-like/unranked scenarios. --------- Signed-off-by: Dmitrii Makarenko <[email protected]>
…#189073) Fix bufferization inconsistencies between builtin tensor types and custom TensorLikeType implementations across One-Shot analysis/module paths and SCF bufferization interfaces. The main issue was a mix of TensorType/RankedTensorType checks in places that need TensorLikeType-aware handling. This could leave function-boundary equivalence/aliasing incomplete for custom tensor-like types, leading to spurious SCF loop equivalence verification failures. This change: - switches relevant One-Shot analysis/module checks from TensorType/ RankedTensorType to TensorLikeType; - updates generic/default aliasing utilities to treat TensorLikeType consistently; - updates SCF BufferizableOpInterface implementations (for/while/if/yield related paths) to use TensorLikeType/BufferLikeType where appropriate; - updates test custom ops to provide required aliasing/getBufferType hooks for custom tensor-like types; - refreshes and renames custom_types SCF tests to explicitly check memref replacement after bufferization. Potential follow-ups / known risk areas: - SCF.Forall shared_outs still has RankedTensorType assumptions in signatures/ paths and should be audited for full TensorLikeType coverage. - SCF.For and SCF.While resolveConflicts call allocateTensorForShapedValue, which currently assumes ranked tensor/memref copy paths; this may still be a limitation for some tensor-like/unranked scenarios. --------- Signed-off-by: Dmitrii Makarenko <[email protected]>
…#189073) Fix bufferization inconsistencies between builtin tensor types and custom TensorLikeType implementations across One-Shot analysis/module paths and SCF bufferization interfaces. The main issue was a mix of TensorType/RankedTensorType checks in places that need TensorLikeType-aware handling. This could leave function-boundary equivalence/aliasing incomplete for custom tensor-like types, leading to spurious SCF loop equivalence verification failures. This change: - switches relevant One-Shot analysis/module checks from TensorType/ RankedTensorType to TensorLikeType; - updates generic/default aliasing utilities to treat TensorLikeType consistently; - updates SCF BufferizableOpInterface implementations (for/while/if/yield related paths) to use TensorLikeType/BufferLikeType where appropriate; - updates test custom ops to provide required aliasing/getBufferType hooks for custom tensor-like types; - refreshes and renames custom_types SCF tests to explicitly check memref replacement after bufferization. Potential follow-ups / known risk areas: - SCF.Forall shared_outs still has RankedTensorType assumptions in signatures/ paths and should be audited for full TensorLikeType coverage. - SCF.For and SCF.While resolveConflicts call allocateTensorForShapedValue, which currently assumes ranked tensor/memref copy paths; this may still be a limitation for some tensor-like/unranked scenarios. --------- Signed-off-by: Dmitrii Makarenko <[email protected]>
* [mlir][RFC] Allow to skip operands type specification in ASM form * Add FlatSymbolRefAttr and ArrayAttr for memory space representation (llvm#44/llvm#45) * [mlir] Relax ASM parser requirements about operands Type presence * [mlir] Remove LIT tests affected by ASM simplification * Add method getInlineBlockAndPoint for DialectInlinerInterface * Initialize pass options using pipeline options * Fix compilation issue with MSVC * Port Ubunu-24 warning fixes to npu/release/18.x (llvm#45) * Extend Quant dialect with Quantile Quantization type (llvm#53) * Extending QuantileQuantizedType with quantileType mlir::Type member (llvm#60) * Relax negative scales conditions in Quant Dialect (llvm#61) * Adding missing check in QuantileQuantizedPerAxisType::verify (llvm#66) * Adding new quantileType types to mlir test (llvm#85) * Add Value back to SideEffectInterfaces * EISW-130780: remove all wd flag to enable warnings when LLVM_ENABLE_WARNINGS is ON (llvm#99) * EISW-176770 Fix argument parsing issue in mlir-src-sharder after command-line parser reset * Enable quantization for FP4 type * [MLIR] Make printing Value to a stream thread-safe (llvm#185762) * [MLIR] Fix mlir-doc build failures by adding -dialect to add_mlir_doc calls * [MLIR] Add getter for the action handler of MLIR context (llvm#197230) * Silence deprecation warning for OpBuilder::create * [MLIR] make One-Shot and SCF bufferization TensorLikeType-aware (llvm#189073) * [NFC][mlir][bufferization] Remove getMemRefType() helper (llvm#199034) * [mlir][bufferization] Drop TensorLikeType::getBufferType() (llvm#201350) --------- Signed-off-by: Gladilov, Gleb <[email protected]> Signed-off-by: Zhu, Shaojie <[email protected]> Signed-off-by: Dmitrii Makarenko <[email protected]> Co-authored-by: Vladislav Vinogradov <[email protected]> Co-authored-by: Nikita Kudriavtsev <[email protected]> Co-authored-by: Schondube, Jorn <[email protected]> Co-authored-by: Daria Mityagina <[email protected]> Co-authored-by: Luca Sarti <[email protected]> Co-authored-by: Zoran Zomborat <[email protected]> Co-authored-by: Ngun, Raymond <[email protected]> Co-authored-by: Shaojie Zhu <[email protected]> Co-authored-by: Surendar Rama Sitaraman <[email protected]> Co-authored-by: Andruszkiewicz, Jacenty <[email protected]> Co-authored-by: Mehdi Amini <[email protected]> Co-authored-by: Kigyosi Alexandru <[email protected]> Co-authored-by: Dmitrii Makarenko <[email protected]> Co-authored-by: Andrei Golubev <[email protected]>
…#189073) Fix bufferization inconsistencies between builtin tensor types and custom TensorLikeType implementations across One-Shot analysis/module paths and SCF bufferization interfaces. The main issue was a mix of TensorType/RankedTensorType checks in places that need TensorLikeType-aware handling. This could leave function-boundary equivalence/aliasing incomplete for custom tensor-like types, leading to spurious SCF loop equivalence verification failures. This change: - switches relevant One-Shot analysis/module checks from TensorType/ RankedTensorType to TensorLikeType; - updates generic/default aliasing utilities to treat TensorLikeType consistently; - updates SCF BufferizableOpInterface implementations (for/while/if/yield related paths) to use TensorLikeType/BufferLikeType where appropriate; - updates test custom ops to provide required aliasing/getBufferType hooks for custom tensor-like types; - refreshes and renames custom_types SCF tests to explicitly check memref replacement after bufferization. Potential follow-ups / known risk areas: - SCF.Forall shared_outs still has RankedTensorType assumptions in signatures/ paths and should be audited for full TensorLikeType coverage. - SCF.For and SCF.While resolveConflicts call allocateTensorForShapedValue, which currently assumes ranked tensor/memref copy paths; this may still be a limitation for some tensor-like/unranked scenarios. --------- Signed-off-by: Dmitrii Makarenko <[email protected]>
…emrefs The copies that One-Shot Bufferize inserts for out-of-place operands and for loop yields are built by `allocateTensorForShapedValue`, which handled only builtin ranked tensors and memrefs: any other tensor-like value (llvm#134220) reached an `llvm_unreachable`. `resolveTensorOpOperandConflicts` skipped every operand that is not a builtin tensor, so an out-of-place operand of another tensor-like type silently got no copy. Both spots carry the TODO "Properly support with options, for now it is hardcoded to builtin Tensor/MemRef types based approach" from llvm#189073, which continued the custom-type support of llvm#142986. This patch narrows that TODO: - `bufferization.alloc_tensor` takes and produces any `TensorLikeType`. The size helpers keep their signatures and additionally assert a ranked tensor result. The verifier accepts dynamic sizes and a size hint only for a ranked tensor result; shape reification and both canonicalization patterns check for one. The builders route through one that takes the declared `TensorLikeType`. The buffer type of a result that is not a builtin ranked tensor comes from `unknownTypeConverterFn` (as in llvm#201350). - `allocateTensorForShapedValue` copies any tensor-like value, and `resolveTensorOpOperandConflicts` resolves every tensor-like operand. What remains, each a diagnostic with a TODO: the allocation hook still takes a `MemRefType`, so a buffer type that is not a memref is reported rather than allocated; and a value that is not a builtin tensor is allocated only as a copy, because its dynamic extents cannot be read before bufferization. Tests: test-one-shot-module-bufferize-copies.mlir runs `-test-one-shot-module-bufferize` with two new options, `allow-return-allocs-from-loops` and `test-tensor-to-memref` (buffers of `!test.test_tensor` become builtin memrefs), on a `scf.for` that yields a value defined outside the loop and on an operand conflict that needs a copy. invalid.mlir checks the new verifier message. Note for LLVM integration: `AllocTensorOp::getType()` is now the generated accessor and returns `TensorLikeType` instead of `RankedTensorType`. No hook signature changes. Code and tests in this change were written with Claude Code. Carried on integration-23 from the branch bufferization-alloc-tensor-tensorlike (b45b943 on upstream main). At 23.1.4 the alloc_tensor model is op methods in IR/BufferizationOps.cpp rather than an external model in Transforms/BufferizableOpInterfaceImpl.cpp; the model's hunks land there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…emrefs The copies that One-Shot Bufferize inserts for out-of-place operands and for loop yields are built by `allocateTensorForShapedValue`, which handled only builtin ranked tensors and memrefs: any other tensor-like value (llvm#134220) reached an `llvm_unreachable`. `resolveTensorOpOperandConflicts` skipped every operand that is not a builtin tensor, so an out-of-place operand of another tensor-like type silently got no copy. Both spots carry the TODO "Properly support with options, for now it is hardcoded to builtin Tensor/MemRef types based approach" from llvm#189073, which continued the custom-type support of llvm#142986. This patch narrows that TODO: - `bufferization.alloc_tensor` takes and produces any `TensorLikeType`. The size helpers keep their signatures and additionally assert a ranked tensor result. The verifier accepts dynamic sizes and a size hint only for a ranked tensor result; shape reification and both canonicalization patterns check for one. The builders route through one that takes the declared `TensorLikeType`. The buffer type of a result that is not a builtin ranked tensor comes from `unknownTypeConverterFn` (as in llvm#201350). - `allocateTensorForShapedValue` copies any tensor-like value, and `resolveTensorOpOperandConflicts` resolves every tensor-like operand. What remains, each a diagnostic with a TODO: the allocation hook still takes a `MemRefType`, so a buffer type that is not a memref is reported rather than allocated; and a value that is not a builtin tensor is allocated only as a copy, because its dynamic extents cannot be read before bufferization. Tests: test-one-shot-module-bufferize-copies.mlir runs `-test-one-shot-module-bufferize` with two new options, `allow-return-allocs-from-loops` and `test-tensor-to-memref` (buffers of `!test.test_tensor` become builtin memrefs), on a `scf.for` that yields a value defined outside the loop and on an operand conflict that needs a copy. invalid.mlir checks the new verifier message. Note for LLVM integration: `AllocTensorOp::getType()` is now the generated accessor and returns `TensorLikeType` instead of `RankedTensorType`. No hook signature changes. Code and tests in this change were written with Claude Code. Carried on integration-23 from the branch bufferization-alloc-tensor-tensorlike (b45b943 on upstream main). At 23.1.4 the alloc_tensor model is op methods in IR/BufferizationOps.cpp rather than an external model in Transforms/BufferizableOpInterfaceImpl.cpp; the model's hunks land there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fix bufferization inconsistencies between builtin tensor types and custom TensorLikeType implementations across One-Shot analysis/module paths and SCF bufferization interfaces.
The main issue was a mix of TensorType/RankedTensorType checks in places that need TensorLikeType-aware handling. This could leave function-boundary equivalence/aliasing incomplete for custom tensor-like types, leading to spurious SCF loop equivalence verification failures.
This change:
Potential follow-ups / known risk areas: