| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
Switch member calls to isa/dyn_cast/cast/... to free function calls. (#89356) This change cleans up call sites. Next step is to mark the member functions deprecated. See https://mlir.llvm.org/deprecation and https://discourse.llvm.org/t/preferred-casting-style-going-forward. | 2 年前 | |
[mlir] Fix shared builds. NFC | 2 年前 | |
[mlir][llvm] Port overflowFlags to a native operation property (RELAND) (#89410) This PR changes the LLVM dialect's IntegerOverflowFlags to be stored on operations as native properties. Reland to fix flang | 2 年前 | |
[mlir][amdgpu] Add support for multi-dim arith.truncf/extf fp8 lowering (#98074) The existing fp8 lowering from arith to amdgpu bails out on the multidimensional case. We can handle this by vector.shape_cast collapsing to the 1-D case on extraction and re-casting back to the desired output shape. | 2 年前 | |
[mlir][ArmSME] Add arith-to-arm-sme conversion pass (#78197) Existing 'arith::ConstantOp' conversion and tests are moved from VectorToArmSME. There's currently only a single op that's converted at the moment, but this will grow in the future as things like in-tile add are implemented. Also, 'createLoopOverTileSlices' is moved to ArmSME utils since it's relevant for both conversions. | 2 年前 | |
[mlir][emitc] Lower arith.index_cast, arith.index_castui, arith.shli, arith.shrui, arith.shrsi (#95795) This PR makes use of the newly introduced EmitC types, and lowers: * ops dealing with index types (index_cast, index_castui), * ops where size_t is used as part of the lowering (shli, shrui, shrsi, to check for overflow and avoid UB in this case). | 2 年前 | |
[MLIR][Arith] Add rounding mode attribute to truncf (#86152) Add rounding mode attribute to arith. This attribute can be used in different FP arith operations to control rounding mode. Rounding modes correspond to IEEE 754-specified rounding modes. Use in arith.truncf folding. As this is not supported in dialects other than LLVM, conversion should fail for now in case this attribute is present. --------- Signed-off-by: Victor Perez <victor.perez@codeplay.com> | 2 年前 | |
[mlir][spirv] Add support for dense_resource in arith to spirv (#91318) This adds support for dense_resource in arith to spirv. Note that this inlines the blob into the IR. Another possibility would be to add proper dense_resource support to spirv, but there is a lot of special handling going on to convert a DenseElementsAttr to the correct SPIRV type. Some of that even iterates over all the values in the Attribute. For proper support of a DenseResourceElementsAttr this probably needs a redesign. I would like to hear some opinions on that! The test is disabled on non little Endian machines. See https://github.com/llvm/llvm-project/issues/63469 for more information. | 2 年前 | |
[mlir] Move casting calls from methods to function calls The MLIR classes Type/Attribute/Operation/Op/Value support cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast functionality in addition to defining methods with the same name. This change begins the migration of uses of the method to the corresponding function call as has been decided as more consistent. Note that there still exist classes that only define methods directly, such as AffineExpr, and this does not include work currently to support a functional cast/isa call. Caveats include: - This clang-tidy script probably has more problems. - This only touches C++ code, so nothing that is being generated. Context: - https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…" - Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443 Implementation: This first patch was created with the following steps. The intention is to only do automated changes at first, so I waste less time if it's reverted, and so the first mass change is more clear as an example to other teams that will need to follow similar steps. Steps are described per line, as comments are removed by git: 0. Retrieve the change from the following to build clang-tidy with an additional check: https://github.com/llvm/llvm-project/compare/main...tpopp:llvm-project:tidy-cast-check 1. Build clang-tidy 2. Run clang-tidy over your entire codebase while disabling all checks and enabling the one relevant one. Run on all header files also. 3. Delete .inc files that were also modified, so the next build rebuilds them to a pure state. 4. Some changes have been deleted for the following reasons: - Some files had a variable also named cast - Some files had not included a header file that defines the cast functions - Some files are definitions of the classes that have the casting methods, so the code still refers to the method instead of the function without adding a prefix or removing the method declaration at the same time. ninja -C $BUILD_DIR clang-tidy run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\ -header-filter=mlir/ mlir/* -fix rm -rf $BUILD_DIR/tools/mlir/**/*.inc git restore mlir/lib/IR mlir/lib/Dialect/DLTI/DLTI.cpp\ mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp\ mlir/lib/**/IR/\ mlir/lib/Dialect/SparseTensor/Transforms/SparseVectorization.cpp\ mlir/lib/Dialect/Vector/Transforms/LowerVectorMultiReduction.cpp\ mlir/test/lib/Dialect/Test/TestTypes.cpp\ mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp\ mlir/test/lib/Dialect/Test/TestAttributes.cpp\ mlir/unittests/TableGen/EnumsGenTest.cpp\ mlir/test/python/lib/PythonTestCAPI.cpp\ mlir/include/mlir/IR/ Differential Revision: https://reviews.llvm.org/D150123 | 3 年前 | |
[mlir][ArmSME] Reword in-memory tile warning (NFC) (#92415) It did not make sense that this said "all tile operations will go through memory". Only the operations where the warning is emitted will go through memory. The message has been updated to reflect that. | 2 年前 | |
[mlir][ArmSME] Use liveness information in the tile allocator (#90448) This patch rewrites the ArmSME tile allocator to use liveness information to make better tile allocation decisions and improve the correctness of the ArmSME dialect. This algorithm used here is a linear scan over live ranges, where live ranges are assigned to tiles as they appear in the program (chronologically). Live ranges release their assigned tile ID when the current program point is passed their end. This is a greedy algorithm (which is mainly to keep the implementation relatively straightforward), and because it seems to be sufficient for most kernels (e.g. matmuls) that use ArmSME. The general steps of this are roughly from https://link.springer.com/content/pdf/10.1007/3-540-45937-5_17.pdf, though there have been a few simplifications and assumptions made for our use case. Hopefully, the only changes needed for a user of the ArmSME dialect is that: - -allocate-arm-sme-tiles will no longer be a standalone pass - -test-arm-sme-tile-allocation is only for unit tests - -convert-arm-sme-to-llvm must happen after -convert-scf-to-cf - SME tile allocation is now part of the LLVM conversion By integrating this into the ArmSME -> LLVM conversion we can allow high-level (value-based) ArmSME operations to be side-effect-free, as we can guarantee nothing will rearrange ArmSME operations before we emit intrinsics (which could invalidate the tile allocation). The hope is for ArmSME operations to have no hidden state/side effects and allow easily lowering dialects such as vector and arith to SME, without making assumptions about how the input IR looks, as the semantics of the operations will be the same. That is no (new) side effects and the IR follows the rules of SSA (a value will never change). The aim is correctness, so we have a base for working on optimizations. | 2 年前 | |
[mlir] Use OpBuilder::createBlock in op builders and patterns (#82770) When creating a new block in (conversion) rewrite patterns, OpBuilder::createBlock must be used. Otherwise, no notifyBlockInserted notification is sent to the listener. Note: The dialect conversion relies on listener notifications to keep track of IR modifications. Creating blocks without the builder API can lead to memory leaks during rollback. | 2 年前 | |
[mlir] [bufferize] fix bufferize deallocation error in nest symbol table (#98476) In nested symbols, the dealloc_helper function generated by lower deallocations pass was incorrectly positioned, causing calls fail. This patch fixes this issue. | 2 年前 | |
Apply clang-tidy fixes for llvm-include-order in ComplexToLLVM.cpp (NFC) | 2 年前 | |
[mlir][complex] Convert complex.tan to libm ctan call (#78250) We can convert complex.tan op to [ctan/ctanf](https://sourceware.org/newlib/libm.html#ctan) function in libm in the complex to libm conversion. | 2 年前 | |
[mlir][spirv] Improve integer cast during type conversion In SPIR-V, the capabilities for storage and compute are separate. We have good handling of the storage side in general via MemRef type conversion and various memref dialect ops. Once the value was loaded properly, if the compute capability is supported directly, we don't need to emulate like the storage side with int32. However, we do need to make sure casting ops are properly inserted to chain the flow to go back to the original bitwidth. Right now that is done in the each individual pattern directly, which put lots of pressure that shouldn't be on the patterns and causes duplication and trickiness w.r.t. capability check and such. Instead, we should handle such casting within the SPIR-V conversion framework using addSourceMaterialization, where we can check with the target environment to make sure the corresponding compute capability is allowed and then we can materialize and SPIR-V casting op. Along the way, we can drop all the duplicated cast materialization registration in various places. Reviewed By: kuhar Differential Revision: https://reviews.llvm.org/D155118 | 3 年前 | |
Fix complex abs with nnan/ninf. (#95080) The current logic tests for inf/inf and 0/0 inputs using a NaN check. This doesn't work with all fastmath flags. With nnan and ninf, we can just check for a 0 maximum. With only nnan, we have to check for both cases separately. | 2 年前 | |
[MLIR][ControlFlowToLLVM] Remove typed pointer support (#70733) This commit removes the support for lowering ControlFlow to LLVM dialect with typed pointers. Typed pointers have been deprecated for a while now and it's planned to soon remove them from the LLVM dialect. Related PSA: https://discourse.llvm.org/t/psa-removal-of-typed-pointers-from-the-llvm-dialect/74502 | 2 年前 | |
[mlir] Use OpBuilder::createBlock in op builders and patterns (#82770) When creating a new block in (conversion) rewrite patterns, OpBuilder::createBlock must be used. Otherwise, no notifyBlockInserted notification is sent to the listener. Note: The dialect conversion relies on listener notifications to keep track of IR modifications. Creating blocks without the builder API can lead to memory leaks during rollback. | 2 年前 | |
mlir/LogicalResult: move into llvm (#97309) This patch is part of a project to move the Presburger library into LLVM. | 2 年前 | |
[mlir] Adopt ConvertToLLVMPatternInterface GpuToLLVMConversionPass to align with convert-to-llvm (#73761) This is a follow-up to the introduction of convert-to-llvm: it is supposed to be a unifying pass through the ConvertToLLVMPatternInterface, but some specific conversion (like the GPU target) aren't vanilla LLVM target. Instead they need extra customizations that are specific to LLVM-on-GPUs and our custom runtime wrappers. This change make the GpuToLLVMConversionPass just as pluggable as the convert-to-llvm by using the same mechanism. | 2 年前 | |
[mlir][spirv] Implement vector type legalization for function signatures (#98337) ### Description This PR implements a minimal version of function signature conversion to unroll vectors into 1D and with a size supported by SPIR-V (2, 3 or 4 depending on the original dimension). This PR also includes new unit tests that only check for function signature conversion. ### Future Plans - Check for capabilities that support vectors of size 8 or 16. - Set up OneToNTypeConversion and DialectConversion to replace the current implementation that uses GreedyPatternRewriteDriver. - Introduce other vector unrolling patterns to cancel out the vector.insert_strided_slice and vector.extract_strided_slice ops and fully legalize the vector types in the function body. - Handle func::CallOp and declarations. - Restructure the code in SPIRVConversion.cpp. - Create test passes for testing sets of patterns in isolation. - Optimize the way original shape is splitted into target shapes, e.g. vector<5xi32> can be splitted into vector<4xi32> and vector<1xi32>. --------- Co-authored-by: Jakub Kuderski <kubakuderski@gmail.com> | 2 年前 | |
[mlir][EmitC] Fix call ops with zero arguments in func to emitc conversion (#94936) | 2 年前 | |
mlir/LogicalResult: move into llvm (#97309) This patch is part of a project to move the Presburger library into LLVM. | 2 年前 | |
mlir/LogicalResult: move into llvm (#97309) This patch is part of a project to move the Presburger library into LLVM. | 2 年前 | |
[mlir][Conversion] FuncToLLVM: Simplify bare-pointer handling (#96393) Before this commit, there used to be a workaround in the func.func/gpu.func op lowering when the bare-pointer calling convention is enabled. This workaround "patched up" the argument materializations for memref arguments. This can be done directly in the argument materialization functions (as the TODOs in the code base indicate). This commit effectively reverts back to the old implementation (a664c14001fa2359604527084c91d0864aa131a4) and adds additional checks to make sure that bare pointers are used only for function entry block arguments. | 2 年前 | |
[MLIR] Add the convergent attribute to the barrier and shuffle ops (#97807) When lowering from the gpu dialect to the llvm dialect for spirv, the barrier op and shuffle ops need a convergent attribute for correctness. | 2 年前 | |
[mlir][GPU] Improve handling of GPU bounds (#95166) This change reworks how range information for GPU dispatch IDs (block IDs, thread IDs, and so on) is handled. 1. known_block_size and known_grid_size become inherent attributes of GPU functions. This makes them less clunky to work with. As a consequence, the gpu.func lowering patterns now only look at the inherent attributes when setting target-specific attributes on the llvm.func that they lower to. 2. At the same time, gpu.known_block_size and gpu.known_grid_size are made official dialect-level discardable attributes which can be placed on arbitrary functions. This allows for progressive lowerings (without this, a lowering for gpu.thread_id couldn't know about the bounds if it had already been moved from a gpu.func to an llvm.func) and allows for range information to be provided even when gpu.*_{id,dim} are being used outside of a gpu.func context. 3. All of these index operations have gained an optional upper_bound attribute, allowing for an alternate mode of operation where the bounds are specified locally and not inherited from the operation's context. These also allow handling of cases where the precise launch sizes aren't known, but can be bounded more precisely than the maximum of what any platform's API allows. (I'd like to thank @benvanik for pointing out that this could be useful.) When inferring bounds (either for range inference or for setting range during lowering) these sources of information are consulted in order of specificity (upper_bound > inherent attribute > discardable attribute, except that dimension sizes check for known_*_bounds to see if they can be constant-folded before checking their upper_bound). This patch also updates the documentation about the bounds and inference behavior to clarify what these attributes do when set and the consequences of setting them up incorrectly. --------- Co-authored-by: Mehdi Amini <joker.eph@gmail.com> | 2 年前 | |
[MLIR][ROCDL] Refactor conversion of math operations to ROCDL calls to a separate pass (#98653) This patch refactors the conversion of math operations to ROCDL library calls. This pass will also be used in flang to lower Fortran intrinsics/math functions for OpenMP target offloading codgen. | 2 年前 | |
mlir/LogicalResult: move into llvm (#97309) This patch is part of a project to move the Presburger library into LLVM. | 2 年前 | |
[MLIR][LaunchFuncToVulkan] Remove typed pointer support (#70865) This commit removes the typed pointer support from the LaunchFunc's lowering to Vukan dialect. Typed pointers have been deprecated for a while now and it's planned to soon remove them from the LLVM dialect. Related PSA: https://discourse.llvm.org/t/psa-removal-of-typed-pointers-from-the-llvm-dialect/74502 | 2 年前 | |
[mlir][Conversion] Implement ConvertToLLVMPatternInterface (2) Implement ConvertToLLVMPatternInterface for more dialects: index, math, ub. Differential Revision: https://reviews.llvm.org/D157478 | 2 年前 | |
Reland: "[mlir][index][spirv] Add conversion for index to spirv" (#69790) Due to an issue when lowering from scf to spirv as there was no conversion pass for index to spirv, we are motivated to add a conversion pass from the Index dialect to the SPIR-V dialect. Furthermore, we add the new conversion patterns to the scf-to-spirv conversion. Fixes https://github.com/llvm/llvm-project/issues/63713 --------- Co-authored-by: Jeremy Kun <jkun@google.com> | 2 年前 | |
[MLIR] Add f8E4M3 IEEE 754 type (#97118) This PR adds f8E4M3 type to mlir. f8E4M3 type follows IEEE 754 convention c f8E4M3 (IEEE 754) - Exponent bias: 7 - Maximum stored exponent value: 14 (binary 1110) - Maximum unbiased exponent value: 14 - 7 = 7 - Minimum stored exponent value: 1 (binary 0001) - Minimum unbiased exponent value: 1 − 7 = −6 - Precision specifies the total number of bits used for the significand (mantisa), including implicit leading integer bit = 3 + 1 = 4 - Follows IEEE 754 conventions for representation of special values - Has Positive and Negative zero - Has Positive and Negative infinity - Has NaNs Additional details: - Max exp (unbiased): 7 - Min exp (unbiased): -6 - Infinities (+/-): S.1111.000 - Zeros (+/-): S.0000.000 - NaNs: S.1111.{001, 010, 011, 100, 101, 110, 111} - Max normal number: S.1110.111 = +/-2^(7) x (1 + 0.875) = +/-240 - Min normal number: S.0001.000 = +/-2^(-6) - Max subnormal number: S.0000.111 = +/-2^(-6) x 0.875 = +/-2^(-9) x 7 - Min subnormal number: S.0000.001 = +/-2^(-6) x 0.125 = +/-2^(-9) Related PRs: - [PR-97179](https://github.com/llvm/llvm-project/pull/97179) [APFloat] Add support for f8E4M3 IEEE 754 type | 2 年前 | |
[MLIR] Add missing MLIRLinalgTransforms to LinalgToStandard conv (#84545) This fixes the following failure when doing a clean build (in particular no .ninja* lying around) of lib/libMLIRLinalgToStandard.a only: In file included from mlir/include/mlir/Dialect/Vector/Transforms/VectorTransforms.h:12, from mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h:21, from mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp:15: mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h:20:10: fatal error: mlir/Dialect/Vector/Transforms/VectorTransformsEnums.h.inc: No such file or directory | 2 年前 | |
[mlir] Move casting calls from methods to function calls The MLIR classes Type/Attribute/Operation/Op/Value support cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast functionality in addition to defining methods with the same name. This change begins the migration of uses of the method to the corresponding function call as has been decided as more consistent. Note that there still exist classes that only define methods directly, such as AffineExpr, and this does not include work currently to support a functional cast/isa call. Caveats include: - This clang-tidy script probably has more problems. - This only touches C++ code, so nothing that is being generated. Context: - https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…" - Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443 Implementation: This first patch was created with the following steps. The intention is to only do automated changes at first, so I waste less time if it's reverted, and so the first mass change is more clear as an example to other teams that will need to follow similar steps. Steps are described per line, as comments are removed by git: 0. Retrieve the change from the following to build clang-tidy with an additional check: https://github.com/llvm/llvm-project/compare/main...tpopp:llvm-project:tidy-cast-check 1. Build clang-tidy 2. Run clang-tidy over your entire codebase while disabling all checks and enabling the one relevant one. Run on all header files also. 3. Delete .inc files that were also modified, so the next build rebuilds them to a pure state. 4. Some changes have been deleted for the following reasons: - Some files had a variable also named cast - Some files had not included a header file that defines the cast functions - Some files are definitions of the classes that have the casting methods, so the code still refers to the method instead of the function without adding a prefix or removing the method declaration at the same time. ninja -C $BUILD_DIR clang-tidy run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\ -header-filter=mlir/ mlir/* -fix rm -rf $BUILD_DIR/tools/mlir/**/*.inc git restore mlir/lib/IR mlir/lib/Dialect/DLTI/DLTI.cpp\ mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp\ mlir/lib/**/IR/\ mlir/lib/Dialect/SparseTensor/Transforms/SparseVectorization.cpp\ mlir/lib/Dialect/Vector/Transforms/LowerVectorMultiReduction.cpp\ mlir/test/lib/Dialect/Test/TestTypes.cpp\ mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp\ mlir/test/lib/Dialect/Test/TestAttributes.cpp\ mlir/unittests/TableGen/EnumsGenTest.cpp\ mlir/test/python/lib/PythonTestCAPI.cpp\ mlir/include/mlir/IR/ Differential Revision: https://reviews.llvm.org/D150123 | 3 年前 | |
[mlir][math] Propagate scalability in convert-math-to-llvm (#82635) This also generally increases the coverage of scalable vector types in the math-to-llvm tests. | 2 年前 | |
[mlir] Add missing libm member operations to MathToLibm (#87981) This PR adds support for lowering the following Math operations to libm calls: * math.absf -> fabsf, fabs * math.exp -> expf, exp * math.exp2 -> exp2f, exp2 * math.fma -> fmaf, fma * math.log -> logf, log * math.log2 -> log2f, log2 * math.log10 -> log10f, log10 * math.powf -> powf, pow * math.sqrt -> sqrtf, sqrt These operations are direct members of libm, and do not seem to require any special manipulations on their operands. | 2 年前 | |
[MLIR][ROCDL] Refactor conversion of math operations to ROCDL calls to a separate pass (#98653) This patch refactors the conversion of math operations to ROCDL library calls. This pass will also be used in flang to lower Fortran intrinsics/math functions for OpenMP target offloading codgen. | 2 年前 | |
[mlir][spirv] Improve integer cast during type conversion In SPIR-V, the capabilities for storage and compute are separate. We have good handling of the storage side in general via MemRef type conversion and various memref dialect ops. Once the value was loaded properly, if the compute capability is supported directly, we don't need to emulate like the storage side with int32. However, we do need to make sure casting ops are properly inserted to chain the flow to go back to the original bitwidth. Right now that is done in the each individual pattern directly, which put lots of pressure that shouldn't be on the patterns and causes duplication and trickiness w.r.t. capability check and such. Instead, we should handle such casting within the SPIR-V conversion framework using addSourceMaterialization, where we can check with the target environment to make sure the corresponding compute capability is allowed and then we can materialize and SPIR-V casting op. Along the way, we can drop all the duplicated cast materialization registration in various places. Reviewed By: kuhar Differential Revision: https://reviews.llvm.org/D155118 | 3 年前 | |
EmitC: Add emitc.global and emitc.get_global (#145) (#88701) This adds - emitc.global and emitc.get_global ops to model global variables similar to how memref.global and memref.get_global work. - translation of those ops to C++ - lowering of memref.global and memref.get_global into those ops --------- Co-authored-by: Simon Camphausen <simon.camphausen@iml.fraunhofer.de> | 2 年前 | |
| 2 年前 | ||
mlir/LogicalResult: move into llvm (#97309) This patch is part of a project to move the Presburger library into LLVM. | 2 年前 | |
Switch member calls to isa/dyn_cast/cast/... to free function calls. (#89356) This change cleans up call sites. Next step is to mark the member functions deprecated. See https://mlir.llvm.org/deprecation and https://discourse.llvm.org/t/preferred-casting-style-going-forward. | 2 年前 | |
mlir/LogicalResult: move into llvm (#97309) This patch is part of a project to move the Presburger library into LLVM. | 2 年前 | |
[mlir][IR] Rename "update root" to "modify op" in rewriter API (#78260) This commit renames 4 pattern rewriter API functions: * updateRootInPlace -> modifyOpInPlace * startRootUpdate -> startOpModification * finalizeRootUpdate -> finalizeOpModification * cancelRootUpdate -> cancelOpModification The term "root" is a misnomer. The root is the op that a rewrite pattern matches against (https://mlir.llvm.org/docs/PatternRewriter/#root-operation-name-optional). A rewriter must be notified of all in-place op modifications, not just in-place modifications of the root (https://mlir.llvm.org/docs/PatternRewriter/#pattern-rewriter). The old function names were confusing and have contributed to various broken rewrite patterns. Note: The new function names use the term "modify" instead of "update" for consistency with the RewriterBase::Listener terminology (notifyOperationModified). | 2 年前 | |
[mlir][OpenMP] Remove deprecated omp.reduction (#92732) This operation did not model the behaviour of reductions in the openmp standard. It has since been replaced by block arguments on the outer operation. See https://github.com/llvm/llvm-project/pull/79308 and https://github.com/llvm/llvm-project/pull/80019 | 2 年前 | |
Add llvm::min/max_element and use it in llvm/ and mlir/ directories. (#84678) For some reason this was missing from STLExtras. | 2 年前 | |
[mlir][Conversion] Generalize and fix crash in reconcile-unrealized-casts (#95700) This commit fixes a crash in -reconcile-unrealized-casts when cast ops have multiple operands: `` DialectConversion.cpp:1583: virtual void mlir::ConversionPatternRewriter::replaceOp(mlir::Operation *, mlir::ValueRange): Assertion op->getNumResults() == newValues.size() && "incorrect # of replacement values"' failed. This commit also generalizes the pass such that more ops are folded. In particular (letters indicate types): A / \ B C | A `` Previously, such IR was not folded at all. The A -> B -> A type cast cycle is now folded away. (The A -> C cast stays in place.) This commit also turns the pass from a dialect conversion into a simple IR walk. The pattern and its populate function are removed. The pattern was a (non-conversion) rewrite pattern, but used in a dialect conversion, which is generally not safe. In particular, the rewrite pattern may traverse IR that was already scheduled for erasure by the dialect conversion. Note: Some test cases changed slightly (NFC) because the new pass implementation no longer attempts to fold ops. Note for LLVM integration: If your pipeline uses the removed populate function, try to simply remove that function call. Chances are you may not need it at all. If it is in fact needed, run the -reconcile-unrealized-casts` pass right after the pass that used to populate the pattern. --------- Co-authored-by: Maksim Levental <maksim.levental@gmail.com> Co-authored-by: Markus Böck <markus.boeck02@gmail.com> | 2 年前 | |
[mlir][scf] Implement conversion from scf.forall to scf.parallel (#94109) There is currently no path to lower scf.forall to scf.parallel with the goal of targeting the OpenMP dialect. In the SCF->ControlFlow conversion, scf.forall is briefly converted to scf.parallel, but the scf.parallel is lowered directly to a sequential loop. This makes experimenting with scf.forall for CPU execution difficult. This change factors out the rewrite in the SCF->ControlFlow pass into a utility function that can then be used in the SCF->ControlFlow lowering and via a separate -scf-forall-to-parallel pass. --------- Co-authored-by: Spenser Bauman <sabauma@fastmail> | 2 年前 | |
[mlir][emitc] Remove copy from scf.for lowering (#94898) Remove the copy into fresh variables done when lowering scf.for into emitc.for and use the variables carrying the init and iter values as the loop's results. | 2 年前 | |
| 2 年前 | ||
[MLIR][OpenMP] Clause-based OpenMP operation definition (#92523) This patch updates OpenMP_Op definitions to be based on the new set of OpenMP_Clause definitions, and to take advantage of clause-based automatically-generated argument lists, descriptions, assembly format and class declarations. There are also changes introduced to the clause operands structures to match the current set of tablegen clause definitions. These two are very closely linked and should be kept in sync. It would probably be a good idea to try generating clause operands structures from the tablegen OpenMP_Clause definitions in the future. As a result of this change, arguments for some operations have been reordered. This patch also addresses this by updating affected operation build calls and unit tests. Some other updates to tests related to the order of arguments in the resulting assembly format and others due to certain previous inconsistencies in the printing/parsing of clauses are addressed. The printer and parser functions for the map clause are updated, so that they are able to handle map clauses linked to entry block arguments as well as those which aren't. This PR causes a build failure in the flang subproject. This is addressed by the next PR in the stack. | 2 年前 | |
[mlir][Transforms] Dialect Conversion: Simplify block conversion API (#94866) This commit simplifies and improves documentation for the part of the ConversionPatternRewriter API that deals with signature conversions. There are now two public functions for signature conversion: * applySignatureConversion converts a single block signature. This function used to take a Region * (but converted only the entry block). It now takes a Block *. * convertRegionTypes converts all block signatures of a region. convertNonEntryRegionTypes is removed because it is not widely used and can easily be expressed with a call to applySignatureConversion inside a loop. (See Detensorize.cpp for an example.) Note: For consistency, convertRegionTypes could be renamed to applySignatureConversion (overload) in the future. (Or applySignatureConversion renamed to convertBlockTypes.) Also clarify when a type converter and/or signature conversion object is needed and for what purpose. Internal code refactoring (NFC) of ConversionPatternRewriterImpl (the part that deals with signature conversions). This part of the codebase was quite convoluted and unintuitive. From a functional perspective, this change is NFC. However, the public API changes, thus not marking as NFC. Note for LLVM integration: When you see applySignatureConversion(region, ...), replace with applySignatureConversion(region->front(), ...). In the unlikely case that you see convertNonEntryRegionTypes, apply the same changes as this commit did to Detensorize.cpp. --------- Co-authored-by: Markus Böck <markus.boeck02@gmail.com> | 2 年前 | |
[mlir][spirv] Allow vectors of index types in elementwise conversions Currently the conversion of elementwise ops only checks for scalar index types when checking for bitwidth emulation. Differential Revision: https://reviews.llvm.org/D146307 | 3 年前 | |
mlir/LogicalResult: move into llvm (#97309) This patch is part of a project to move the Presburger library into LLVM. | 2 年前 | |
[mlir] Use arith max or min ops instead of cmp + select (#82178) I believe the semantics should be the same, but this saves 1 op and simplifies the code. For example, the following two instructions: %2 = cmp sgt %0, %1 %3 = select %2, %0, %1 Are equivalent to: %2 = maxsi %0 %1 | 2 年前 | |
mlir/LogicalResult: move into llvm (#97309) This patch is part of a project to move the Presburger library into LLVM. | 2 年前 | |
mlir/LogicalResult: move into llvm (#97309) This patch is part of a project to move the Presburger library into LLVM. | 2 年前 | |
[mlir][tosa]Create a check for i64 input in apply_scale lowering in TosaToArith Reviewed By: rsuderman Differential Revision: https://reviews.llvm.org/D159473 | 2 年前 | |
[TOSA] Add lowering for tosa.sin and tosa.cos (#99651) Lower tosa ops to mlir::math::SinOp and mlir::math::CosOp as part of the tosa to linalg conversion. Added lit tests for conversion. | 2 年前 | |
[TOSA] Add TosaToMLProgram conversion (#69787) This patch adds a new pass to lower TOSA StatefulOps to corresponding ML Program ops (https://mlir.llvm.org/docs/Dialects/MLProgramOps/). Signed-off-by: Jerry Ge <jerry.ge@arm.com> | 2 年前 | |
Lowering for 'tosa.scatter' This patch adds support for tosa.scatter lowering in the --tosa-to-scf pass. Here's an example for this lowering: func.func @tosa( %valuesIn : tensor<3x7x5xi32>, %indices : tensor<3x6xi32>, %input : tensor<3x6x5xi32>) -> tensor<3x7x5xi32> { %0 = "tosa.scatter"(%valuesIn, %indices, %input) : (tensor<3x7x5xi32>, tensor<3x6xi32>, tensor<3x6x5xi32>) -> (tensor<3x7x5xi32>) return %0 : tensor<3x7x5xi32> } translates to func.func @tosa(%arg0: tensor<3x7x5xi32>, %arg1: tensor<3x6xi32>, %arg2: tensor<3x6x5xi32>) -> tensor<3x7x5xi32> { %c0 = arith.constant 0 : index %c3 = arith.constant 3 : index %c1 = arith.constant 1 : index %c6 = arith.constant 6 : index %c2 = arith.constant 2 : index %c5 = arith.constant 5 : index %c0_0 = arith.constant 0 : index %c1_1 = arith.constant 1 : index %0 = scf.for %arg3 = %c0_0 to %c3 step %c1_1 iter_args(%arg4 = %arg0) -> (tensor<3x7x5xi32>) { %1 = scf.for %arg5 = %c0_0 to %c6 step %c1_1 iter_args(%arg6 = %arg4) -> (tensor<3x7x5xi32>) { %extracted = tensor.extract %arg1[%arg3, %arg5] : tensor<3x6xi32> %2 = arith.index_cast %extracted : i32 to index %extracted_slice = tensor.extract_slice %arg2[%arg3, %arg5, %c0_0] [%c1_1, %c1_1, %c5] [%c1_1, %c1_1, %c1_1] : tensor<3x6x5xi32> to tensor<?x?x?xi32> %inserted_slice = tensor.insert_slice %extracted_slice into %arg6[%arg3, %2, %c0_0] [%c1_1, %c1_1, %c5] [%c1_1, %c1_1, %c1_1] : tensor<?x?x?xi32> into tensor<3x7x5xi32> scf.yield %inserted_slice : tensor<3x7x5xi32> } scf.yield %1 : tensor<3x7x5xi32> } return %0 : tensor<3x7x5xi32> } `` We have attempted an alternative lowering pass that uses tensor.scatter as an intermediate step. However, we opted to aim straight at the scf dialect for the following reasons: - The tensor.scatter op doesn't seem to be used anywhere. There is no available lowering pass for this op (although we have one that we'll upstream soon). - The tosa.scatter and tensor.scatter op have different indexing semantics. The indices argument of tosa.scatter must be non-trivially modified and restructured (e.g. with a linalg.generic op) to adapt to the needs of tensor.scatter. While this overhead may be simplified and fused after a subsequent tensor.scatter lowering, it adds complex logic and an obscure intermediate state. Unless there is a good reason to go through the tensor` dialect that we're missing, this additional complexity may not be justified. Reviewed By: eric-k256 Differential Revision: https://reviews.llvm.org/D151117 | 3 年前 | |
TosaToTensor: Support reshape on tensors of unsigned integer (#91734) This adds - mlir::tosa::populateTosaToLinalgTypeConversion which converts tensors of unsigned integers into tensors of signless integers - modifies the tosa.reshape lowering in TosaToTensor to use the type converter correctly I choose to implement the type converter in mlir/Conversion/TosaToLinalg/TosaToLinalg.h instead of mlir/Conversion/TosaToTensor/TosaToTensor.h because I need the same type converter in the TosaToLinalg lowerings (future PR). Alternatively, I could duplicate the type converter so it exists both in TosaToLinalg and TosaToTensor. Let me know if you prefer that. | 2 年前 | |
[mlir][UBToLLVM] Do not arbitrarily restrict input types The lowering pattern is currently restricted to integer, float and index types. This is seemingly arbitrary, as ub.poison works for any input type. The lowering should therefore also work with any type that can be converted using the type converter. This patch therefore simply removes that condition and adds a test ensuring that this works. Differential Revision: https://reviews.llvm.org/D158982 | 2 年前 | |
[mlir][spirv] Convert ub.poison to spirv.undef SPIR-V doesn't have poison, but poison can be converted to undef. Differential Revision: https://reviews.llvm.org/D156163 | 3 年前 | |
[mlir][ArmSME] Lower extract from 2D scalable create_mask to psel (#96066) Example: mlir %mask = vector.create_mask %a, %b : vector<[4]x[8]xi1> %slice = vector.extract %mask[%index] : vector<[8]xi1> from vector<[4]x[8]xi1> Becomes: mlir %mask_rows = vector.create_mask %a : vector<[4]xi1> %mask_cols = vector.create_mask %b : vector<[8]xi1> %slice = arm_sve.psel %mask_cols, %mask_rows[%index] : vector<[8]xi1>, vector<[4]xi1> Note: While psel is under ArmSVE it requires SME (or SVE 2.1), so this is currently the most logical place for this lowering. | 2 年前 | |
mlir/LogicalResult: move into llvm (#97309) This patch is part of a project to move the Presburger library into LLVM. | 2 年前 | |
[mlir][vector] Propagate scalability to gather/scatter ptrs vector (#97584) In convert-vector-to-llvm the first operand (vector of pointers holding all memory addresses to read) to the masked.gather (and scatter) intrinsic has a fixed vector type. This may result in intrinsics where the scalable flag has been dropped: %0 = llvm.intr.masked.gather %1, %2, %3 {alignment = 4 : i32} : (!llvm.vec<4 x ptr>, vector<[4]xi1>, vector<[4]xi32>) -> vector<[4]xi32> Fortunately the operand is overloaded on the result type so we end up with the correct IR when lowering to LLVM, but this is still incorrect. This patch fixes it by propagating scalability. | 2 年前 | |
[mlir] Use StringRef::operator== instead of StringRef::equals (NFC) (#91560) I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 10 under mlir/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str". | 2 年前 | |
[mlir][spirv] Fix bug for vector.broadcast op in convert-vector-to-spirv pass (#99928) This PR addresses [!17976](https://github.com/iree-org/iree/issues/17976) by using converted resultType instead of the original result type obtained from castOp.getResultVectorType. A new LIT test is also included. | 2 年前 | |
[MLIR][ROCDL] Refactor conversion of math operations to ROCDL calls to a separate pass (#98653) This patch refactors the conversion of math operations to ROCDL library calls. This pass will also be used in flang to lower Fortran intrinsics/math functions for OpenMP target offloading codgen. | 2 年前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 3 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 3 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 3 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 3 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 3 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 3 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 3 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 |