[llvm-branch-commits] [mlir] e2d7d3c - [mlir][docs] Bring bufferization docs up to date.
Author: Sean Silva Date: 2021-01-14T12:28:35-08:00 New Revision: e2d7d3cb0eade079690c3938f694c8f7ef2b686b URL: https://github.com/llvm/llvm-project/commit/e2d7d3cb0eade079690c3938f694c8f7ef2b686b DIFF: https://github.com/llvm/llvm-project/commit/e2d7d3cb0eade079690c3938f694c8f7ef2b686b.diff LOG: [mlir][docs] Bring bufferization docs up to date. This spilts out BufferDeallocationInternals.md, since buffer deallocation is not part of bufferization per se. Differential Revision: https://reviews.llvm.org/D94351 Added: mlir/docs/BufferDeallocationInternals.md Modified: mlir/docs/Bufferization.md Removed: diff --git a/mlir/docs/BufferDeallocationInternals.md b/mlir/docs/BufferDeallocationInternals.md new file mode 100644 index ..acc775fd9f30 --- /dev/null +++ b/mlir/docs/BufferDeallocationInternals.md @@ -0,0 +1,786 @@ +# Buffer Deallocation - Internals + +This section covers the internal functionality of the BufferDeallocation +transformation. The transformation consists of several passes. The main pass +called BufferDeallocation can be applied via “-buffer-deallocation” on MLIR +programs. + +## Requirements + +In order to use BufferDeallocation on an arbitrary dialect, several +control-flow interfaces have to be implemented when using custom operations. +This is particularly important to understand the implicit control-flow +dependencies between diff erent parts of the input program. Without implementing +the following interfaces, control-flow relations cannot be discovered properly +and the resulting program can become invalid: + +* Branch-like terminators should implement the `BranchOpInterface` to query and +manipulate associated operands. +* Operations involving structured control flow have to implement the +`RegionBranchOpInterface` to model inter-region control flow. +* Terminators yielding values to their parent operation (in particular in the +scope of nested regions within `RegionBranchOpInterface`-based operations), +should implement the `ReturnLike` trait to represent logical “value returns”. + +Example dialects that are fully compatible are the “std” and “scf” dialects +with respect to all implemented interfaces. + +## Detection of Buffer Allocations + +The first step of the BufferDeallocation transformation is to identify +manageable allocation operations that implement the `SideEffects` interface. +Furthermore, these ops need to apply the effect `MemoryEffects::Allocate` to a +particular result value while not using the resource +`SideEffects::AutomaticAllocationScopeResource` (since it is currently reserved +for allocations, like `Alloca` that will be automatically deallocated by a +parent scope). Allocations that have not been detected in this phase will not +be tracked internally, and thus, not deallocated automatically. However, +BufferDeallocation is fully compatible with “hybrid” setups in which tracked +and untracked allocations are mixed: + +```mlir +func @mixedAllocation(%arg0: i1) { + %0 = alloca() : memref<2xf32> // aliases: %2 + %1 = alloc() : memref<2xf32> // aliases: %2 + cond_br %arg0, ^bb1, ^bb2 +^bb1: + use(%0) + br ^bb3(%0 : memref<2xf32>) +^bb2: + use(%1) + br ^bb3(%1 : memref<2xf32>) +^bb3(%2: memref<2xf32>): + ... +} +``` + +Example of using a conditional branch with alloc and alloca. BufferDeallocation +can detect and handle the diff erent allocation types that might be intermixed. + +Note: the current version does not support allocation operations returning +multiple result buffers. + +## Conversion from AllocOp to AllocaOp + +The PromoteBuffersToStack-pass converts AllocOps to AllocaOps, if possible. In +some cases, it can be useful to use such stack-based buffers instead of +heap-based buffers. The conversion is restricted to several constraints like: + +* Control flow +* Buffer Size +* Dynamic Size + +If a buffer is leaving a block, we are not allowed to convert it into an +alloca. If the size of the buffer is large, we could convert it, but regarding +stack overflow, it makes sense to limit the size of these buffers and only +convert small ones. The size can be set via a pass option. The current default +value is 1KB. Furthermore, we can not convert buffers with dynamic size, since +the dimension is not known a priori. + +## Movement and Placement of Allocations + +Using the buffer hoisting pass, all buffer allocations are moved as far upwards +as possible in order to group them and make upcoming optimizations easier by +limiting the search space. Such a movement is shown in the following graphs. +In addition, we are able to statically free an alloc, if we move it into a +dominator of all of its uses. This simplifies further optimizations (e.g. +buffer fusion) in the future. However, movement of allocations is limited by +external data dependencies (in particular in the case of allocations of +dynamically shaped types). Furthermore, a
[llvm-branch-commits] [mlir] be7352c - [mlir][splitting std] move 2 more ops to `tensor`
Author: Sean Silva Date: 2021-01-19T13:49:25-08:00 New Revision: be7352c00d51f4358db3a23ed6a077f7cb48eafd URL: https://github.com/llvm/llvm-project/commit/be7352c00d51f4358db3a23ed6a077f7cb48eafd DIFF: https://github.com/llvm/llvm-project/commit/be7352c00d51f4358db3a23ed6a077f7cb48eafd.diff LOG: [mlir][splitting std] move 2 more ops to `tensor` - DynamicTensorFromElementsOp - TensorFromElements Differential Revision: https://reviews.llvm.org/D94994 Added: Modified: mlir/include/mlir/Dialect/StandardOps/IR/Ops.td mlir/include/mlir/Dialect/Tensor/IR/Tensor.h mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td mlir/include/mlir/Dialect/Tensor/Transforms/Passes.td mlir/lib/Conversion/ShapeToStandard/CMakeLists.txt mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp mlir/lib/Dialect/StandardOps/IR/Ops.cpp mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp mlir/lib/Dialect/Tensor/IR/CMakeLists.txt mlir/lib/Dialect/Tensor/IR/TensorOps.cpp mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp mlir/lib/Dialect/Tensor/Transforms/CMakeLists.txt mlir/lib/Dialect/Tensor/Transforms/PassDetail.h mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir mlir/test/Dialect/Standard/bufferize.mlir mlir/test/Dialect/Standard/canonicalize.mlir mlir/test/Dialect/Standard/invalid.mlir mlir/test/Dialect/Standard/ops.mlir mlir/test/Dialect/Tensor/bufferize.mlir mlir/test/Dialect/Tensor/canonicalize.mlir mlir/test/Dialect/Tensor/invalid.mlir mlir/test/Dialect/Tensor/ops.mlir mlir/test/IR/core-ops.mlir mlir/test/IR/invalid-ops.mlir mlir/test/Transforms/canonicalize.mlir Removed: diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td index 6eabe1179234..8e3f1f1a7a85 100644 --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -1591,47 +1591,6 @@ def DivFOp : FloatArithmeticOp<"divf"> { let summary = "floating point division operation"; } -//===--===// -// DynamicTensorFromElementsOp -//===--===// - -def DynamicTensorFromElementsOp : Std_Op<"dynamic_tensor_from_elements", -[RecursiveSideEffects, SingleBlockImplicitTerminator<"YieldOp">]> { - string summary = "Creates a dynamically sized tensor from elements"; - string description = [{ -This operation creates a dynamically sized tensor with elements of any type. -It expects one index operand per dynamic extent of the result tensor. - -The body region defines the tensor's elements. It takes index operands as -its region arguments that span the index space. The element at the given -position is yielded with the `yield` operation (see `YieldOp`). There is -no defined ordering to the invocations of the body. It is conceptually -a "parallel map" operation. - -Example: - -```mlir - %tnsr = dynamic_tensor_from_elements %m, %n { - ^bb0(%i : index, %j : index, %k : index): -... -yield %elem : f32 - } : tensor -``` - }]; - - let arguments = (ins Variadic:$dynamicExtents); - let results = (outs AnyRankedTensor:$result); - let regions = (region SizedRegion<1>:$body); - - let builders = [ -// Build op and populate its body per callback function. -OpBuilderDAG<(ins "Type":$resultTy, "ValueRange":$dynamicExtents, - "function_ref")>, - ]; - - let hasCanonicalizer = 1; -} - //===--===// // ExpOp //===--===// @@ -1672,46 +1631,6 @@ def Exp2Op : FloatUnaryOp<"exp2"> { let summary = "base-2 exponential of the specified value"; } -//===--===// -// TensorFromElementsOp -//===--===// - -def TensorFromElementsOp : Std_Op<"tensor_from_elements", [ -NoSideEffect, -TypesMatchWith<"operand types match result element type", - "result", "elements", "SmallVector(" - "$_self.cast().getDimSize(0), " - "$_self.cast().getElementType())"> - ]> { - string summary = "tensor from elements operation."; - string description = [{ -Create a 1D tensor from a range of same-type arguments. - -Example: - -```mlir -tensor_from_elements(i_1, ..., i_N) : tensor -``` - }]; - - let arguments = (ins Variadic:$elements); - let results = (outs 1DTensorOf<[AnyType]>:$result); - - let assemblyFormat = "$elements attr-dict `:` type($result)"; - - // This op is fully verified by its traits. - let verifier = ?; - - let skipD
[llvm-branch-commits] [mlir] caf4f2e - [mlir] Handle unknown ops in dynamic_tensor_from_elements bufferization
Author: Sean Silva Date: 2020-12-15T12:50:56-08:00 New Revision: caf4f2e372a7a4d5d8b5a8733e44f002c6dee0d5 URL: https://github.com/llvm/llvm-project/commit/caf4f2e372a7a4d5d8b5a8733e44f002c6dee0d5 DIFF: https://github.com/llvm/llvm-project/commit/caf4f2e372a7a4d5d8b5a8733e44f002c6dee0d5.diff LOG: [mlir] Handle unknown ops in dynamic_tensor_from_elements bufferization Due to how the conversion infra works, the "clone" call that this pattern was using required all the cloned ops to be immediately legalized as part of this dialect conversion invocation. That was previously working due to a couple factors: - In the test case, there was scf.if, which we happen to mark as legal as part of marking the entire SCF dialect as legal for the scf.parallel we generate here. - Originally, this test case had std.extract_element in the body, which we happened to have a pattern for in this pass. After I migrated that to `tensor.extract` (which removed the tensor.extract bufferization from here), I hacked this up to use `std.dim` which we still have patterns for in this pass. This patch updates the test case to use a truly opaque op `test.source` that properly stresses this aspect of the pattern. (this also removes a stray dependency on the `tensor` dialect that I must have left behind as part of my hacking this pass up when migrating to `tensor.extract`) Differential Revision: https://reviews.llvm.org/D93262 Added: Modified: mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp mlir/test/Dialect/Standard/bufferize.mlir Removed: diff --git a/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp b/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp index 6691355d232c..a84934b0ebb8 100644 --- a/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp @@ -15,7 +15,6 @@ #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/StandardOps/Transforms/Passes.h" -#include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/Transforms/DialectConversion.h" @@ -70,18 +69,29 @@ class BufferizeDynamicTensorFromElementsOp upperBounds.push_back(upperBound); } -// Generate tensor elements with a parallel loop. -rewriter.create( -loc, lowerBounds, upperBounds, steps, -[&](OpBuilder &b, Location loc, ValueRange ivs) { - BlockAndValueMapping mapping; - mapping.map(op.body().getArguments(), ivs); - for (auto &nestedOp : op.getBody()->without_terminator()) -b.clone(nestedOp, mapping); - auto yieldOp = cast(op.getBody()->getTerminator()); - b.create(loc, mapping.lookup(yieldOp.value()), result, ivs); - b.create(loc); -}); +// Generate tensor elements with a parallel loop that stores into +// each element of the resulting memref. +// +// This is a bit tricky. We cannot simply clone the ops because when an op +// is cloned, it must be legalized. However, we want to allow arbitrary ops +// in the body that we don't necessarily have legalization patterns for as +// part of this dialect conversion invocation. +// +// To accomplish this, we use mergeBlockBefore to "move" this op's body +// into the scf.parallel's body. +auto parallel = +rewriter.create(loc, lowerBounds, upperBounds, steps); +Block *parallelBody = parallel.getBody(); +rewriter.mergeBlockBefore(op.getBody(), parallelBody->getTerminator(), + parallelBody->getArguments()); +// Replace the inlined yield op with a store op. The scf.parallel's builder +// already populated an scf.yield at the end, so we don't need to worry +// about creating that. +Operation *elementYield = parallelBody->getTerminator()->getPrevNode(); +rewriter.setInsertionPointAfter(elementYield); +rewriter.replaceOpWithNewOp(elementYield, + elementYield->getOperands()[0], result, + parallelBody->getArguments()); rewriter.replaceOp(op, {result}); return success(); @@ -168,7 +178,6 @@ struct StdBufferizePass : public StdBufferizeBase { target.addLegalDialect(); target.addLegalDialect(); -target.addLegalDialect(); populateStdBufferizePatterns(context, typeConverter, patterns); target.addIllegalOp tensor<2xindex> { return %0 : tensor<2xindex> } -// The dynamic_tensor_from_elements op clones each op in its body. -// Make sure that regions nested within such ops are recursively converted. -// CHECK-LABEL: func @recursively_convert_cloned_regions -func @recursively_convert_cloned_regions(%arg0: tensor<*xf32>, %arg1: index, %arg2: i1) -> tensor { - %tensor = dynamic_tensor_from_elements %arg1 { +// The dy
[llvm-branch-commits] [mlir] 129d6e5 - [mlir] Move `std.tensor_cast` -> `tensor.cast`.
Author: Sean Silva Date: 2020-12-17T16:06:56-08:00 New Revision: 129d6e554e7a0dba3443ffd8f1df185b90cc6fd5 URL: https://github.com/llvm/llvm-project/commit/129d6e554e7a0dba3443ffd8f1df185b90cc6fd5 DIFF: https://github.com/llvm/llvm-project/commit/129d6e554e7a0dba3443ffd8f1df185b90cc6fd5.diff LOG: [mlir] Move `std.tensor_cast` -> `tensor.cast`. This is almost entirely mechanical. Differential Revision: https://reviews.llvm.org/D93357 Added: Modified: mlir/include/mlir/Dialect/Linalg/Utils/Utils.h mlir/include/mlir/Dialect/StandardOps/IR/Ops.h mlir/include/mlir/Dialect/StandardOps/IR/Ops.td mlir/include/mlir/Dialect/Tensor/IR/Tensor.h mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td mlir/include/mlir/IR/OpDefinition.h mlir/integration_test/Dialect/Linalg/CPU/test-elementwise.mlir mlir/integration_test/Dialect/Linalg/CPU/test-subtensor-insert-multiple-uses.mlir mlir/integration_test/Dialect/Linalg/CPU/test-subtensor-insert.mlir mlir/integration_test/Dialect/Linalg/CPU/test-tensor-e2e.mlir mlir/integration_test/Dialect/Linalg/CPU/test-tensor-matmul.mlir mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp mlir/lib/Dialect/Linalg/IR/CMakeLists.txt mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp mlir/lib/Dialect/Shape/IR/CMakeLists.txt mlir/lib/Dialect/Shape/IR/Shape.cpp mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td mlir/lib/Dialect/StandardOps/IR/Ops.cpp mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp mlir/lib/Dialect/Tensor/IR/TensorOps.cpp mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp mlir/lib/IR/Operation.cpp mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir mlir/test/Dialect/Linalg/canonicalize.mlir mlir/test/Dialect/Shape/canonicalize.mlir mlir/test/Dialect/Standard/bufferize.mlir mlir/test/Dialect/Standard/canonicalize.mlir mlir/test/Dialect/Tensor/bufferize.mlir mlir/test/Dialect/Tensor/canonicalize.mlir mlir/test/Dialect/Tensor/invalid.mlir mlir/test/Dialect/Tensor/ops.mlir mlir/test/IR/core-ops.mlir mlir/test/Transforms/canonicalize.mlir mlir/test/Transforms/cse.mlir mlir/utils/vim/syntax/mlir.vim Removed: diff --git a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h index 3df609f295cc..2ef32cfe378b 100644 --- a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h @@ -34,7 +34,7 @@ namespace linalg { class LinalgDependenceGraph; /// A struct containing the Linalg producer before and after fusion. -/// When operating on tensors, `fusedProducer` may feed into a `tensor_cast` op +/// When operating on tensors, `fusedProducer` may feed into a `tensor.cast` op /// before the consumer Linalg op, until enough canonicalizations have applied. struct FusionInfo { LinalgOp originalProducer; diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h index 7302bd486657..56ff32252fee 100644 --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h @@ -354,31 +354,6 @@ computeRankReductionMask(ArrayRef originalShape, /// ``` bool canFoldIntoConsumerOp(MemRefCastOp castOp); -/// Counterpart of `canFoldIntoConsumerOp(MemRefCastOp castOp)` for tensors. -/// Determines whether TensorCastOp casts to a more dynamic version of the -/// source tensor. This is useful to fold a tensor_cast into a consuming op and -/// implement canonicalization patterns for ops in diff erent dialects that may -/// consume the results of tensor_cast operations. Such foldable tensor_cast -/// operations are typically inserted as `subtensor` ops and are canonicalized, -/// to preserve the type compatibility of their uses. -/// -/// Returns true when all conditions are met: -/// 1. source and result are ranked tensors with same element type and rank. -/// 2. the tensor type has more static information than the result -/// -/// Example: -/// ```mlir -/// %1 = tensor_cast %0 : tensor<8x16xf32> to tensor -/// %2 = consumer %1 ... : tensor ... -/// ``` -/// -/// folds into: -/// -/// ```mlir -/// %2 = consumer %0 ... : tensor<8x16xf32> ... -/// ``` -bool canFoldIntoConsumerOp(TensorCastOp castOp); - /// Compute `lhs` `pred` `rhs`, where `pred` is one of the known integer /// comparison predicates. bool applyCmpPredicate(CmpIPredicate predicate, const APInt &lhs, diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td index 481dfaf4b34d..7af44f8435ff 100644 --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/
[llvm-branch-commits] [mlir] 5488a6b - [NFC] Fix pattern name.
Author: Sean Silva Date: 2020-11-25T16:10:34-08:00 New Revision: 5488a6b0ffb1c34898db6bd50798be2472db93c8 URL: https://github.com/llvm/llvm-project/commit/5488a6b0ffb1c34898db6bd50798be2472db93c8 DIFF: https://github.com/llvm/llvm-project/commit/5488a6b0ffb1c34898db6bd50798be2472db93c8.diff LOG: [NFC] Fix pattern name. It still had the old name from before ElementwiseMappable was added. Added: Modified: mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp Removed: diff --git a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp index a0e5d74e1767..8ee1b389dee8 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp @@ -26,8 +26,8 @@ static bool isElementwiseMappableOpOnRankedTensors(Operation *op) { } namespace { -struct ConvertStdElementwiseOpOnRankedTensors : public RewritePattern { - ConvertStdElementwiseOpOnRankedTensors() +struct ConvertAnyElementwiseMappableOpOnRankedTensors : public RewritePattern { + ConvertAnyElementwiseMappableOpOnRankedTensors() : RewritePattern(/*benefit=*/1, MatchAnyOpTypeTag()) {} LogicalResult matchAndRewrite(Operation *op, PatternRewriter &rewriter) const final { @@ -68,7 +68,7 @@ struct ConvertStdElementwiseOpOnRankedTensors : public RewritePattern { void mlir::populateElementwiseToLinalgConversionPatterns( OwningRewritePatternList &patterns, MLIRContext *) { - patterns.insert(); + patterns.insert(); } namespace { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] 774f1d3 - [mlir] Small cleanups to func-bufferize/finalizing-bufferize
Author: Sean Silva Date: 2020-11-30T17:04:14-08:00 New Revision: 774f1d3ffd458d6cb82d5039758ef1cf6370957f URL: https://github.com/llvm/llvm-project/commit/774f1d3ffd458d6cb82d5039758ef1cf6370957f DIFF: https://github.com/llvm/llvm-project/commit/774f1d3ffd458d6cb82d5039758ef1cf6370957f.diff LOG: [mlir] Small cleanups to func-bufferize/finalizing-bufferize - Address TODO in scf-bufferize: the argument materialization issue is now fixed and the code is now in Transforms/Bufferize.cpp - Tighten up finalizing-bufferize to avoid creating invalid IR when operand types potentially change - Tidy up the testing of func-bufferize, and move appropriate tests to a new finalizing-bufferize.mlir - The new stricter checking in finalizing-bufferize revealed that we needed a DimOp conversion pattern (found when integrating into npcomp). Previously, the converion infrastructure was blindly changing the operand type during finalization, which happened to work due to DimOp's tensor/memref polymorphism, but is generally not encouraged (the new pattern is the way to tell the conversion infrastructure that it is legal to change that type). Added: mlir/test/Transforms/finalizing-bufferize.mlir Modified: mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp mlir/lib/Transforms/Bufferize.cpp mlir/test/Dialect/Standard/bufferize.mlir mlir/test/Dialect/Standard/func-bufferize.mlir Removed: mlir/test/Dialect/Standard/func-bufferize-partial.mlir diff --git a/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp b/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp index 57d605b3491f7..7cf0dfabd9174 100644 --- a/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp @@ -27,21 +27,6 @@ struct SCFBufferizePass : public SCFBufferizeBase { OwningRewritePatternList patterns; ConversionTarget target(*context); -// TODO: Move this to BufferizeTypeConverter's constructor. -// -// This doesn't currently play well with "finalizing" bufferizations (ones -// that expect all materializations to be gone). In particular, there seems -// to at least be a double-free in the dialect conversion framework -// when this materialization gets inserted and then folded away because -// it is marked as illegal. -typeConverter.addArgumentMaterialization( -[](OpBuilder &builder, RankedTensorType type, ValueRange inputs, - Location loc) -> Value { - assert(inputs.size() == 1); - assert(inputs[0].getType().isa()); - return builder.create(loc, type, inputs[0]); -}); - populateBufferizeMaterializationLegality(target); populateSCFStructuralTypeConversionsAndLegality(context, typeConverter, patterns, target); diff --git a/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp b/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp index 9056fbc25e14d..8b47e88677e2d 100644 --- a/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp @@ -20,6 +20,21 @@ using namespace mlir; +namespace { +class BufferizeDimOp : public OpConversionPattern { +public: + using OpConversionPattern::OpConversionPattern; + LogicalResult + matchAndRewrite(DimOp op, ArrayRef operands, + ConversionPatternRewriter &rewriter) const override { +DimOp::Adaptor adaptor(operands); +rewriter.replaceOpWithNewOp(op, adaptor.memrefOrTensor(), + adaptor.index()); +return success(); + } +}; +} // namespace + namespace { class BufferizeDynamicTensorFromElementsOp : public OpConversionPattern { @@ -148,6 +163,7 @@ void mlir::populateStdBufferizePatterns(MLIRContext *context, OwningRewritePatternList &patterns) { patterns.insert< // clang-format off + BufferizeDimOp, BufferizeDynamicTensorFromElementsOp, BufferizeExtractElementOp, BufferizeSelectOp, @@ -178,6 +194,8 @@ struct StdBufferizePass : public StdBufferizeBase { return typeConverter.isLegal(op.getType()) || !op.condition().getType().isa(); }); +target.addDynamicallyLegalOp( +[&](DimOp op) { return typeConverter.isLegal(op); }); if (failed( applyPartialConversion(getFunction(), target, std::move(patterns signalPassFailure(); diff --git a/mlir/lib/Transforms/Bufferize.cpp b/mlir/lib/Transforms/Bufferize.cpp index 1811ac8bdfbca..66b1cc65646c1 100644 --- a/mlir/lib/Transforms/Bufferize.cpp +++ b/mlir/lib/Transforms/Bufferize.cpp @@ -105,13 +105,17 @@ struct FinalizingBufferizePass populateEliminateBufferizeMaterializationsPatterns(context, typeConverter,
[llvm-branch-commits] [llvm] ae9fd55 - [SmallVector] Allow SmallVector
Author: Sean Silva Date: 2020-12-03T17:21:44-08:00 New Revision: ae9fd5578e8ab59bcffe1fd2b6a91531dff5bde6 URL: https://github.com/llvm/llvm-project/commit/ae9fd5578e8ab59bcffe1fd2b6a91531dff5bde6 DIFF: https://github.com/llvm/llvm-project/commit/ae9fd5578e8ab59bcffe1fd2b6a91531dff5bde6.diff LOG: [SmallVector] Allow SmallVector This patch adds a capability to SmallVector to decide a number of inlined elements automatically. The policy is: - A minimum of 1 inlined elements, with more as long as sizeof(SmallVector) <= 64. - If sizeof(T) is "too big", then trigger a static_assert: this dodges the more pathological cases This is expected to systematically improve SmallVector use in the LLVM codebase, which has historically been plagued by semi-arbitrary / cargo culted N parameters, often leading to bad outcomes due to excessive sizeof(SmallVector). This default also makes programming more convenient by avoiding edit/rebuild cycles due to forgetting to type the N parameter. Differential Revision: https://reviews.llvm.org/D92522 Added: Modified: llvm/docs/ProgrammersManual.rst llvm/include/llvm/ADT/SmallVector.h llvm/unittests/ADT/SmallVectorTest.cpp Removed: diff --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst index e303a7a18eba..7713a353ae1d 100644 --- a/llvm/docs/ProgrammersManual.rst +++ b/llvm/docs/ProgrammersManual.rst @@ -1521,6 +1521,12 @@ this makes the size of the SmallVector itself large, so you don't want to allocate lots of them (doing so will waste a lot of space). As such, SmallVectors are most useful when on the stack. +In the absence of a well-motivated choice for the number of +inlined elements ``N``, it is recommended to use ``SmallVector`` (that is, +omitting the ``N``). This will choose a default number of +inlined elements reasonable for allocation on the stack (for example, trying +to keep ``sizeof(SmallVector)`` around 64 bytes). + SmallVector also provides a nice portable and efficient replacement for ``alloca``. diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h index c5bb1ece0667..1b2787b88932 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -948,6 +948,64 @@ struct SmallVectorStorage { /// well-defined. template struct alignas(T) SmallVectorStorage {}; +/// Forward declaration of SmallVector so that +/// calculateSmallVectorDefaultInlinedElements can reference +/// `sizeof(SmallVector)`. +template class LLVM_GSL_OWNER SmallVector; + +/// Helper class for calculating the default number of inline elements for +/// `SmallVector`. +/// +/// This should be migrated to a constexpr function when our minimum +/// compiler support is enough for multi-statement constexpr functions. +template struct CalculateSmallVectorDefaultInlinedElements { + // Parameter controlling the default number of inlined elements + // for `SmallVector`. + // + // The default number of inlined elements ensures that + // 1. There is at least one inlined element. + // 2. `sizeof(SmallVector) <= kPreferredSmallVectorSizeof` unless + // it contradicts 1. + static constexpr size_t kPreferredSmallVectorSizeof = 64; + + // static_assert that sizeof(T) is not "too big". + // + // Because our policy guarantees at least one inlined element, it is possible + // for an arbitrarily large inlined element to allocate an arbitrarily large + // amount of inline storage. We generally consider it an antipattern for a + // SmallVector to allocate an excessive amount of inline storage, so we want + // to call attention to these cases and make sure that users are making an + // intentional decision if they request a lot of inline storage. + // + // We want this assertion to trigger in pathological cases, but otherwise + // not be too easy to hit. To accomplish that, the cutoff is actually somewhat + // larger than kPreferredSmallVectorSizeof (otherwise, + // `SmallVector>` would be one easy way to trip it, and that + // pattern seems useful in practice). + // + // One wrinkle is that this assertion is in theory non-portable, since + // sizeof(T) is in general platform-dependent. However, we don't expect this + // to be much of an issue, because most LLVM development happens on 64-bit + // hosts, and therefore sizeof(T) is expected to *decrease* when compiled for + // 32-bit hosts, dodging the issue. The reverse situation, where development + // happens on a 32-bit host and then fails due to sizeof(T) *increasing* on a + // 64-bit host, is expected to be very rare. + static_assert( + sizeof(T) <= 256, + "You are trying to use a default number of inlined elements for " + "`SmallVector` but `sizeof(T)` is really big! Please use an " + "explicit number of inlined elements with `SmallVector` to make " + "sure you really want that much inline stor
[llvm-branch-commits] [mlir] cab8dda - [mlir] Start splitting the `tensor` dialect out of `std`.
Author: Sean Silva Date: 2020-12-11T13:50:55-08:00 New Revision: cab8dda90f48e15ee94b0d55ceac5b6a812e4743 URL: https://github.com/llvm/llvm-project/commit/cab8dda90f48e15ee94b0d55ceac5b6a812e4743 DIFF: https://github.com/llvm/llvm-project/commit/cab8dda90f48e15ee94b0d55ceac5b6a812e4743.diff LOG: [mlir] Start splitting the `tensor` dialect out of `std`. This starts by moving `std.extract_element` to `tensor.extract` (this mirrors the naming of `vector.extract`). Curiously, `std.extract_element` supposedly works on vectors as well, and this patch removes that functionality. I would tend to do that in separate patch, but I couldn't find any downstream users relying on this, and the fact that we have `vector.extract` made it seem safe enough to lump in here. This also sets up the `tensor` dialect as a dependency of the `std` dialect, as some ops that currently live in `std` depend on `tensor.extract` via their canonicalization patterns. Part of RFC: https://llvm.discourse.group/t/rfc-split-the-tensor-dialect-from-std/2347/2 Differential Revision: https://reviews.llvm.org/D92991 Added: mlir/include/mlir/Dialect/Tensor/CMakeLists.txt mlir/include/mlir/Dialect/Tensor/IR/CMakeLists.txt mlir/include/mlir/Dialect/Tensor/IR/Tensor.h mlir/include/mlir/Dialect/Tensor/IR/TensorBase.td mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td mlir/include/mlir/Dialect/Tensor/Transforms/CMakeLists.txt mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h mlir/include/mlir/Dialect/Tensor/Transforms/Passes.td mlir/lib/Dialect/Tensor/CMakeLists.txt mlir/lib/Dialect/Tensor/IR/CMakeLists.txt mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp mlir/lib/Dialect/Tensor/IR/TensorOps.cpp mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp mlir/lib/Dialect/Tensor/Transforms/CMakeLists.txt mlir/lib/Dialect/Tensor/Transforms/PassDetail.h mlir/test/Dialect/Tensor/bufferize.mlir mlir/test/Dialect/Tensor/canonicalize.mlir mlir/test/Dialect/Tensor/invalid.mlir mlir/test/Dialect/Tensor/ops.mlir Modified: mlir/include/mlir/Dialect/CMakeLists.txt mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h mlir/include/mlir/Dialect/StandardOps/IR/Ops.td mlir/include/mlir/InitAllDialects.h mlir/include/mlir/InitAllPasses.h mlir/lib/Conversion/ShapeToStandard/ConvertShapeConstraints.cpp mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp mlir/lib/Dialect/CMakeLists.txt mlir/lib/Dialect/StandardOps/CMakeLists.txt mlir/lib/Dialect/StandardOps/IR/Ops.cpp mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp mlir/lib/Transforms/Utils/FoldUtils.cpp mlir/test/Conversion/ShapeToStandard/convert-shape-constraints.mlir mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir mlir/test/Dialect/Linalg/fusion-tensor.mlir mlir/test/Dialect/Standard/bufferize.mlir mlir/test/Dialect/Standard/canonicalize.mlir mlir/test/IR/core-ops.mlir mlir/test/IR/invalid-ops.mlir mlir/test/Transforms/canonicalize.mlir mlir/test/Transforms/constant-fold.mlir mlir/utils/vim/syntax/mlir.vim Removed: diff --git a/mlir/include/mlir/Dialect/CMakeLists.txt b/mlir/include/mlir/Dialect/CMakeLists.txt index 0df95ea4e937..034b611d6288 100644 --- a/mlir/include/mlir/Dialect/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/CMakeLists.txt @@ -14,5 +14,6 @@ add_subdirectory(SCF) add_subdirectory(Shape) add_subdirectory(SPIRV) add_subdirectory(StandardOps) +add_subdirectory(Tensor) add_subdirectory(Tosa) add_subdirectory(Vector) diff --git a/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h b/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h index 3575d55c3d53..0dd471c5d6d2 100644 --- a/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h @@ -10,6 +10,7 @@ #include "mlir/Dialect/Linalg/EDSC/Builders.h" #include "mlir/Dialect/Linalg/EDSC/Intrinsics.h" +#include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Transforms/FoldUtils.h" @@ -46,7 +47,6 @@ using folded_std_constant_float = FoldedValueBuilder; using folded_std_constant_index = FoldedValueBuilder; using folded_std_constant_int = FoldedValueBuilder; using folded_std_dim = FoldedValueBuilder; -using folded_std_extract_element = FoldedValueBuilder; using folded_std_index_cast = FoldedValueBuilder; using folded_std_muli = FoldedValueBuilder; using folded_std_mulf = FoldedValueBuilder; @@ -60,6 +60,7 @@ using folded_std_tensor_load = FoldedValueBuilder; using folded_std_view = FoldedValueBuilder; using folded_std_zero_extendi = FoldedValueBuilder; using folded_std_sign_extendi = FoldedValueBuilder; +using folded_tensor_extract = FoldedValueBuilder; } // namespace intrinsics } // namespace edsc } // namespace mlir diff
[llvm-branch-commits] [mlir] 0d48d26 - Revert "[mlir] Start splitting the `tensor` dialect out of `std`."
Author: Sean Silva Date: 2020-12-11T14:15:41-08:00 New Revision: 0d48d265db6633e4e575f81f9d3a52139b1dc5ca URL: https://github.com/llvm/llvm-project/commit/0d48d265db6633e4e575f81f9d3a52139b1dc5ca DIFF: https://github.com/llvm/llvm-project/commit/0d48d265db6633e4e575f81f9d3a52139b1dc5ca.diff LOG: Revert "[mlir] Start splitting the `tensor` dialect out of `std`." This reverts commit cab8dda90f48e15ee94b0d55ceac5b6a812e4743. I mistakenly thought that CAPI/ir.c failure was unrelated to this change. Need to debug it. Added: Modified: mlir/include/mlir/Dialect/CMakeLists.txt mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h mlir/include/mlir/Dialect/StandardOps/IR/Ops.td mlir/include/mlir/InitAllDialects.h mlir/include/mlir/InitAllPasses.h mlir/lib/Conversion/ShapeToStandard/ConvertShapeConstraints.cpp mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp mlir/lib/Dialect/CMakeLists.txt mlir/lib/Dialect/StandardOps/CMakeLists.txt mlir/lib/Dialect/StandardOps/IR/Ops.cpp mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp mlir/lib/Transforms/Utils/FoldUtils.cpp mlir/test/Conversion/ShapeToStandard/convert-shape-constraints.mlir mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir mlir/test/Dialect/Linalg/fusion-tensor.mlir mlir/test/Dialect/Standard/bufferize.mlir mlir/test/Dialect/Standard/canonicalize.mlir mlir/test/IR/core-ops.mlir mlir/test/IR/invalid-ops.mlir mlir/test/Transforms/canonicalize.mlir mlir/test/Transforms/constant-fold.mlir mlir/utils/vim/syntax/mlir.vim Removed: mlir/include/mlir/Dialect/Tensor/CMakeLists.txt mlir/include/mlir/Dialect/Tensor/IR/CMakeLists.txt mlir/include/mlir/Dialect/Tensor/IR/Tensor.h mlir/include/mlir/Dialect/Tensor/IR/TensorBase.td mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td mlir/include/mlir/Dialect/Tensor/Transforms/CMakeLists.txt mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h mlir/include/mlir/Dialect/Tensor/Transforms/Passes.td mlir/lib/Dialect/Tensor/CMakeLists.txt mlir/lib/Dialect/Tensor/IR/CMakeLists.txt mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp mlir/lib/Dialect/Tensor/IR/TensorOps.cpp mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp mlir/lib/Dialect/Tensor/Transforms/CMakeLists.txt mlir/lib/Dialect/Tensor/Transforms/PassDetail.h mlir/test/Dialect/Tensor/bufferize.mlir mlir/test/Dialect/Tensor/canonicalize.mlir mlir/test/Dialect/Tensor/invalid.mlir mlir/test/Dialect/Tensor/ops.mlir diff --git a/mlir/include/mlir/Dialect/CMakeLists.txt b/mlir/include/mlir/Dialect/CMakeLists.txt index 034b611d6288..0df95ea4e937 100644 --- a/mlir/include/mlir/Dialect/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/CMakeLists.txt @@ -14,6 +14,5 @@ add_subdirectory(SCF) add_subdirectory(Shape) add_subdirectory(SPIRV) add_subdirectory(StandardOps) -add_subdirectory(Tensor) add_subdirectory(Tosa) add_subdirectory(Vector) diff --git a/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h b/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h index 0dd471c5d6d2..3575d55c3d53 100644 --- a/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h @@ -10,7 +10,6 @@ #include "mlir/Dialect/Linalg/EDSC/Builders.h" #include "mlir/Dialect/Linalg/EDSC/Intrinsics.h" -#include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Transforms/FoldUtils.h" @@ -47,6 +46,7 @@ using folded_std_constant_float = FoldedValueBuilder; using folded_std_constant_index = FoldedValueBuilder; using folded_std_constant_int = FoldedValueBuilder; using folded_std_dim = FoldedValueBuilder; +using folded_std_extract_element = FoldedValueBuilder; using folded_std_index_cast = FoldedValueBuilder; using folded_std_muli = FoldedValueBuilder; using folded_std_mulf = FoldedValueBuilder; @@ -60,7 +60,6 @@ using folded_std_tensor_load = FoldedValueBuilder; using folded_std_view = FoldedValueBuilder; using folded_std_zero_extendi = FoldedValueBuilder; using folded_std_sign_extendi = FoldedValueBuilder; -using folded_tensor_extract = FoldedValueBuilder; } // namespace intrinsics } // namespace edsc } // namespace mlir diff --git a/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h b/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h index a9eed0984c80..1fe3246d4843 100644 --- a/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h +++ b/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h @@ -9,7 +9,6 @@ #define MLIR_DIALECT_STANDARDOPS_EDSC_INTRINSICS_H_ #include "mlir/Dialect/StandardOps/EDSC/Builders.h" -#include "mlir/Dialect/Tensor/IR/Tensor.h" namespace mlir { namespace edsc { @@ -29,6 +28,7 @@ using std_dealloc = OperationBuilder; using std_divis = ValueBui
[llvm-branch-commits] [mlir] 444822d - Revert "Revert "[mlir] Start splitting the `tensor` dialect out of `std`.""
Author: Sean Silva Date: 2020-12-11T14:30:50-08:00 New Revision: 444822d77a7fea28aa49edf24533c987efa1b2ee URL: https://github.com/llvm/llvm-project/commit/444822d77a7fea28aa49edf24533c987efa1b2ee DIFF: https://github.com/llvm/llvm-project/commit/444822d77a7fea28aa49edf24533c987efa1b2ee.diff LOG: Revert "Revert "[mlir] Start splitting the `tensor` dialect out of `std`."" This reverts commit 0d48d265db6633e4e575f81f9d3a52139b1dc5ca. This reapplies the following commit, with a fix for CAPI/ir.c: [mlir] Start splitting the `tensor` dialect out of `std`. This starts by moving `std.extract_element` to `tensor.extract` (this mirrors the naming of `vector.extract`). Curiously, `std.extract_element` supposedly works on vectors as well, and this patch removes that functionality. I would tend to do that in separate patch, but I couldn't find any downstream users relying on this, and the fact that we have `vector.extract` made it seem safe enough to lump in here. This also sets up the `tensor` dialect as a dependency of the `std` dialect, as some ops that currently live in `std` depend on `tensor.extract` via their canonicalization patterns. Part of RFC: https://llvm.discourse.group/t/rfc-split-the-tensor-dialect-from-std/2347/2 Differential Revision: https://reviews.llvm.org/D92991 Added: mlir/include/mlir/Dialect/Tensor/CMakeLists.txt mlir/include/mlir/Dialect/Tensor/IR/CMakeLists.txt mlir/include/mlir/Dialect/Tensor/IR/Tensor.h mlir/include/mlir/Dialect/Tensor/IR/TensorBase.td mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td mlir/include/mlir/Dialect/Tensor/Transforms/CMakeLists.txt mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h mlir/include/mlir/Dialect/Tensor/Transforms/Passes.td mlir/lib/Dialect/Tensor/CMakeLists.txt mlir/lib/Dialect/Tensor/IR/CMakeLists.txt mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp mlir/lib/Dialect/Tensor/IR/TensorOps.cpp mlir/lib/Dialect/Tensor/Transforms/Bufferize.cpp mlir/lib/Dialect/Tensor/Transforms/CMakeLists.txt mlir/lib/Dialect/Tensor/Transforms/PassDetail.h mlir/test/Dialect/Tensor/bufferize.mlir mlir/test/Dialect/Tensor/canonicalize.mlir mlir/test/Dialect/Tensor/invalid.mlir mlir/test/Dialect/Tensor/ops.mlir Modified: mlir/include/mlir/Dialect/CMakeLists.txt mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h mlir/include/mlir/Dialect/StandardOps/IR/Ops.td mlir/include/mlir/InitAllDialects.h mlir/include/mlir/InitAllPasses.h mlir/lib/Conversion/ShapeToStandard/ConvertShapeConstraints.cpp mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp mlir/lib/Dialect/CMakeLists.txt mlir/lib/Dialect/StandardOps/CMakeLists.txt mlir/lib/Dialect/StandardOps/IR/Ops.cpp mlir/lib/Dialect/StandardOps/Transforms/Bufferize.cpp mlir/lib/Transforms/Utils/FoldUtils.cpp mlir/test/CAPI/ir.c mlir/test/Conversion/ShapeToStandard/convert-shape-constraints.mlir mlir/test/Conversion/ShapeToStandard/shape-to-standard.mlir mlir/test/Dialect/Linalg/fusion-tensor.mlir mlir/test/Dialect/Standard/bufferize.mlir mlir/test/Dialect/Standard/canonicalize.mlir mlir/test/IR/core-ops.mlir mlir/test/IR/invalid-ops.mlir mlir/test/Transforms/canonicalize.mlir mlir/test/Transforms/constant-fold.mlir mlir/utils/vim/syntax/mlir.vim Removed: diff --git a/mlir/include/mlir/Dialect/CMakeLists.txt b/mlir/include/mlir/Dialect/CMakeLists.txt index 0df95ea4e937..034b611d6288 100644 --- a/mlir/include/mlir/Dialect/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/CMakeLists.txt @@ -14,5 +14,6 @@ add_subdirectory(SCF) add_subdirectory(Shape) add_subdirectory(SPIRV) add_subdirectory(StandardOps) +add_subdirectory(Tensor) add_subdirectory(Tosa) add_subdirectory(Vector) diff --git a/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h b/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h index 3575d55c3d53..0dd471c5d6d2 100644 --- a/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/FoldedIntrinsics.h @@ -10,6 +10,7 @@ #include "mlir/Dialect/Linalg/EDSC/Builders.h" #include "mlir/Dialect/Linalg/EDSC/Intrinsics.h" +#include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Transforms/FoldUtils.h" @@ -46,7 +47,6 @@ using folded_std_constant_float = FoldedValueBuilder; using folded_std_constant_index = FoldedValueBuilder; using folded_std_constant_int = FoldedValueBuilder; using folded_std_dim = FoldedValueBuilder; -using folded_std_extract_element = FoldedValueBuilder; using folded_std_index_cast = FoldedValueBuilder; using folded_std_muli = FoldedValueBuilder; using folded_std_mulf = FoldedValueBuilder; @@ -60,6 +60,7 @@ using folded_std_tensor_load = FoldedValueBuilder; using folded_std_view = FoldedValueBuilder; usi