forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mlir][Vector] Add fastmath flags to vector.reduction (llvm#66905)
This revision pipes the fastmath attribute support through the vector.reduction op. This seemingly simple first step already requires quite some genuflexions, file and builder reorganization. In the process, retire the boolean reassoc flag deep in the LLVM dialect builders and just use the fastmath attribute. During conversions, templated builders for predicated intrinsics are partially cleaned up. In the future, to finalize the cleanups, one should consider adding fastmath to the VPIntrinsic ops.
- Loading branch information
1 parent
ebefe83
commit 1b8b556
Showing
15 changed files
with
322 additions
and
226 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
add_mlir_dialect(VectorOps vector) | ||
add_mlir_doc(VectorOps VectorOps Dialects/ -gen-op-doc) | ||
add_mlir_dialect(Vector vector) | ||
add_mlir_doc(Vector Vector Dialects/ -gen-op-doc -dialect=vector) | ||
|
||
# Add Vector operations | ||
set(LLVM_TARGET_DEFINITIONS VectorOps.td) | ||
mlir_tablegen(VectorOpsEnums.h.inc -gen-enum-decls) | ||
mlir_tablegen(VectorOpsEnums.cpp.inc -gen-enum-defs) | ||
mlir_tablegen(VectorOpsAttrDefs.h.inc -gen-attrdef-decls) | ||
mlir_tablegen(VectorOpsAttrDefs.cpp.inc -gen-attrdef-defs) | ||
add_public_tablegen_target(MLIRVectorOpsEnumsIncGen) | ||
add_dependencies(mlir-headers MLIRVectorOpsEnumsIncGen) | ||
mlir_tablegen(VectorOps.h.inc -gen-op-decls) | ||
mlir_tablegen(VectorOps.cpp.inc -gen-op-defs) | ||
add_public_tablegen_target(MLIRVectorOpsIncGen) | ||
add_dependencies(mlir-generic-headers MLIRVectorOpsIncGen) | ||
|
||
# Add Vector attributes | ||
set(LLVM_TARGET_DEFINITIONS VectorAttributes.td) | ||
mlir_tablegen(VectorEnums.h.inc -gen-enum-decls) | ||
mlir_tablegen(VectorEnums.cpp.inc -gen-enum-defs) | ||
mlir_tablegen(VectorAttributes.h.inc -gen-attrdef-decls) | ||
mlir_tablegen(VectorAttributes.cpp.inc -gen-attrdef-defs) | ||
add_public_tablegen_target(MLIRVectorAttributesIncGen) | ||
add_dependencies(mlir-generic-headers MLIRVectorAttributesIncGen) |
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,31 @@ | ||
//===- Vector.td - Vector Dialect --------------------------*- 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file declares the Vector dialect. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_DIALECT_VECTOR_IR_VECTOR | ||
#define MLIR_DIALECT_VECTOR_IR_VECTOR | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def Vector_Dialect : Dialect { | ||
let name = "vector"; | ||
let cppNamespace = "::mlir::vector"; | ||
|
||
let useDefaultAttributePrinterParser = 1; | ||
let hasConstantMaterializer = 1; | ||
let dependentDialects = ["arith::ArithDialect"]; | ||
} | ||
|
||
// Base class for Vector dialect ops. | ||
class Vector_Op<string mnemonic, list<Trait> traits = []> : | ||
Op<Vector_Dialect, mnemonic, traits>; | ||
|
||
#endif // MLIR_DIALECT_VECTOR_IR_VECTOR |
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,85 @@ | ||
//===- VectorAttributes.td - Vector Dialect ----------------*- 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file declares the attributes used in the Vector dialect. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_DIALECT_VECTOR_IR_VECTOR_ATTRIBUTES | ||
#define MLIR_DIALECT_VECTOR_IR_VECTOR_ATTRIBUTES | ||
|
||
include "mlir/Dialect/Vector/IR/Vector.td" | ||
include "mlir/IR/EnumAttr.td" | ||
|
||
// The "kind" of combining function for contractions and reductions. | ||
def COMBINING_KIND_ADD : I32BitEnumAttrCaseBit<"ADD", 0, "add">; | ||
def COMBINING_KIND_MUL : I32BitEnumAttrCaseBit<"MUL", 1, "mul">; | ||
def COMBINING_KIND_MINUI : I32BitEnumAttrCaseBit<"MINUI", 2, "minui">; | ||
def COMBINING_KIND_MINSI : I32BitEnumAttrCaseBit<"MINSI", 3, "minsi">; | ||
def COMBINING_KIND_MINF : I32BitEnumAttrCaseBit<"MINF", 4, "minf">; | ||
def COMBINING_KIND_MAXUI : I32BitEnumAttrCaseBit<"MAXUI", 5, "maxui">; | ||
def COMBINING_KIND_MAXSI : I32BitEnumAttrCaseBit<"MAXSI", 6, "maxsi">; | ||
def COMBINING_KIND_MAXF : I32BitEnumAttrCaseBit<"MAXF", 7, "maxf">; | ||
def COMBINING_KIND_AND : I32BitEnumAttrCaseBit<"AND", 8, "and">; | ||
def COMBINING_KIND_OR : I32BitEnumAttrCaseBit<"OR", 9, "or">; | ||
def COMBINING_KIND_XOR : I32BitEnumAttrCaseBit<"XOR", 10, "xor">; | ||
def COMBINING_KIND_MINIMUMF : I32BitEnumAttrCaseBit<"MINIMUMF", 11, "minimumf">; | ||
def COMBINING_KIND_MAXIMUMF : I32BitEnumAttrCaseBit<"MAXIMUMF", 12, "maximumf">; | ||
|
||
def CombiningKind : I32BitEnumAttr< | ||
"CombiningKind", | ||
"Kind of combining function for contractions and reductions", | ||
[COMBINING_KIND_ADD, COMBINING_KIND_MUL, COMBINING_KIND_MINUI, | ||
COMBINING_KIND_MINSI, COMBINING_KIND_MINF, COMBINING_KIND_MAXUI, | ||
COMBINING_KIND_MAXSI, COMBINING_KIND_MAXF, COMBINING_KIND_AND, | ||
COMBINING_KIND_OR, COMBINING_KIND_XOR, | ||
COMBINING_KIND_MAXIMUMF, COMBINING_KIND_MINIMUMF]> { | ||
let cppNamespace = "::mlir::vector"; | ||
let genSpecializedAttr = 0; | ||
} | ||
|
||
/// An attribute that specifies the combining function for `vector.contract`, | ||
/// and `vector.reduction`. | ||
def Vector_CombiningKindAttr : EnumAttr<Vector_Dialect, CombiningKind, "kind"> { | ||
let assemblyFormat = "`<` $value `>`"; | ||
} | ||
|
||
def Vector_IteratorType : I32EnumAttr<"IteratorType", "Iterator type", [ | ||
I32EnumAttrCase<"parallel", 0>, | ||
I32EnumAttrCase<"reduction", 1> | ||
]> { | ||
let genSpecializedAttr = 0; | ||
let cppNamespace = "::mlir::vector"; | ||
} | ||
|
||
def Vector_IteratorTypeEnum | ||
: EnumAttr<Vector_Dialect, Vector_IteratorType, "iterator_type"> { | ||
let assemblyFormat = "`<` $value `>`"; | ||
} | ||
|
||
def Vector_IteratorTypeArrayAttr | ||
: TypedArrayAttrBase<Vector_IteratorTypeEnum, | ||
"Iterator type should be an enum.">; | ||
|
||
def PrintPunctuation : I32EnumAttr<"PrintPunctuation", | ||
"Punctuation for separating vectors or vector elements", [ | ||
I32EnumAttrCase<"NoPunctuation", 0, "no_punctuation">, | ||
I32EnumAttrCase<"NewLine", 1, "newline">, | ||
I32EnumAttrCase<"Comma", 2, "comma">, | ||
I32EnumAttrCase<"Open", 3, "open">, | ||
I32EnumAttrCase<"Close", 4, "close"> | ||
]> { | ||
let cppNamespace = "::mlir::vector"; | ||
let genSpecializedAttr = 0; | ||
} | ||
|
||
def Vector_PrintPunctuation : EnumAttr<Vector_Dialect, PrintPunctuation, "punctuation"> { | ||
let assemblyFormat = "`<` $value `>`"; | ||
} | ||
|
||
#endif // MLIR_DIALECT_VECTOR_IR_VECTOR_ATTRIBUTES |
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
Oops, something went wrong.