Skip to content
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

dialects: (builtin) remove Index support in DenseArrayBase #3541

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions tests/dialects/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
Float128Type,
FloatAttr,
FloatData,
IndexType,
IntAttr,
MemRefType,
NoneAttr,
Expand Down Expand Up @@ -90,16 +89,10 @@ def test_DenseArrayBase_verifier_failure():
"dense array of float element type " "should only contain floats"
)

with pytest.raises(VerifyException) as err:
DenseArrayBase([IndexType(), ArrayAttr([FloatData(0.0)])])
assert err.value.args[0] == (
"dense array of integer or index element type " "should only contain integers"
)

with pytest.raises(VerifyException) as err:
DenseArrayBase([i32, ArrayAttr([FloatData(0.0)])])
assert err.value.args[0] == (
"dense array of integer or index element type " "should only contain integers"
"dense array of integer element type " "should only contain integers"
)


Expand Down
23 changes: 7 additions & 16 deletions xdsl/dialects/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
overload,
)

from typing_extensions import Self, deprecated
from typing_extensions import Self

from xdsl.ir import (
Attribute,
Expand Down Expand Up @@ -951,33 +951,24 @@ def from_params(handle: str | StringAttr, type: Attribute) -> DenseResourceAttr:
class DenseArrayBase(ParametrizedAttribute):
name = "array"

elt_type: ParameterDef[IntegerType | IndexType | AnyFloat]
elt_type: ParameterDef[IntegerType | AnyFloat]
data: ParameterDef[ArrayAttr[IntAttr] | ArrayAttr[FloatData]]

def verify(self):
if isinstance(self.elt_type, IntegerType | IndexType):
if isinstance(self.elt_type, IntegerType):
for d in self.data.data:
if isinstance(d, FloatData):
raise VerifyException(
"dense array of integer or index element type "
"should only contain integers"
"dense array of integer element type should only contain "
"integers"
)
else:
for d in self.data.data:
if isinstance(d, IntAttr):
raise VerifyException(
"dense array of float element type "
"should only contain floats"
"dense array of float element type should only contain floats"
)

@deprecated("Please use `create_dense_int` instead.")
@staticmethod
def create_dense_int_or_index(
data_type: IntegerType | IndexType, data: Sequence[int] | Sequence[IntAttr]
) -> DenseArrayBase:
assert not isinstance(data_type, IndexType), "Index type is not supported"
return DenseArrayBase.create_dense_int(data_type, data)

@staticmethod
def create_dense_int(
data_type: IntegerType, data: Sequence[int] | Sequence[IntAttr]
Expand All @@ -1003,7 +994,7 @@ def create_dense_float(
@overload
@staticmethod
def from_list(
data_type: IntegerType | IndexType, data: Sequence[int] | Sequence[IntAttr]
data_type: IntegerType, data: Sequence[int] | Sequence[IntAttr]
) -> DenseArrayBase: ...

@overload
Expand Down