[Mlir-commits] [mlir] c26e398 - [mlir][linalg][transform] Fix Python build

Matthias Springer llvmlistbot at llvm.org
Thu Jul 6 03:23:38 PDT 2023


Author: Matthias Springer
Date: 2023-07-06T12:20:35+02:00
New Revision: c26e398b491bee73bcb1ef2fde30c6ad23bb830e

URL: https://github.com/llvm/llvm-project/commit/c26e398b491bee73bcb1ef2fde30c6ad23bb830e
DIFF: https://github.com/llvm/llvm-project/commit/c26e398b491bee73bcb1ef2fde30c6ad23bb830e.diff

LOG: [mlir][linalg][transform] Fix Python build

This should have been part of D154585.

Added: 
    

Modified: 
    mlir/python/mlir/dialects/_structured_transform_ops_ext.py

Removed: 
    


################################################################################
diff  --git a/mlir/python/mlir/dialects/_structured_transform_ops_ext.py b/mlir/python/mlir/dialects/_structured_transform_ops_ext.py
index 190b3bc9124ea3..b754034c8a4809 100644
--- a/mlir/python/mlir/dialects/_structured_transform_ops_ext.py
+++ b/mlir/python/mlir/dialects/_structured_transform_ops_ext.py
@@ -217,10 +217,10 @@ def __init__(
 
 
 class TileOp:
-    """Specialization for TileOp class."""
+  """Specialization for TileOp class."""
 
-    @overload
-    def __init__(
+  @overload
+  def __init__(
         self,
         loop_types: Union[Type, List[Type]],
         target: Union[Operation, Value],
@@ -233,10 +233,10 @@ def __init__(
         loc=None,
         ip=None,
     ):
-        ...
+    ...
 
-    @overload
-    def __init__(
+  @overload
+  def __init__(
         self,
         target: Union[Operation, Value, OpView],
         *,
@@ -248,9 +248,9 @@ def __init__(
         loc=None,
         ip=None,
     ):
-        ...
+    ...
 
-    def __init__(
+  def __init__(
         self,
         loop_types_or_target: Union[Type, List[Type], Operation, Value],
         target_or_none: Optional[Union[Operation, Value, OpView]] = None,
@@ -263,43 +263,45 @@ def __init__(
         loc=None,
         ip=None,
     ):
-        if interchange is None:
-            interchange = []
-        if sizes is None:
-            sizes = []
-        if scalable_sizes is None:
-            scalable_sizes = []
-
-        static_sizes = []
-        dynamic_sizes = []
-        if isinstance(sizes, ArrayAttr):
-            sizes_attr = sizes
+    if interchange is None:
+      interchange = []
+    if sizes is None:
+      sizes = []
+
+    static_sizes = []
+    dynamic_sizes = []
+    if isinstance(sizes, ArrayAttr):
+      sizes_attr = sizes
+    else:
+      for size in sizes:
+        if isinstance(size, int):
+          static_sizes.append(size)
         else:
-            for size in sizes:
-                if isinstance(size, int):
-                    static_sizes.append(size)
-                else:
-                    static_sizes.append(ShapedType.get_dynamic_size())
-                    dynamic_sizes.append(_get_op_result_or_value(size))
-            sizes_attr = DenseI64ArrayAttr.get(static_sizes)
-
-        num_loops = sum(v if v == 0 else 1 for v in self.__extract_values(sizes_attr))
-
-        if isinstance(loop_types_or_target, (Operation, Value, OpView)):
-            loop_types = [transform.AnyOpType.get()] * num_loops
-            target = loop_types_or_target
-            assert target_or_none is None, "Cannot construct TileOp with two targets."
-        else:
-            loop_types = (
-                ([loop_types_or_target] * num_loops)
-                if isinstance(loop_types_or_target, Type)
-                else loop_types_or_target
-            )
-            target = target_or_none
+          static_sizes.append(ShapedType.get_dynamic_size())
+          dynamic_sizes.append(_get_op_result_or_value(size))
+      sizes_attr = DenseI64ArrayAttr.get(static_sizes)
 
-        target = _get_op_result_or_value(target)
+    num_loops = sum(
+        v if v == 0 else 1 for v in self.__extract_values(sizes_attr)
+    )
+    if scalable_sizes is None:
+      scalable_sizes = [False] * len(self.__extract_values(sizes_attr))
+
+    if isinstance(loop_types_or_target, (Operation, Value, OpView)):
+      loop_types = [transform.AnyOpType.get()] * num_loops
+      target = loop_types_or_target
+      assert target_or_none is None, "Cannot construct TileOp with two targets."
+    else:
+      loop_types = (
+          ([loop_types_or_target] * num_loops)
+          if isinstance(loop_types_or_target, Type)
+          else loop_types_or_target
+      )
+      target = target_or_none
+
+    target = _get_op_result_or_value(target)
 
-        super().__init__(
+    super().__init__(
             target.type,
             loop_types,
             target,
@@ -311,10 +313,10 @@ def __init__(
             ip=ip,
         )
 
-    def __extract_values(self, attr: Optional[DenseI64ArrayAttr]) -> List[int]:
-        if not attr:
-            return []
-        return [element for element in attr]
+  def __extract_values(self, attr: Optional[DenseI64ArrayAttr]) -> List[int]:
+    if not attr:
+      return []
+    return [element for element in attr]
 
 
 class VectorizeOp:


        


More information about the Mlir-commits mailing list