Repository navigation
[NFC][mlir][bufferization] Remove getMemRefType() helper - #199034
Conversation
|
I guess we can start with this first and foremost. |
|
@llvm/pr-subscribers-mlir-bufferization Author: Andrei Golubev (andrey-golubev) ChangesThe implementation for a builtin TensorType's TensorLikeType interface is a bit overly complex for no reason: it calls 1 Files Affected:
diff --git a/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp
index bd177ba1afccd..b36aac8c68d36 100644
--- a/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp
+++ b/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp
@@ -48,7 +48,7 @@ struct BuiltinTensorExternalModel
return emitError() << "could not infer memory space";
return cast<BufferLikeType>(
- getMemRefType(tensorType, options, /*layout=*/{}, *memSpace));
+ options.unknownTypeConverterFn(tensorType, *memSpace, options));
}
mlir::LogicalResult verifyCompatibleBufferType(
|
|
@llvm/pr-subscribers-mlir Author: Andrei Golubev (andrey-golubev) ChangesThe implementation for a builtin TensorType's TensorLikeType interface is a bit overly complex for no reason: it calls 1 Files Affected:
diff --git a/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp
index bd177ba1afccd..b36aac8c68d36 100644
--- a/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp
+++ b/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp
@@ -48,7 +48,7 @@ struct BuiltinTensorExternalModel
return emitError() << "could not infer memory space";
return cast<BufferLikeType>(
- getMemRefType(tensorType, options, /*layout=*/{}, *memSpace));
+ options.unknownTypeConverterFn(tensorType, *memSpace, options));
}
mlir::LogicalResult verifyCompatibleBufferType(
|
Replace getMemRefType() helper with a direct usage of options.unknownTypeConverterFn() hook. This does not change any behaviour since all the existing call-sites would already implicitly call the hook. The major difference could have been in the handling of the memref layout but this does not seem to be properly handled anyhow.
24f007b to
1d2ee75
Compare
| /// Note: Canonicalization patterns could clean up layout maps and infer more | ||
| /// precise layout maps after bufferization. However, many possible | ||
| /// canonicalizations are currently not implemented. | ||
| BaseMemRefType getMemRefType(TensorType tensorType, |
There was a problem hiding this comment.
Can we keep this function? Some downstream projects (e.g. IREE) are using it. Alternatively, if we remove it, mention in the commit message how to fix the code.
There was a problem hiding this comment.
updated the PR description, would it be sufficient?
Replace getMemRefType() helper with a direct usage of options.unknownTypeConverterFn() hook. This does not change any behaviour since all the existing call-sites would already implicitly call the hook. The major difference could have been in the handling of the memref layout but this does not seem to be properly handled anyhow. As the `getMemRefType()` helper is removed, there are two cases to keep in mind for downstream users that need to adjust the code accordingly: 1. For creating memrefs without layouts, call `options.unknownTypeConverterFn` hook directly (the same way this patch is doing for upstream) 2. For creating memrefs with layouts (assuming, custom ones), please (re)implement the same helper. As only ranked memrefs can have a layout, a call to `mlir::MemRefType::get(shape, elementType, /*your custom layout=*/myLayout, memorySpace)` should be sufficient.
Replace getMemRefType() helper with a direct usage of options.unknownTypeConverterFn() hook. This does not change any behaviour since all the existing call-sites would already implicitly call the hook. The major difference could have been in the handling of the memref layout but this does not seem to be properly handled anyhow. As the `getMemRefType()` helper is removed, there are two cases to keep in mind for downstream users that need to adjust the code accordingly: 1. For creating memrefs without layouts, call `options.unknownTypeConverterFn` hook directly (the same way this patch is doing for upstream) 2. For creating memrefs with layouts (assuming, custom ones), please (re)implement the same helper. As only ranked memrefs can have a layout, a call to `mlir::MemRefType::get(shape, elementType, /*your custom layout=*/myLayout, memorySpace)` should be sufficient.
Replace getMemRefType() helper with a direct usage of options.unknownTypeConverterFn() hook. This does not change any behaviour since all the existing call-sites would already implicitly call the hook. The major difference could have been in the handling of the memref layout but this does not seem to be properly handled anyhow. As the `getMemRefType()` helper is removed, there are two cases to keep in mind for downstream users that need to adjust the code accordingly: 1. For creating memrefs without layouts, call `options.unknownTypeConverterFn` hook directly (the same way this patch is doing for upstream) 2. For creating memrefs with layouts (assuming, custom ones), please (re)implement the same helper. As only ranked memrefs can have a layout, a call to `mlir::MemRefType::get(shape, elementType, /*your custom layout=*/myLayout, memorySpace)` should be sufficient.
Replace getMemRefType() helper with a direct usage of options.unknownTypeConverterFn() hook. This does not change any behaviour since all the existing call-sites would already implicitly call the hook. The major difference could have been in the handling of the memref layout but this does not seem to be properly handled anyhow. As the `getMemRefType()` helper is removed, there are two cases to keep in mind for downstream users that need to adjust the code accordingly: 1. For creating memrefs without layouts, call `options.unknownTypeConverterFn` hook directly (the same way this patch is doing for upstream) 2. For creating memrefs with layouts (assuming, custom ones), please (re)implement the same helper. As only ranked memrefs can have a layout, a call to `mlir::MemRefType::get(shape, elementType, /*your custom layout=*/myLayout, memorySpace)` should be sufficient.
Replace getMemRefType() helper with a direct usage of options.unknownTypeConverterFn() hook. This does not change any behaviour since all the existing call-sites would already implicitly call the hook. The major difference could have been in the handling of the memref layout but this does not seem to be properly handled anyhow. As the `getMemRefType()` helper is removed, there are two cases to keep in mind for downstream users that need to adjust the code accordingly: 1. For creating memrefs without layouts, call `options.unknownTypeConverterFn` hook directly (the same way this patch is doing for upstream) 2. For creating memrefs with layouts (assuming, custom ones), please (re)implement the same helper. As only ranked memrefs can have a layout, a call to `mlir::MemRefType::get(shape, elementType, /*your custom layout=*/myLayout, memorySpace)` should be sufficient.
* [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]>
Replace getMemRefType() helper with a direct usage of options.unknownTypeConverterFn() hook. This does not change any behaviour since all the existing call-sites would already implicitly call the hook. The major difference could have been in the handling of the memref layout but this does not seem to be properly handled anyhow. As the `getMemRefType()` helper is removed, there are two cases to keep in mind for downstream users that need to adjust the code accordingly: 1. For creating memrefs without layouts, call `options.unknownTypeConverterFn` hook directly (the same way this patch is doing for upstream) 2. For creating memrefs with layouts (assuming, custom ones), please (re)implement the same helper. As only ranked memrefs can have a layout, a call to `mlir::MemRefType::get(shape, elementType, /*your custom layout=*/myLayout, memorySpace)` should be sufficient.
Replace getMemRefType() helper with a direct usage of options.unknownTypeConverterFn() hook. This does not change any behaviour since all the existing call-sites would already implicitly call the hook. The major difference could have been in the handling of the memref layout but this does not seem to be properly handled anyhow.
As the
getMemRefType()helper is removed, there are two cases to keep in mind for downstream users that need to adjust the code accordingly:options.unknownTypeConverterFnhook directly (the same way this patch is doing for upstream)mlir::MemRefType::get(shape, elementType, /*your custom layout=*/myLayout, memorySpace)should be sufficient.