-
Notifications
You must be signed in to change notification settings - Fork 73
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
misc: split dialects.utils into multiple files #3472
Changes from all commits
5b15824
a55afb1
7b48fc8
4ed292c
8968ff3
eae169d
a35fd9a
5980046
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# TID 251 enforces to not import from those | ||
# We need to skip it here to allow importing from here instead. | ||
from .fast_math import * # noqa: TID251 | ||
from .format import * # noqa: TID251 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from abc import ABC | ||
from dataclasses import dataclass | ||
|
||
from xdsl.ir import BitEnumAttribute | ||
from xdsl.utils.str_enum import StrEnum | ||
|
||
|
||
class FastMathFlag(StrEnum): | ||
""" | ||
Values specifying fast math behaviour of an arithmetic operation. | ||
""" | ||
|
||
REASSOC = "reassoc" | ||
NO_NANS = "nnan" | ||
NO_INFS = "ninf" | ||
NO_SIGNED_ZEROS = "nsz" | ||
ALLOW_RECIP = "arcp" | ||
ALLOW_CONTRACT = "contract" | ||
APPROX_FUNC = "afn" | ||
|
||
|
||
@dataclass(frozen=True, init=False) | ||
class FastMathAttrBase(BitEnumAttribute[FastMathFlag], ABC): | ||
""" | ||
Base class for attributes defining fast math behavior of arithmetic operations. | ||
""" | ||
|
||
none_value = "none" | ||
all_value = "fast" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
from abc import ABC | ||
from collections.abc import Iterable, Sequence | ||
from dataclasses import dataclass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tend to be quite coupled to each other, so it made sense to keep them together. I agree that the name isn't great, but I can't think of a better one... We could also go with the irdl and ir route and ban the sub files of the utils, and expose it all via There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll try that quickly, will result in smaller diff and probably a better experience There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand the point of the irdl approach, just seems to cause loads of linting errors for me There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For some reason, the local development experience is worse than for clients, Pylance automatically inserts the correct import if you pip install xdsl. |
||
from typing import Generic | ||
|
||
from xdsl.dialects.builtin import ( | ||
|
@@ -14,7 +12,6 @@ | |
from xdsl.ir import ( | ||
Attribute, | ||
AttributeInvT, | ||
BitEnumAttribute, | ||
BlockArgument, | ||
Operation, | ||
Region, | ||
|
@@ -23,7 +20,6 @@ | |
from xdsl.irdl import IRDLOperation, var_operand_def | ||
from xdsl.parser import Parser, UnresolvedOperand | ||
from xdsl.printer import Printer | ||
from xdsl.utils.str_enum import StrEnum | ||
|
||
|
||
def print_call_op_like( | ||
|
@@ -345,33 +341,3 @@ def parse_dynamic_index_list_without_types( | |
values.append(value_or_index) | ||
|
||
return values, indices | ||
|
||
|
||
# region Fast Math Flags | ||
|
||
|
||
class FastMathFlag(StrEnum): | ||
""" | ||
Values specifying fast math behaviour of an arithmetic operation. | ||
""" | ||
|
||
REASSOC = "reassoc" | ||
NO_NANS = "nnan" | ||
NO_INFS = "ninf" | ||
NO_SIGNED_ZEROS = "nsz" | ||
ALLOW_RECIP = "arcp" | ||
ALLOW_CONTRACT = "contract" | ||
APPROX_FUNC = "afn" | ||
|
||
|
||
@dataclass(frozen=True, init=False) | ||
class FastMathAttrBase(BitEnumAttribute[FastMathFlag], ABC): | ||
""" | ||
Base class for attributes defining fast math behavior of arithmetic operations. | ||
""" | ||
|
||
none_value = "none" | ||
all_value = "fast" | ||
|
||
|
||
# endregion |
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.
sorted this list