-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AMD] Add TritonAMDGPU dialect scaffolding (#4685)
This PR adds an TritonAMDGPU dialect to host future AMD specific ops to help with AMD backend CodeGen. --------- Co-authored-by: Ognjen Plavsic <[email protected]> Co-authored-by: Lei Zhang <[email protected]>
- Loading branch information
1 parent
3ae95a8
commit d6a11a4
Showing
20 changed files
with
268 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
add_subdirectory(Dialect) | ||
add_subdirectory(TritonAMDGPUToLLVM) | ||
add_subdirectory(TritonAMDGPUTransforms) |
This file contains 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(TritonAMDGPU) |
This file contains 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) |
16 changes: 16 additions & 0 deletions
16
third_party/amd/include/Dialect/TritonAMDGPU/IR/CMakeLists.txt
This file contains 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,16 @@ | ||
set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR}) | ||
|
||
set(LLVM_TARGET_DEFINITIONS TritonAMDGPUOps.td) | ||
mlir_tablegen(Dialect.h.inc -gen-dialect-decls -dialect=amdgpu) | ||
mlir_tablegen(Dialect.cpp.inc -gen-dialect-defs -dialect=amdgpu) | ||
mlir_tablegen(OpsConversions.inc -gen-llvmir-conversions) | ||
mlir_tablegen(Ops.h.inc -gen-op-decls) | ||
mlir_tablegen(Ops.cpp.inc -gen-op-defs) | ||
add_mlir_doc(TritonAMDGPUDialect TritonAMDGPUDialect dialects/ -gen-dialect-doc) | ||
add_mlir_doc(TritonAMDGPUOps TritonAMDGPUOps dialects/ -gen-op-doc) | ||
add_public_tablegen_target(TritonAMDGPUTableGen) | ||
|
||
set(LLVM_TARGET_DEFINITIONS TritonAMDGPUAttrDefs.td) | ||
mlir_tablegen(TritonAMDGPUAttrDefs.h.inc -gen-attrdef-decls) | ||
mlir_tablegen(TritonAMDGPUAttrDefs.cpp.inc -gen-attrdef-defs) | ||
add_public_tablegen_target(TritonAMDGPUAttrDefsIncGen) |
This file contains 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,48 @@ | ||
/* | ||
* Copyright (c) 2024, Advanced Micro Devices, Inc. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files | ||
* (the "Software"), to deal in the Software without restriction, | ||
* including without limitation the rights to use, copy, modify, merge, | ||
* publish, distribute, sublicense, and/or sell copies of the Software, | ||
* and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#ifndef TRITON_DIALECT_AMDGPU_IR_DIALECT_H_ | ||
#define TRITON_DIALECT_AMDGPU_IR_DIALECT_H_ | ||
|
||
#include "mlir/Dialect/LLVMIR/LLVMDialect.h" | ||
#include "mlir/Dialect/Tensor/IR/Tensor.h" | ||
#include "mlir/IR/BuiltinOps.h" | ||
#include "mlir/IR/Dialect.h" | ||
#include "mlir/IR/PatternMatch.h" | ||
// clang-format off | ||
#include "amd/include/Dialect/TritonAMDGPU/IR/Dialect.h.inc" | ||
// clang-format on | ||
|
||
#define GET_ATTRDEF_CLASSES | ||
#include "amd/include/Dialect/TritonAMDGPU/IR/TritonAMDGPUAttrDefs.h.inc" | ||
|
||
#define GET_OP_CLASSES | ||
#include "amd/include/Dialect/TritonAMDGPU/IR/Ops.h.inc" | ||
|
||
namespace mlir { | ||
namespace triton { | ||
namespace amdgpu {} // namespace amdgpu | ||
} // namespace triton | ||
} // namespace mlir | ||
|
||
#endif // TRITON_DIALECT_TRITONGPU_IR_DIALECT_H_ |
35 changes: 35 additions & 0 deletions
35
third_party/amd/include/Dialect/TritonAMDGPU/IR/TritonAMDGPUAttrDefs.td
This file contains 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,35 @@ | ||
/* | ||
* Copyright (c) 2024, Advanced Micro Devices, Inc. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files | ||
* (the "Software"), to deal in the Software without restriction, | ||
* including without limitation the rights to use, copy, modify, merge, | ||
* publish, distribute, sublicense, and/or sell copies of the Software, | ||
* and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#ifndef TRITON_AMDGPU_ATTRDEFS | ||
#define TRITON_AMDGPU_ATTRDEFS | ||
|
||
include "mlir/IR/AttrTypeBase.td" | ||
include "TritonAMDGPUDialect.td" | ||
|
||
class TritonAMDGPU_Attr<string name, list<Trait> traits = [], | ||
string baseCppClass = "::mlir::Attribute"> | ||
: AttrDef<TritonAMDGPU_Dialect, name, traits, baseCppClass> { | ||
} | ||
|
||
#endif |
40 changes: 40 additions & 0 deletions
40
third_party/amd/include/Dialect/TritonAMDGPU/IR/TritonAMDGPUDialect.td
This file contains 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,40 @@ | ||
/* | ||
* Copyright (c) 2024, Advanced Micro Devices, Inc. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files | ||
* (the "Software"), to deal in the Software without restriction, | ||
* including without limitation the rights to use, copy, modify, merge, | ||
* publish, distribute, sublicense, and/or sell copies of the Software, | ||
* and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#ifndef TRITON_AMDGPU_DIALECT | ||
#define TRITON_AMDGPU_DIALECT | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def TritonAMDGPU_Dialect : Dialect { | ||
let name = "amdgpu"; | ||
let cppNamespace = "::mlir::triton::amdgpu"; | ||
|
||
let description = [{ | ||
TritonAMDGPU Dialect hosts AMD specific ops at TritonGPU abstraction level. | ||
}]; | ||
|
||
let dependentDialects = []; | ||
} | ||
|
||
#endif |
35 changes: 35 additions & 0 deletions
35
third_party/amd/include/Dialect/TritonAMDGPU/IR/TritonAMDGPUOps.td
This file contains 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,35 @@ | ||
/* | ||
* Copyright (c) 2024, Advanced Micro Devices, Inc. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files | ||
* (the "Software"), to deal in the Software without restriction, | ||
* including without limitation the rights to use, copy, modify, merge, | ||
* publish, distribute, sublicense, and/or sell copies of the Software, | ||
* and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
|
||
#ifndef TRITON_AMDGPU_OPS | ||
#define TRITON_AMDGPU_OPS | ||
|
||
include "mlir/IR/OpBase.td" | ||
include "mlir/IR/EnumAttr.td" | ||
include "mlir/Dialect/LLVMIR/LLVMOpBase.td" | ||
include "mlir/Interfaces/InferTypeOpInterface.td" | ||
include "TritonAMDGPUDialect.td" | ||
include "TritonAMDGPUAttrDefs.td" | ||
|
||
#endif |
This file contains 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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
add_subdirectory(Dialect) | ||
add_subdirectory(TritonAMDGPUToLLVM) | ||
add_subdirectory(TritonAMDGPUDialectToLLVM) | ||
add_subdirectory(TritonAMDGPUTransforms) |
This file contains 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(TritonAMDGPU) |
This file contains 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) |
12 changes: 12 additions & 0 deletions
12
third_party/amd/lib/Dialect/TritonAMDGPU/IR/CMakeLists.txt
This file contains 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,12 @@ | ||
add_triton_library(TritonAMDGPUIR | ||
Dialect.cpp | ||
|
||
DEPENDS | ||
TritonAMDGPUTableGen | ||
TritonAMDGPUAttrDefsIncGen | ||
|
||
LINK_LIBS PUBLIC | ||
MLIRLLVMDialect | ||
TritonIR | ||
TritonGPUIR | ||
) |
This file contains 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,48 @@ | ||
/* | ||
* Copyright (c) 2024, Advanced Micro Devices, Inc. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files | ||
* (the "Software"), to deal in the Software without restriction, | ||
* including without limitation the rights to use, copy, modify, merge, | ||
* publish, distribute, sublicense, and/or sell copies of the Software, | ||
* and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#include "mlir/IR/DialectImplementation.h" | ||
#include "mlir/IR/OpImplementation.h" | ||
|
||
// clang-format off | ||
#include "Dialect/TritonAMDGPU/IR/Dialect.h" | ||
#include "Dialect/TritonAMDGPU/IR/Dialect.cpp.inc" | ||
// clang-format on | ||
|
||
using namespace mlir; | ||
using namespace mlir::triton::amdgpu; | ||
|
||
void mlir::triton::amdgpu::TritonAMDGPUDialect::initialize() { | ||
addAttributes< | ||
#define GET_ATTRDEF_LIST | ||
#include "Dialect/TritonAMDGPU/IR/TritonAMDGPUAttrDefs.cpp.inc" | ||
>(); | ||
|
||
addOperations< | ||
#define GET_OP_LIST | ||
#include "Dialect/TritonAMDGPU/IR/Ops.cpp.inc" | ||
>(); | ||
} | ||
|
||
#define GET_OP_CLASSES | ||
#include "Dialect/TritonAMDGPU/IR/Ops.cpp.inc" |
This file contains 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,6 @@ | ||
add_triton_library(TritonAMDGPUDialectToLLVM | ||
TritonAMDGPUToLLVMPatterns.cpp | ||
|
||
DEPENDS | ||
TritonAMDGPUIR | ||
) |
9 changes: 9 additions & 0 deletions
9
third_party/amd/lib/TritonAMDGPUDialectToLLVM/TritonAMDGPUToLLVMPatterns.cpp
This file contains 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,9 @@ | ||
#include "triton/Conversion/TritonGPUToLLVM/PatternTritonGPUOpToLLVM.h" | ||
|
||
namespace mlir::triton::AMD { | ||
void populateTritonAMDGPUToLLVMPatterns(LLVMTypeConverter &typeConverter, | ||
RewritePatternSet &patterns, | ||
PatternBenefit benefit) { | ||
// TODO: Insert TrtionAMDGPU dialect patterns. | ||
} | ||
} // namespace mlir::triton::AMD |
This file contains 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 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 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