diff --git a/include/imex/Dialect/XeTile/Transforms/Blocking.h b/include/imex/Dialect/XeTile/Transforms/Blocking.h deleted file mode 100644 index 95a7473d7..000000000 --- a/include/imex/Dialect/XeTile/Transforms/Blocking.h +++ /dev/null @@ -1,113 +0,0 @@ -//===- Blocking.h ----------- Blocking Pass ---------*- C++ -*------------===// -// -// Copyright 2024 Intel Corporation -// Part of the IMEX 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 -// -//===----------------------------------------------------------------------===// -/// -/// \file -/// This file contains lowering transformation for determing the problem size -/// that can be handled by an XeGPU operator (hardware instruction). XeTile -/// program can work one bigger problem size that cannot be handled by a -/// hardware instruction. But it needs to be decomposed into smaller pieces -/// such that each pieces can be handled by a hardware instruction. -/////===----------------------------------------------------------------------===// -#ifndef _XeTileTranformBase_H_INCLUDED_ -#define _XeTileTranformBase_H_INCLUDED_ - -#include -#include -#include -#include -#include -#include -#include - -#include "imex/Dialect/XeTile/IR/XeTileOps.h" -#include "imex/Utils/DebugUtils.h" -#include "imex/Utils/PassWrapper.h" -#include "imex/Utils/XeCommon.h" - -namespace imex { - -template -class XeTileConversion : public imex::XeConversionPattern { -public: - using OpAdaptor = typename SourceOp::Adaptor; - using OpPatternRewriter = typename mlir::PatternRewriter; - - XeTileConversion(mlir::MLIRContext *context, XeTypeConverter &typeConverter, - AnalysisT &analysis, mlir::PatternBenefit benefit = 1) - : XeConversionPattern(typeConverter, analysis, - SourceOp::getOperationName(), benefit, - context) {} - - mlir::LogicalResult - matchAndRewrite(mlir::Operation *op, - mlir::PatternRewriter &rewriter) const override final { - auto sourceOp = llvm::cast(op); - OpAdaptor adaptor(op->getOperands(), sourceOp); - return matchAndRewrite(sourceOp, adaptor, rewriter); - } - - virtual mlir::LogicalResult - matchAndRewrite(SourceOp op, OpAdaptor adaptor, - OpPatternRewriter &rewriter) const { - llvm_unreachable("must override matchAndRewrite or a rewrite method"); - } - - xetile::TileUnpackOp addUnpackOp(mlir::Value src, - OpPatternRewriter &rewriter) const { - auto srcTy = llvm::dyn_cast_if_present(src.getType()); - assert(srcTy && srcTy.getRank() == 4); - auto shape = srcTy.getShape(); - auto grids = shape.take_front(2); - auto innerBlocks = shape.take_back(2); - llvm::SmallVector unpackShape( - {grids[0] * innerBlocks[0], grids[1] * innerBlocks[1]}); - - auto unpackTy = mlir::VectorType::get(unpackShape, srcTy.getElementType()); - return rewriter.create( - src.getLoc(), unpackTy, src, - mlir::DenseI64ArrayAttr::get(src.getContext(), innerBlocks)); - } - - mlir::Value addPackOp(mlir::Value src, llvm::ArrayRef targetBlkSizes, - OpPatternRewriter &rewriter) const { - auto srcTy = mlir::dyn_cast(src.getType()); - assert(srcTy && targetBlkSizes.size() == 2); - auto shape = srcTy.getShape(); - llvm::SmallVector packShape( - {shape[0] / targetBlkSizes[0], shape[1] / targetBlkSizes[1], - targetBlkSizes[0], targetBlkSizes[1]}); - - auto packTy = mlir::VectorType::get(packShape, srcTy.getElementType()); - auto packOp = rewriter.create( - src.getLoc(), packTy, src, - mlir::DenseI64ArrayAttr::get(src.getContext(), targetBlkSizes)); - return packOp; - } - - mlir::Value addUnpackAndPackOps(mlir::Value src, - llvm::ArrayRef targetBlocks, - OpPatternRewriter &rewriter) const { - auto unpack = addUnpackOp(src, rewriter); - return addPackOp(unpack, targetBlocks, rewriter); - } -}; - -template