diff --git a/mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h b/mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h --- a/mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h @@ -16,8 +16,11 @@ namespace edsc { namespace intrinsics { +using linalg_copy = OperationBuilder; using linalg_fill = OperationBuilder; +using linalg_range = ValueBuilder; using linalg_reshape = ValueBuilder; +using linalg_slice = ValueBuilder; using linalg_yield = OperationBuilder; } // namespace intrinsics diff --git a/mlir/include/mlir/Dialect/Linalg/Utils/Intrinsics.h b/mlir/include/mlir/Dialect/Linalg/Utils/Intrinsics.h deleted file mode 100644 --- a/mlir/include/mlir/Dialect/Linalg/Utils/Intrinsics.h +++ /dev/null @@ -1,29 +0,0 @@ -//===- Intrinsics.h - Linalg intrinsics definitions -----------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef MLIR_DIALECT_LINALG_INTRINSICS_H_ -#define MLIR_DIALECT_LINALG_INTRINSICS_H_ - -#include "mlir/EDSC/Intrinsics.h" - -namespace mlir { -namespace linalg { -class CopyOp; -class FillOp; -class RangeOp; -class SliceOp; -namespace intrinsics { -using copy = mlir::edsc::intrinsics::OperationBuilder; -using fill = mlir::edsc::intrinsics::OperationBuilder; -using range = mlir::edsc::intrinsics::ValueBuilder; -using slice = mlir::edsc::intrinsics::ValueBuilder; -} // namespace intrinsics -} // namespace linalg -} // namespace mlir - -#endif // MLIR_DIALECT_LINALG_INTRINSICS_H_ diff --git a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp --- a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp +++ b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp @@ -16,7 +16,6 @@ #include "mlir/Dialect/Linalg/IR/LinalgOps.h" #include "mlir/Dialect/Linalg/IR/LinalgTypes.h" #include "mlir/Dialect/Linalg/Passes.h" -#include "mlir/Dialect/Linalg/Utils/Intrinsics.h" #include "mlir/EDSC/Builders.h" #include "mlir/EDSC/Intrinsics.h" #include "mlir/IR/AffineExpr.h" @@ -47,7 +46,6 @@ using namespace mlir::edsc::intrinsics; using namespace mlir::LLVM; using namespace mlir::linalg; -using namespace mlir::linalg::intrinsics; using add = ValueBuilder; using addi = ValueBuilder; @@ -452,7 +450,8 @@ /// Conversion pattern specialization for CopyOp. This kicks in when both input /// and output permutations are left unspecified or are the identity. -template <> class LinalgOpConversion : public OpRewritePattern { +template <> +class LinalgOpConversion : public OpRewritePattern { public: using OpRewritePattern::OpRewritePattern; diff --git a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp @@ -15,7 +15,6 @@ #include "mlir/Dialect/Linalg/IR/LinalgOps.h" #include "mlir/Dialect/Linalg/IR/LinalgTypes.h" #include "mlir/Dialect/Linalg/Passes.h" -#include "mlir/Dialect/Linalg/Utils/Intrinsics.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" #include "mlir/EDSC/Helpers.h" #include "mlir/IR/AffineExpr.h" @@ -35,7 +34,6 @@ using namespace mlir::edsc; using namespace mlir::edsc::intrinsics; using namespace mlir::linalg; -using namespace mlir::linalg::intrinsics; using llvm::dbgs; diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp @@ -7,11 +7,11 @@ //===----------------------------------------------------------------------===// #include "mlir/Dialect/Linalg/EDSC/Builders.h" +#include "mlir/Dialect/Linalg/EDSC/Intrinsics.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" #include "mlir/Dialect/Linalg/IR/LinalgTypes.h" #include "mlir/Dialect/Linalg/Passes.h" #include "mlir/Dialect/Linalg/Transforms/LinalgTransforms.h" -#include "mlir/Dialect/Linalg/Utils/Intrinsics.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/StandardOps/Ops.h" @@ -30,7 +30,6 @@ using namespace mlir::edsc; using namespace mlir::edsc::intrinsics; using namespace mlir::linalg; -using namespace mlir::linalg::intrinsics; using IndexedStdValue = TemplatedIndexedValue; using IndexedAffineValue = TemplatedIndexedValue; @@ -77,7 +76,8 @@ ScopedContext scope(b, loc); SmallVector res; for (unsigned idx = 0, e = map.getNumResults(); idx < e; ++idx) { - res.push_back(range(constant_index(0), sizes[idx], constant_index(1))); + res.push_back( + linalg_range(constant_index(0), sizes[idx], constant_index(1))); } return res; } diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp @@ -13,7 +13,6 @@ #include "mlir/Dialect/Linalg/Transforms/LinalgTransforms.h" #include "mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" -#include "mlir/Dialect/Linalg/Utils/Intrinsics.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" #include "mlir/Dialect/VectorOps/VectorOps.h" #include "mlir/EDSC/Helpers.h" @@ -31,7 +30,6 @@ using namespace mlir::edsc; using namespace mlir::edsc::intrinsics; using namespace mlir::linalg; -using namespace mlir::linalg::intrinsics; using llvm::dbgs; using llvm::SetVector; diff --git a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp @@ -10,10 +10,10 @@ // //===----------------------------------------------------------------------===// +#include "mlir/Dialect/Linalg/EDSC/Intrinsics.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" #include "mlir/Dialect/Linalg/IR/LinalgTypes.h" #include "mlir/Dialect/Linalg/Passes.h" -#include "mlir/Dialect/Linalg/Utils/Intrinsics.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/EDSC/Helpers.h" @@ -33,7 +33,6 @@ using namespace mlir::edsc; using namespace mlir::edsc::intrinsics; using namespace mlir::linalg; -using namespace mlir::linalg::intrinsics; using namespace mlir::loop; using llvm::SetVector; @@ -93,14 +92,15 @@ Value d = rangeValue.size; allocSize = muli(folder, allocSize, d).getValue(); fullRanges.push_back(d); - partialRanges.push_back(range(folder, zero, dim(subView, rank), one)); + partialRanges.push_back( + linalg_range(folder, zero, dim(subView, rank), one)); } SmallVector dynSizes(fullRanges.size(), -1); auto buffer = allocBuffer(viewType.getElementType(), allocSize, dynamicBuffers); auto fullLocalView = view( MemRefType::get(dynSizes, viewType.getElementType()), buffer, fullRanges); - auto partialLocalView = slice(fullLocalView, partialRanges); + auto partialLocalView = linalg_slice(fullLocalView, partialRanges); return PromotionInfo{buffer, fullLocalView, partialLocalView}; } @@ -139,14 +139,15 @@ // TODO(ntv): fill is only necessary if `promotionInfo` has a full local // view that is different from the partial local view and we are on the // boundary. - fill(info->second.fullLocalView, fillVal); + linalg_fill(info->second.fullLocalView, fillVal); } for (auto v : subViews) { auto info = promotionInfoMap.find(v); if (info == promotionInfoMap.end()) continue; - copy(cast(v.getDefiningOp()), info->second.partialLocalView); + linalg_copy(cast(v.getDefiningOp()), + info->second.partialLocalView); } return res; } @@ -191,7 +192,8 @@ bool isOutput = op.getIndexOfOutputBuffer(viewAndPartialLocalView.first).hasValue(); if (isOutput) - copy(viewAndPartialLocalView.second, viewAndPartialLocalView.first); + linalg_copy(viewAndPartialLocalView.second, + viewAndPartialLocalView.first); } // 4. Dealloc local buffers. diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -14,7 +14,6 @@ #include "mlir/Dialect/Linalg/IR/LinalgOps.h" #include "mlir/Dialect/Linalg/IR/LinalgTypes.h" #include "mlir/Dialect/Linalg/Passes.h" -#include "mlir/Dialect/Linalg/Utils/Intrinsics.h" #include "mlir/Dialect/Linalg/Utils/Utils.h" #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/EDSC/Helpers.h" @@ -33,7 +32,6 @@ using namespace mlir::edsc; using namespace mlir::edsc::intrinsics; using namespace mlir::linalg; -using namespace mlir::linalg::intrinsics; using namespace mlir::loop; #define DEBUG_TYPE "linalg-tiling" diff --git a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp --- a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp @@ -13,7 +13,6 @@ #include "mlir/Dialect/Linalg/Utils/Utils.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" #include "mlir/Dialect/Linalg/IR/LinalgTypes.h" -#include "mlir/Dialect/Linalg/Utils/Intrinsics.h" #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/StandardOps/Ops.h" #include "mlir/EDSC/Helpers.h" @@ -28,7 +27,6 @@ using namespace mlir::edsc; using namespace mlir::edsc::intrinsics; using namespace mlir::linalg; -using namespace mlir::linalg::intrinsics; using namespace mlir::loop; static Value emitOrFoldComposedAffineApply(OpBuilder &b, Location loc,