From 1c98ac980252c8aea3ca0e2e2795c6158dcec37d Mon Sep 17 00:00:00 2001 From: Gabriel Rodriguez-Canal Date: Wed, 30 Oct 2024 15:43:21 -0700 Subject: [PATCH] Remove dialects and other changes that do not belong in the liveness analysis PR --- .gitignore | 2 -- xdsl/dialects/linalg.py | 16 +-------- xdsl/dialects/tensor.py | 71 ---------------------------------------- xdsl/ir/core.py | 1 - xdsl/irdl/constraints.py | 3 +- xdsl/traits.py | 6 ---- 6 files changed, 2 insertions(+), 97 deletions(-) diff --git a/.gitignore b/.gitignore index 3ba53de506..64c91d9398 100644 --- a/.gitignore +++ b/.gitignore @@ -166,5 +166,3 @@ docs/ret.xdsl # direnv .direnv .envrc - -xdsl-venv/ diff --git a/xdsl/dialects/linalg.py b/xdsl/dialects/linalg.py index 7fff75a07a..75e80f96f5 100644 --- a/xdsl/dialects/linalg.py +++ b/xdsl/dialects/linalg.py @@ -54,7 +54,7 @@ ) from xdsl.parser import AttrParser, Parser from xdsl.printer import Printer -from xdsl.traits import IsContraction, IsTerminator +from xdsl.traits import IsTerminator from xdsl.utils.exceptions import VerifyException from xdsl.utils.hints import isa from xdsl.utils.str_enum import StrEnum @@ -834,8 +834,6 @@ class MatmulOp(NamedOpBase): PRINT_ATTRS_IN_FRONT: ClassVar[bool] = True - traits = frozenset([IsContraction()]) - def __init__( self, inputs: Sequence[SSAValue], @@ -999,17 +997,6 @@ class PoolingNchwMaxOp(PoolingOpsBase): name = "linalg.pooling_nchw_max" -@irdl_op_definition -class PoolingNchwSumOp(PoolingOpsBase): - """ - Performs sum pooling - - See https://mlir.llvm.org/docs/Dialects/Linalg/#linalgpooling_nchw_sum-linalgpoolingnchwsumop - """ - - name = "linalg.pooling_nchw_sum" - - class ConvOpsBase(IRDLOperation, ABC): """Base class for linalg convolution operations.""" @@ -1183,7 +1170,6 @@ def parse(cls, parser: Parser) -> Self: MatmulOp, QuantizedMatmulOp, PoolingNchwMaxOp, - PoolingNchwSumOp, Conv2DNchwFchwOp, BroadcastOp, ], diff --git a/xdsl/dialects/tensor.py b/xdsl/dialects/tensor.py index d76317c0a1..53d456f0b4 100644 --- a/xdsl/dialects/tensor.py +++ b/xdsl/dialects/tensor.py @@ -18,10 +18,8 @@ IntegerType, TensorType, UnrankedTensorType, - i32, i64, ) -from xdsl.dialects.utils import AbstractYieldOperation from xdsl.ir import Attribute, Dialect, Operation, SSAValue from xdsl.irdl import ( AttrSizedOperandSegments, @@ -436,73 +434,6 @@ def from_static_parameters( ) -@irdl_op_definition -class Yield(AbstractYieldOperation[Attribute]): - name = "tensor.yield" - - -@irdl_op_definition -class PadOp(IRDLOperation): - name = "tensor.pad" - source = operand_def(TensorType) - # low = var_operand_def(IndexType) - # high = var_operand_def(IndexType) - static_low = prop_def(DenseArrayBase) - static_high = prop_def(DenseArrayBase) - - result = result_def(TensorType) - - irdl_options = [AttrSizedOperandSegments(as_property=True)] - - def __init__( - self, - source: SSAValue | Operation, - low: Sequence[IndexType], - high: Sequence[IndexType], - ): - source = SSAValue.get(source) - assert isinstance(source.type, TensorType) - - new_shape = [] - for dim_idx, dim in enumerate(source.type.shape.data): - new_dim = dim.data + low[dim_idx] + high[dim_idx] - new_shape.append(new_dim) - - return_type = TensorType(source.type.element_type, new_shape) - - super().__init__( - operands=[source], - properties={ - "static_low": DenseArrayBase.from_list(i32, low), - "static_high": DenseArrayBase.from_list(i32, high), - }, - result_types=[return_type], - ) - - @classmethod - def parse(cls, parser: Parser) -> Self: - source = parser.parse_operand() - parser.parse_keyword("low") - low = parser.parse_comma_separated_list( - Parser.Delimiter.SQUARE, parser.parse_integer - ) - parser.parse_keyword("high") - high = parser.parse_comma_separated_list( - Parser.Delimiter.SQUARE, parser.parse_integer - ) - parser.parse_region() - attrs = parser.parse_optional_attr_dict() - parser.parse_punctuation(":") - parser.parse_type() - parser.parse_keyword("to") - parser.parse_type() - - pad = cls(source, low, high) - pad.attributes |= attrs - - return pad - - Tensor = Dialect( "tensor", [ @@ -513,8 +444,6 @@ def parse(cls, parser: Parser) -> Self: InsertSliceOp, ReshapeOp, CollapseShapeOp, - PadOp, - Yield, ], [], ) diff --git a/xdsl/ir/core.py b/xdsl/ir/core.py index 924d1d067b..1b6a5a8c93 100644 --- a/xdsl/ir/core.py +++ b/xdsl/ir/core.py @@ -1262,7 +1262,6 @@ def emit_error( diagnostic = Diagnostic() diagnostic.add_message(self, message) - print("OPERATION ERROR: ", self) diagnostic.raise_exception(message, self, exception_type, underlying_error) @classmethod diff --git a/xdsl/irdl/constraints.py b/xdsl/irdl/constraints.py index ed0a54a34c..d32a36bc8b 100644 --- a/xdsl/irdl/constraints.py +++ b/xdsl/irdl/constraints.py @@ -276,8 +276,7 @@ def verify( # constraint context is not modified. constraint_context_copy = constraint_context.copy() try: - # GABRIEL 22/10/2024: this verification fails with matmul in ResNet (HIDA test) - # attr_constr.verify(attr, constraint_context_copy) + attr_constr.verify(attr, constraint_context_copy) # If the constraint succeeds, we update back the constraint variables constraint_context.update(constraint_context_copy) return diff --git a/xdsl/traits.py b/xdsl/traits.py index cc9adfc73b..f1a564a454 100644 --- a/xdsl/traits.py +++ b/xdsl/traits.py @@ -31,12 +31,6 @@ def verify(self, op: Operation) -> None: OpTraitInvT = TypeVar("OpTraitInvT", bound=OpTrait) -class IsContraction(OpTrait): - """ - Temporary patch to qualify operations as contractions. This is done with an interface for the linalg dialect. - """ - - class ConstantLike(OpTrait): """ Operation known to be constant-like.