-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[MLIR] XeGPU dialect for Intel GPU - core definitions and base classes #78483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
35440b9
add XeGPU dialect definition
chencha3 9cac285
update testcases
chencha3 a49d68c
Update mlir/include/mlir/Dialect/XeGPU/IR/XeGPUOps.td
chencha3 795a599
Update mlir/include/mlir/Dialect/XeGPU/IR/XeGPUTypes.td
chencha3 8224664
XeGPU dialect definition
chencha3 f871d16
format code
chencha3 86de798
remove xegpu testcases
chencha3 71192ab
cleanup code
chencha3 821e00d
code format
chencha3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(IR) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
add_mlir_dialect(XeGPU xegpu) | ||
add_mlir_doc(XeGPU XeGPU Dialects/ -gen-dialect-doc -dialect=xegpu) | ||
|
||
set(LLVM_TARGET_DEFINITIONS XeGPU.td) | ||
mlir_tablegen(XeGPUAttrs.h.inc -gen-attrdef-decls) | ||
mlir_tablegen(XeGPUAttrs.cpp.inc -gen-attrdef-defs) | ||
add_public_tablegen_target(MLIRXeGPUAttrsIncGen) | ||
add_dependencies(mlir-headers MLIRXeGPUAttrsIncGen) | ||
|
||
set(LLVM_TARGET_DEFINITIONS XeGPU.td) | ||
mlir_tablegen(XeGPUEnums.h.inc -gen-enum-decls) | ||
mlir_tablegen(XeGPUEnums.cpp.inc -gen-enum-defs) | ||
add_public_tablegen_target(MLIRXeGPUEnumsIncGen) | ||
add_dependencies(mlir-headers MLIRXeGPUEnumsIncGen) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//===- XeGPU.h - MLIR dialect for XeGPU -------------------------*- C++ -*-===// | ||
// | ||
// 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_XEGPU_IR_XEGPU_H | ||
#define MLIR_DIALECT_XEGPU_IR_XEGPU_H | ||
|
||
#include <mlir/IR/BuiltinTypes.h> | ||
#include <mlir/IR/Dialect.h> | ||
#include <mlir/IR/OpDefinition.h> | ||
#include <mlir/IR/Region.h> | ||
#include <mlir/IR/Types.h> | ||
#include <mlir/Interfaces/CastInterfaces.h> | ||
#include <mlir/Interfaces/ControlFlowInterfaces.h> | ||
#include <mlir/Interfaces/CopyOpInterface.h> | ||
#include <mlir/Interfaces/InferTypeOpInterface.h> | ||
#include <mlir/Interfaces/ShapedOpInterfaces.h> | ||
#include <mlir/Interfaces/SideEffectInterfaces.h> | ||
#include <mlir/Interfaces/ViewLikeInterface.h> | ||
|
||
namespace mlir { | ||
namespace xegpu { | ||
|
||
class TensorDescType; | ||
|
||
} // namespace xegpu | ||
} // namespace mlir | ||
|
||
#include <mlir/Dialect/XeGPU/IR/XeGPUDialect.h.inc> | ||
#include <mlir/Dialect/XeGPU/IR/XeGPUEnums.h.inc> | ||
#define GET_ATTRDEF_CLASSES | ||
#include <mlir/Dialect/XeGPU/IR/XeGPUAttrs.h.inc> | ||
#define GET_TYPEDEF_CLASSES | ||
#include <mlir/Dialect/XeGPU/IR/XeGPUTypes.h.inc> | ||
#define GET_OP_CLASSES | ||
#include <mlir/Dialect/XeGPU/IR/XeGPU.h.inc> | ||
|
||
#endif // MLIR_DIALECT_XEGPU_IR_XEGPU_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//===- XeGPU.td - XeGPU dialect definition ------------------*- tablegen -*-===// | ||
// | ||
// 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_XEGPU_IR_XEGPU_TD | ||
#define MLIR_DIALECT_XEGPU_IR_XEGPU_TD | ||
|
||
include "mlir/Dialect/XeGPU/IR/XeGPUOps.td" | ||
|
||
#endif // MLIR_DIALECT_XEGPU_IR_XEGPU_TD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//===- XeGPUAttrs.td - XeGPU dialect attributes definition --*- tablegen -*-===// | ||
// | ||
// 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_XEGPU_IR_XEGPUATTRS_TD | ||
#define MLIR_DIALECT_XEGPU_IR_XEGPUATTRS_TD | ||
|
||
include "mlir/Dialect/XeGPU/IR/XeGPUDialect.td" | ||
include "mlir/IR/EnumAttr.td" | ||
|
||
class XeGPUAttr<string name, string attrMnemonic, list<Trait> traits = [], | ||
string baseCppClass = "::mlir::Attribute"> | ||
: AttrDef<XeGPU_Dialect, name, traits, baseCppClass> { | ||
let mnemonic = attrMnemonic; | ||
} | ||
|
||
#endif // MLIR_DIALECT_XEGPU_IR_XEGPUATTRS_TD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//===- XeGPUDialect.td - XeGPU dialect definition -----------*- tablegen -*-===// | ||
// | ||
// 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_XEGPU_IR_XEGPUDIALECT_TD | ||
#define MLIR_DIALECT_XEGPU_IR_XEGPUDIALECT_TD | ||
|
||
include "mlir/IR/OpBase.td" | ||
include "mlir/IR/OpAsmInterface.td" | ||
include "mlir/IR/AttrTypeBase.td" | ||
include "mlir/IR/BuiltinTypes.td" | ||
include "mlir/IR/BuiltinTypeInterfaces.td" | ||
include "mlir/Interfaces/SideEffectInterfaces.td" | ||
include "mlir/Interfaces/ViewLikeInterface.td" | ||
include "mlir/Interfaces/CastInterfaces.td" | ||
include "mlir/Interfaces/ControlFlowInterfaces.td" | ||
include "mlir/Interfaces/CopyOpInterface.td" | ||
include "mlir/Interfaces/InferTypeOpInterface.td" | ||
include "mlir/Interfaces/ShapedOpInterfaces.td" | ||
|
||
def XeGPU_Dialect : Dialect { | ||
let name = "xegpu"; | ||
let cppNamespace = "::mlir::xegpu"; | ||
let summary = "The XeGPU dialect that models Intel GPU's ISA"; | ||
let description = [{ | ||
The XeGPU dialect models Intel Xe ISA semantics but works at vector and | ||
TensorDesc data type. It provides 1:1 mappings to match Xe instructions | ||
like DPAS and 2D block load. The matrix size being processed at this level | ||
exactly matches the hardware instructions or the intrinsic supported by | ||
the lower-level GPU compiler. | ||
}]; | ||
|
||
// let useDefaultTypePrinterParser = true; | ||
// let useDefaultAttributePrinterParser = true; | ||
} | ||
|
||
#endif // MLIR_DIALECT_XEGPU_IR_XEGPUDIALECT_TD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//===- XeGPUOps.td - XeGPU dialect operations definition ----*- tablegen -*-===// | ||
// | ||
// 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_XEGPU_IR_XEGPUOPS_TD | ||
#define MLIR_DIALECT_XEGPU_IR_XEGPUOPS_TD | ||
|
||
include "mlir/Dialect/XeGPU/IR/XeGPUAttrs.td" | ||
include "mlir/Dialect/XeGPU/IR/XeGPUDialect.td" | ||
include "mlir/Dialect/XeGPU/IR/XeGPUTypes.td" | ||
|
||
|
||
// Base class for dialect operations. This operation inherits from the base | ||
// `Op` class in OpBase.td, and provides: | ||
// * The parent dialect of the operation. | ||
// * The mnemonic for the operation, or the name without the dialect prefix. | ||
// * A list of traits for the operation. | ||
class XeGPU_Op<string mnemonic, list<Trait> traits = []>: | ||
Op<XeGPU_Dialect, mnemonic, traits>; | ||
|
||
|
||
#endif // MLIR_DIALECT_XEGPU_IR_XEGPUOPS_TD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//===- XeGPUTypes.td - XeGPU dialect types definition -------*- tablegen -*-===// | ||
// | ||
// 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_XEGPU_IR_XEGPUTYPES_TD | ||
#define MLIR_DIALECT_XEGPU_IR_XEGPUTYPES_TD | ||
|
||
include "mlir/IR/BuiltinTypes.td" | ||
|
||
include "mlir/Dialect/XeGPU/IR/XeGPUAttrs.td" | ||
include "mlir/Dialect/XeGPU/IR/XeGPUDialect.td" | ||
|
||
def XeGPU_IntType: AnyTypeOf<[I1, I8, I16, I32, I64, SI1, SI8, SI16, SI32, SI64, UI1, UI8, UI16, UI32, UI64]>; | ||
def XeGPU_FloatType: AnyTypeOf<[F16, F32, F64, BF16, TF32]>; | ||
def XeGPU_ScalarType: AnyTypeOf<[XeGPU_IntType, XeGPU_FloatType]>; | ||
def XeGPU_BaseAddrType: AnyTypeOf<[MemRefRankOf<[XeGPU_ScalarType], [1, 2]>, UI64, UI32, I64, I32]>; | ||
def XeGPU_DpasOpType: VectorOfRankAndType<[2, 3], [XeGPU_ScalarType]>; | ||
def XeGPU_OffsetType: VectorOfRankAndType<[1], [Index]>; | ||
def XeGPU_MaskType: AnyTypeOf<[VectorOfRankAndType<[1,2], [I1]>, I1]>; | ||
def XeGPU_ValueType: AnyTypeOf<[VectorOfRankAndType<[1,2,3,4], [XeGPU_ScalarType]>, XeGPU_ScalarType]>; | ||
def XeGPU_Vector2DType: VectorOfRankAndType<[2], [XeGPU_ScalarType]>; | ||
|
||
// common base class for types in XeGPU dialect | ||
class XeGPUTypeDef<string name, string typeMnemonic, list<Trait> traits = [], | ||
string baseCppClass = "::mlir::Type"> | ||
: TypeDef<XeGPU_Dialect, name, traits, baseCppClass> { | ||
let mnemonic = typeMnemonic; | ||
} | ||
|
||
#endif // MLIR_DIALECT_XEGPU_IR_XEGPUTYPES_TD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(IR) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
add_mlir_dialect_library(MLIRXeGPUDialect | ||
XeGPUDialect.cpp | ||
XeGPUOps.cpp | ||
|
||
ADDITIONAL_HEADER_DIRS | ||
${PROJECT_SOURCE_DIR}/include/mlir/Dialect/XeGPU | ||
|
||
DEPENDS | ||
MLIRXeGPUIncGen | ||
MLIRXeGPUAttrsIncGen | ||
MLIRXeGPUEnumsIncGen | ||
|
||
LINK_LIBS PUBLIC | ||
MLIRIR | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//===- XeGPUDialect.cpp - MLIR XeGPU dialect implementation -----*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include <llvm/ADT/TypeSwitch.h> | ||
#include <llvm/Support/Debug.h> | ||
#include <mlir/Dialect/XeGPU/IR/XeGPU.h> | ||
|
||
#include <mlir/Dialect/Arith/IR/Arith.h> | ||
#include <mlir/Dialect/Linalg/IR/Linalg.h> | ||
#include <mlir/Dialect/MemRef/IR/MemRef.h> | ||
#include <mlir/Dialect/Tensor/IR/Tensor.h> | ||
#include <mlir/Dialect/Utils/StaticValueUtils.h> | ||
#include <mlir/IR/Builders.h> | ||
#include <mlir/IR/DialectImplementation.h> | ||
#include <mlir/IR/TypeUtilities.h> | ||
|
||
#include <numeric> | ||
|
||
namespace mlir { | ||
namespace xegpu { | ||
|
||
void XeGPUDialect::initialize() { | ||
addTypes< | ||
#define GET_TYPEDEF_LIST | ||
#include <mlir/Dialect/XeGPU/IR/XeGPUTypes.cpp.inc> | ||
>(); | ||
addOperations< | ||
#define GET_OP_LIST | ||
#include <mlir/Dialect/XeGPU/IR/XeGPU.cpp.inc> | ||
>(); | ||
addAttributes< | ||
#define GET_ATTRDEF_LIST | ||
#include <mlir/Dialect/XeGPU/IR/XeGPUAttrs.cpp.inc> | ||
>(); | ||
} | ||
|
||
// this file is for position occupation, | ||
// we will add functions in following PRs. | ||
|
||
} // namespace xegpu | ||
} // namespace mlir | ||
|
||
#include <mlir/Dialect/XeGPU/IR/XeGPUDialect.cpp.inc> | ||
#define GET_ATTRDEF_CLASSES | ||
#include <mlir/Dialect/XeGPU/IR/XeGPUAttrs.cpp.inc> | ||
#define GET_TYPEDEF_CLASSES | ||
#include <mlir/Dialect/XeGPU/IR/XeGPUTypes.cpp.inc> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//===- XeGPUOps.cpp - MLIR XeGPU ops implementation -------------*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include <llvm/ADT/TypeSwitch.h> | ||
#include <llvm/Support/Debug.h> | ||
#include <mlir/Dialect/Arith/IR/Arith.h> | ||
#include <mlir/Dialect/Linalg/IR/Linalg.h> | ||
#include <mlir/Dialect/MemRef/IR/MemRef.h> | ||
#include <mlir/Dialect/Tensor/IR/Tensor.h> | ||
#include <mlir/Dialect/Utils/StaticValueUtils.h> | ||
#include <mlir/Dialect/XeGPU/IR/XeGPU.h> | ||
#include <mlir/IR/Builders.h> | ||
#include <mlir/IR/DialectImplementation.h> | ||
#include <mlir/IR/TypeUtilities.h> | ||
#include <numeric> | ||
#include <type_traits> | ||
|
||
#define DEBUG_TYPE "xegpu" | ||
|
||
namespace mlir { | ||
class Token; | ||
rengolin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
namespace xegpu { | ||
// this file is for position occupation, | ||
// we will add functions in following PRs. | ||
|
||
} // namespace xegpu | ||
} // namespace mlir | ||
|
||
#include <mlir/Dialect/XeGPU/IR/XeGPUEnums.cpp.inc> | ||
#define GET_OP_CLASSES | ||
#include <mlir/Dialect/XeGPU/IR/XeGPU.cpp.inc> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.