-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[mlir][Vector] Add fastmath flags to vector.reduction #66905
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 all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
@@ -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 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,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 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,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 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this file be called
VectorBase.td
as other dialects do?