Skip to content

Commit

Permalink
CollapseShapeOp
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Manainen authored and Max Manainen committed Oct 14, 2024
1 parent 70fa878 commit 1418998
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions xdsl/dialects/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

from xdsl.dialects import memref
from xdsl.dialects.builtin import (
Annotated,
AnySignlessIntegerOrIndexType,
ArrayAttr,
ContainerType,
DenseArrayBase,
IndexType,
IntegerAttr,
IntegerType,
TensorType,
UnrankedTensorType,
i64,
Expand Down Expand Up @@ -176,6 +180,25 @@ def parse(cls, parser: Parser) -> Self:
return empty


ReassociationAttr = ArrayAttr[
ArrayAttr[IntegerAttr[Annotated[IntegerType, IntegerType(64)]]]
]


@irdl_op_definition
class CollapseShapeOp(IRDLOperation):
name = "tensor.collapse_shape"

src = operand_def(TensorType[Attribute])
result = result_def(TensorType[Attribute])
reassociation = prop_def(ReassociationAttr)
assembly_format = (
"$src $reassociation attr-dict `:` type($src) `into` type($result)"
)

traits = frozenset([NoMemoryEffect()])


@irdl_op_definition
class ReshapeOp(IRDLOperation):
name = "tensor.reshape"
Expand Down Expand Up @@ -420,6 +443,7 @@ def from_static_parameters(
ExtractSliceOp,
InsertSliceOp,
ReshapeOp,
CollapseShapeOp,
],
[],
)

0 comments on commit 1418998

Please sign in to comment.