Repository: xdslproject/xdsl
Pull request #4066: bench: add lexing benchmarks and their workloads
Author: login: EdmundGoodman
Labels: name: bench
description: Benchmark related changes
Created: 2025-03-17T15:10:51Z | Merged: 2025-03-19T11:49:06Z

Add benchmarks for the lexer. The main complexity is the MLIR workload files to lex, which can then be re-used, for example by the parser/pattern rewriter/printer. Code is added to generate arbitrary constant folding workloads, and real-world use files are included from https://github.com/xdslproject/xdsl-bench/pull/1.

Peeled off from tracking PR https://github.com/xdslproject/xdsl/pull/4008.


Diff:
diff --git a/benchmarks/lexer.py b/benchmarks/lexer.py
new file mode 100644
index 0000000000..4b203fab87
--- /dev/null
+++ b/benchmarks/lexer.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python3
+"""Benchmarks for the lexer of the xDSL implementation."""
+
+from benchmarks.workloads import WorkloadBuilder
+from xdsl.utils.lexer import Input
+from xdsl.utils.mlir_lexer import MLIRLexer, MLIRTokenKind
+
+
+class Lexer:
+    """Benchmark the xDSL lexer on MLIR files."""
+
+    WORKLOAD_EMPTY = WorkloadBuilder.empty()
+    WORKLOAD_CONSTANT_100 = WorkloadBuilder.constant_folding(100)
+    WORKLOAD_CONSTANT_1000 = WorkloadBuilder.constant_folding(1000)
+    WORKLOAD_LARGE_DENSE_ATTR = WorkloadBuilder.large_dense_attr()
+    WORKLOAD_LARGE_DENSE_ATTR_HEX = WorkloadBuilder.large_dense_attr_hex()
+
+    def time_empty_program(self) -> None:
+        """Time lexing an empty program."""
+        lexer_input = Input(Lexer.WORKLOAD_EMPTY, "empty")
+        lexer = MLIRLexer(lexer_input)
+        while lexer.lex().kind is not MLIRTokenKind.EOF:
+            pass
+
+    def time_constant_100(self) -> None:
+        """Time lexing constant folding for 100 items."""
+        lexer_input = Input(Lexer.WORKLOAD_CONSTANT_100, "constant_100")
+        lexer = MLIRLexer(lexer_input)
+        while lexer.lex().kind is not MLIRTokenKind.EOF:
+            pass
+
+    def time_constant_1000(self) -> None:
+        """Time lexing constant folding for 1000 items."""
+        lexer_input = Input(Lexer.WORKLOAD_CONSTANT_1000, "constant_1000")
+        lexer = MLIRLexer(lexer_input)
+        while lexer.lex().kind is not MLIRTokenKind.EOF:
+            pass
+
+    def ignore_time_dense_attr(self) -> None:
+        """Time lexing a 1024x1024xi8 dense attribute."""
+        lexer_input = Input(Lexer.WORKLOAD_LARGE_DENSE_ATTR, "dense_attr")
+        lexer = MLIRLexer(lexer_input)
+        while lexer.lex().kind is not MLIRTokenKind.EOF:
+            pass
+
+    def ignore_time_dense_attr_hex(self) -> None:
+        """Time lexing a 1024x1024xi8 dense attribute given as a hex string."""
+        lexer_input = Input(Lexer.WORKLOAD_LARGE_DENSE_ATTR_HEX, "dense_attr_hex")
+        lexer = MLIRLexer(lexer_input)
+        while lexer.lex().kind is not MLIRTokenKind.EOF:
+            pass
+
+
+if __name__ == "__main__":
+    from bench_utils import Benchmark, profile
+
+    LEXER = Lexer()
+    profile(
+        {
+            "Lexer.empty_program": Benchmark(LEXER.time_empty_program),
+            "Lexer.constant_100": Benchmark(LEXER.time_constant_100),
+            "Lexer.constant_1000": Benchmark(LEXER.time_constant_1000),
+            "Lexer.dense_attr": Benchmark(LEXER.ignore_time_dense_attr),
+            "Lexer.dense_attr_hex": Benchmark(LEXER.ignore_time_dense_attr_hex),
+        }
+    )
diff --git a/benchmarks/workloads.py b/benchmarks/workloads.py
new file mode 100644
index 0000000000..b1e19f2a41
--- /dev/null
+++ b/benchmarks/workloads.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python3
+"""Workloads for benchmarking xDSL."""
+
+import random
+
+RANDOM_SEED = 0
+HEX_CHARS = "0123456789ABCDEF"
+
+
+class WorkloadBuilder:
+    """A helper class to programmatically build synthetic workloads."""
+
+    @classmethod
+    def wrap_module(cls, ops: list[str]) -> str:
+        """Wrap a list of operations as a module."""
+        workload = f'"builtin.module"() ({{\n  {"\n  ".join(ops)}\n}}) : () -> ()'
+        return workload
+
+    @classmethod
+    def empty(cls) -> str:
+        """Generate an empty module."""
+        return WorkloadBuilder.wrap_module([])
+
+    @classmethod
+    def constant_folding(cls, size: int = 100) -> str:
+        """Generate a constant folding workload of a given size."""
+        assert size >= 0
+        random.seed(RANDOM_SEED)
+        ops: list[str] = []
+        ops.append(
+            '%0 = "arith.constant"() {"value" = '
+            f"{random.randint(1, 1000)} : i32}} : () -> i32"
+        )
+        for i in range(1, size + 1):
+            if i % 2 == 0:
+                ops.append(
+                    f'%{i} = "arith.addi"(%{i - 1}, %{i - 2}) : (i32, i32) -> i32'
+                )
+            else:
+                ops.append(
+                    f'%{i} = "arith.constant"() {{"value" = '
+                    f"{random.randint(1, 1000)} : i32}} : () -> i32"
+                )
+        ops.append(f'"test.op"(%{(size // 2) * 2}) : (i32) -> ()')
+        return WorkloadBuilder.wrap_module(ops)
+
+    @classmethod
+    def large_dense_attr(cls, x: int = 1024, y: int = 1024) -> str:
+        """Get the MLIR text representation of a large dense attr."""
+        assert x >= 0
+        assert y >= 0
+        random.seed(RANDOM_SEED)
+        dense_attr = [[random.randint(-128, 128) for _ in range(x)] for _ in range(y)]
+        ops = [
+            (
+                '%0 = "arith.constant"() '
+                f"<{{value = dense<{dense_attr}> "
+                f": tensor<{x}x{y}xi8>}}> : () -> tensor<{x}x{y}xi8>"
+            )
+        ]
+        return WorkloadBuilder.wrap_module(ops)
+
+    @classmethod
+    def large_dense_attr_hex(cls, x: int = 1024, y: int = 1024) -> str:
+        """Get the MLIR hex representation of a large dense attr."""
+        assert x >= 0
+        assert y >= 0
+        random.seed(RANDOM_SEED)
+        # Each dense attr item is a byte = 2 hex chars
+        dense_attr_hex = "".join(random.choice(HEX_CHARS) for _ in range(x * y * 2))
+        ops = [
+            (
+                '%0 = "arith.constant"() '
+                f"<{{value = dense<0x{dense_attr_hex}> "
+                f": tensor<{x}x{y}xi8>}}> : () -> tensor<{x}x{y}xi8>"
+            )
+        ]
+        return WorkloadBuilder.wrap_module(ops)


Reviews:
user: login: superlopuh
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-17T16:07:19Z
user: login: superlopuh
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-17T16:07:30Z
user: login: EdmundGoodman
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-17T16:18:14Z
user: login: EdmundGoodman
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-17T16:20:13Z
user: login: superlopuh
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-17T16:20:44Z
user: login: superlopuh
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-18T13:05:43Z
user: login: superlopuh
body: Looks great!
state: APPROVED
author_association: MEMBER
submitted_at: 2025-03-18T13:08:15Z
user: login: superlopuh
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-18T13:08:41Z
user: login: EdmundGoodman
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-18T13:09:13Z
user: login: superlopuh
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-18T13:09:55Z

Review comments:
path: benchmarks/resources/extra_mlir/large_dense_attr_hex.mlir
user: login: superlopuh
body: I don't think we want these files, why not just generate the string during the benchmark?
created_at: 2025-03-17T16:07:19Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+"""Workloads for benchmarking xDSL."""
+
+import random
+from pathlib import Path
+
+BENCHMARKS_DIR = Path(__file__).parent
+EXTRA_MLIR_DIR = BENCHMARKS_DIR / "resources" / "extra_mlir"
+
+
+class WorkloadBuilder:
+    """A helper class to programmatically build synthetic workloads."""
+
+    @classmethod
+    def wrap_module(cls, ops: list[str]) -> str:
+        """Wrap a list of operations as a module."""
+        workload = f'"builtin.module"() ({{\n  {"\n  ".join(ops)}\n}}) : () -> ()'
+        return workload
+
+    @classmethod
+    def empty(cls) -> str:
+        """Generate an empty module."""
+        return WorkloadBuilder.wrap_module([])
+
+    @classmethod
+    def constant_folding(cls, size: int = 100) -> str:
+        """Generate a constant folding workload of a given size."""
+        assert size >= 0
+        random.seed(0)
+        ops: list[str] = []
+        ops.append(
+            '%0 = "arith.constant"() {"value" = '
+            f"{random.randint(1, 1000)} : i32}} : () -> i32"
+        )
+        for i in range(1, size + 1):
+            if i % 2 == 0:
+                ops.append(
+                    f'%{i} = "arith.addi"(%{i - 1}, %{i - 2}) : (i32, i32) -> i32'
path: benchmarks/workloads.py
user: login: superlopuh
body: why concatenate strings and not build IR?
created_at: 2025-03-17T16:07:30Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+"""Workloads for benchmarking xDSL."""
+
+import random
+from pathlib import Path
+
+BENCHMARKS_DIR = Path(__file__).parent
+EXTRA_MLIR_DIR = BENCHMARKS_DIR / "resources" / "extra_mlir"
+
+
+class WorkloadBuilder:
+    """A helper class to programmatically build synthetic workloads."""
+
+    @classmethod
+    def wrap_module(cls, ops: list[str]) -> str:
+        """Wrap a list of operations as a module."""
+        workload = f'"builtin.module"() ({{\n  {"\n  ".join(ops)}\n}}) : () -> ()'
+        return workload
+
+    @classmethod
+    def empty(cls) -> str:
+        """Generate an empty module."""
+        return WorkloadBuilder.wrap_module([])
+
+    @classmethod
+    def constant_folding(cls, size: int = 100) -> str:
+        """Generate a constant folding workload of a given size."""
+        assert size >= 0
+        random.seed(0)
+        ops: list[str] = []
+        ops.append(
+            '%0 = "arith.constant"() {"value" = '
+            f"{random.randint(1, 1000)} : i32}} : () -> i32"
+        )
+        for i in range(1, size + 1):
+            if i % 2 == 0:
+                ops.append(
+                    f'%{i} = "arith.addi"(%{i - 1}, %{i - 2}) : (i32, i32) -> i32'
path: benchmarks/workloads.py
user: login: EdmundGoodman
body: This is the input to the lexer (and parser), so needs to be a string -- but this is a good point for upcoming rewriting/printing benchmarks, so I will add similar functionality later to build IR instead as well.
created_at: 2025-03-17T16:18:14Z
author_association: COLLABORATOR
path: benchmarks/resources/extra_mlir/large_dense_attr_hex.mlir
user: login: EdmundGoodman
body: The string is a real-world example from https://github.com/xdslproject/xdsl-bench/pull/1 , so cannot by procedurally generated in the same way as constant folding. Its content needs to live somewhere, and since it is so long it made more sense to me for it to be a separate file than a huge inline python string.
created_at: 2025-03-17T16:20:12Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+"""Workloads for benchmarking xDSL."""
+
+import random
+from pathlib import Path
+
+BENCHMARKS_DIR = Path(__file__).parent
+EXTRA_MLIR_DIR = BENCHMARKS_DIR / "resources" / "extra_mlir"
+
+
+class WorkloadBuilder:
+    """A helper class to programmatically build synthetic workloads."""
+
+    @classmethod
+    def wrap_module(cls, ops: list[str]) -> str:
+        """Wrap a list of operations as a module."""
+        workload = f'"builtin.module"() ({{\n  {"\n  ".join(ops)}\n}}) : () -> ()'
+        return workload
+
+    @classmethod
+    def empty(cls) -> str:
+        """Generate an empty module."""
+        return WorkloadBuilder.wrap_module([])
+
+    @classmethod
+    def constant_folding(cls, size: int = 100) -> str:
+        """Generate a constant folding workload of a given size."""
+        assert size >= 0
+        random.seed(0)
+        ops: list[str] = []
+        ops.append(
+            '%0 = "arith.constant"() {"value" = '
+            f"{random.randint(1, 1000)} : i32}} : () -> i32"
+        )
+        for i in range(1, size + 1):
+            if i % 2 == 0:
+                ops.append(
+                    f'%{i} = "arith.addi"(%{i - 1}, %{i - 2}) : (i32, i32) -> i32'
path: benchmarks/workloads.py
user: login: superlopuh
body: My thought was that we could just print and re-parse, but I don't feel strongly about this. I am pretty sure that we don't want to commit this, though.
created_at: 2025-03-17T16:20:44Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,77 @@
+#!/usr/bin/env python3
+"""Workloads for benchmarking xDSL."""
+
+import random
+
+RANDOM_SEED = 0
+HEX_CHARS = "0123456789ABCDEF"
+
+
+class WorkloadBuilder:
+    """A helper class to programmatically build synthetic workloads."""
+
+    @classmethod
+    def wrap_module(cls, ops: list[str]) -> str:
+        """Wrap a list of operations as a module."""
+        workload = f'"builtin.module"() ({{\n  {"\n  ".join(ops)}\n}}) : () -> ()'
+        return workload
+
+    @classmethod
+    def empty(cls) -> str:
+        """Generate an empty module."""
+        return WorkloadBuilder.wrap_module([])
+
+    @classmethod
+    def constant_folding(cls, size: int = 100) -> str:
+        """Generate a constant folding workload of a given size."""
+        assert size >= 0
+        random.seed(RANDOM_SEED)
+        ops: list[str] = []
+        ops.append(
+            '%0 = "arith.constant"() {"value" = '
+            f"{random.randint(1, 1000)} : i32}} : () -> i32"
+        )
+        for i in range(1, size + 1):
+            if i % 2 == 0:
+                ops.append(
+                    f'%{i} = "arith.addi"(%{i - 1}, %{i - 2}) : (i32, i32) -> i32'
+                )
+            else:
+                ops.append(
+                    f'%{i} = "arith.constant"() {{"value" = '
+                    f"{random.randint(1, 1000)} : i32}} : () -> i32"
+                )
+        ops.append(f'"test.op"(%{(size // 2) * 2}) : (i32) -> ()')
+        return WorkloadBuilder.wrap_module(ops)
+
+    @classmethod
+    def large_dense_attr(cls, x: int = 1024, y: int = 1024) -> str:
+        """Get the MLIR text representation of a large dense attr."""
+        assert x >= 0
+        assert y >= 0
+        random.seed(RANDOM_SEED)
+        dense_attr = [[random.randint(-128, 128) for _ in range(x)] for _ in range(y)]
+        ops = [
+            (
+                '%0 = "arith.constant"() '
+                f"<{{value = dense<{dense_attr}> "
+                f": tensor<{x}x{y}xi8>}}> : () -> tensor<{x}x{y}xi8>"
+            )
+        ]
+        return WorkloadBuilder.wrap_module(ops)
+
+    @classmethod
+    def large_dense_attr_hex(cls, x: int = 1024, y: int = 1024) -> str:
+        """Get the MLIR hex representation of a large dense attr."""
+        assert x >= 0
+        assert y >= 0
+        random.seed(RANDOM_SEED)
+        dense_attr_hex = "".join([random.choice(HEX_CHARS) for _ in range(x * y * 2)])
path: benchmarks/workloads.py
user: login: superlopuh
body: why times two?
created_at: 2025-03-18T13:05:42Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,77 @@
+#!/usr/bin/env python3
+"""Workloads for benchmarking xDSL."""
+
+import random
+
+RANDOM_SEED = 0
+HEX_CHARS = "0123456789ABCDEF"
+
+
+class WorkloadBuilder:
+    """A helper class to programmatically build synthetic workloads."""
+
+    @classmethod
+    def wrap_module(cls, ops: list[str]) -> str:
+        """Wrap a list of operations as a module."""
+        workload = f'"builtin.module"() ({{\n  {"\n  ".join(ops)}\n}}) : () -> ()'
+        return workload
+
+    @classmethod
+    def empty(cls) -> str:
+        """Generate an empty module."""
+        return WorkloadBuilder.wrap_module([])
+
+    @classmethod
+    def constant_folding(cls, size: int = 100) -> str:
+        """Generate a constant folding workload of a given size."""
+        assert size >= 0
+        random.seed(RANDOM_SEED)
+        ops: list[str] = []
+        ops.append(
+            '%0 = "arith.constant"() {"value" = '
+            f"{random.randint(1, 1000)} : i32}} : () -> i32"
+        )
+        for i in range(1, size + 1):
+            if i % 2 == 0:
+                ops.append(
+                    f'%{i} = "arith.addi"(%{i - 1}, %{i - 2}) : (i32, i32) -> i32'
+                )
+            else:
+                ops.append(
+                    f'%{i} = "arith.constant"() {{"value" = '
+                    f"{random.randint(1, 1000)} : i32}} : () -> i32"
+                )
+        ops.append(f'"test.op"(%{(size // 2) * 2}) : (i32) -> ()')
+        return WorkloadBuilder.wrap_module(ops)
+
+    @classmethod
+    def large_dense_attr(cls, x: int = 1024, y: int = 1024) -> str:
+        """Get the MLIR text representation of a large dense attr."""
+        assert x >= 0
+        assert y >= 0
+        random.seed(RANDOM_SEED)
+        dense_attr = [[random.randint(-128, 128) for _ in range(x)] for _ in range(y)]
+        ops = [
+            (
+                '%0 = "arith.constant"() '
+                f"<{{value = dense<{dense_attr}> "
+                f": tensor<{x}x{y}xi8>}}> : () -> tensor<{x}x{y}xi8>"
+            )
+        ]
+        return WorkloadBuilder.wrap_module(ops)
+
+    @classmethod
+    def large_dense_attr_hex(cls, x: int = 1024, y: int = 1024) -> str:
+        """Get the MLIR hex representation of a large dense attr."""
+        assert x >= 0
+        assert y >= 0
+        random.seed(RANDOM_SEED)
+        dense_attr_hex = "".join([random.choice(HEX_CHARS) for _ in range(x * y * 2)])
path: benchmarks/workloads.py
user: login: superlopuh
body: ```suggestion
        dense_attr_hex = "".join(random.choice(HEX_CHARS) for _ in range(x * y * 2))
```
created_at: 2025-03-18T13:08:41Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,77 @@
+#!/usr/bin/env python3
+"""Workloads for benchmarking xDSL."""
+
+import random
+
+RANDOM_SEED = 0
+HEX_CHARS = "0123456789ABCDEF"
+
+
+class WorkloadBuilder:
+    """A helper class to programmatically build synthetic workloads."""
+
+    @classmethod
+    def wrap_module(cls, ops: list[str]) -> str:
+        """Wrap a list of operations as a module."""
+        workload = f'"builtin.module"() ({{\n  {"\n  ".join(ops)}\n}}) : () -> ()'
+        return workload
+
+    @classmethod
+    def empty(cls) -> str:
+        """Generate an empty module."""
+        return WorkloadBuilder.wrap_module([])
+
+    @classmethod
+    def constant_folding(cls, size: int = 100) -> str:
+        """Generate a constant folding workload of a given size."""
+        assert size >= 0
+        random.seed(RANDOM_SEED)
+        ops: list[str] = []
+        ops.append(
+            '%0 = "arith.constant"() {"value" = '
+            f"{random.randint(1, 1000)} : i32}} : () -> i32"
+        )
+        for i in range(1, size + 1):
+            if i % 2 == 0:
+                ops.append(
+                    f'%{i} = "arith.addi"(%{i - 1}, %{i - 2}) : (i32, i32) -> i32'
+                )
+            else:
+                ops.append(
+                    f'%{i} = "arith.constant"() {{"value" = '
+                    f"{random.randint(1, 1000)} : i32}} : () -> i32"
+                )
+        ops.append(f'"test.op"(%{(size // 2) * 2}) : (i32) -> ()')
+        return WorkloadBuilder.wrap_module(ops)
+
+    @classmethod
+    def large_dense_attr(cls, x: int = 1024, y: int = 1024) -> str:
+        """Get the MLIR text representation of a large dense attr."""
+        assert x >= 0
+        assert y >= 0
+        random.seed(RANDOM_SEED)
+        dense_attr = [[random.randint(-128, 128) for _ in range(x)] for _ in range(y)]
+        ops = [
+            (
+                '%0 = "arith.constant"() '
+                f"<{{value = dense<{dense_attr}> "
+                f": tensor<{x}x{y}xi8>}}> : () -> tensor<{x}x{y}xi8>"
+            )
+        ]
+        return WorkloadBuilder.wrap_module(ops)
+
+    @classmethod
+    def large_dense_attr_hex(cls, x: int = 1024, y: int = 1024) -> str:
+        """Get the MLIR hex representation of a large dense attr."""
+        assert x >= 0
+        assert y >= 0
+        random.seed(RANDOM_SEED)
+        dense_attr_hex = "".join([random.choice(HEX_CHARS) for _ in range(x * y * 2)])
path: benchmarks/workloads.py
user: login: EdmundGoodman
body: Two hex chars per byte, with each value in the matrix being one byte [0,255]
created_at: 2025-03-18T13:09:13Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,77 @@
+#!/usr/bin/env python3
+"""Workloads for benchmarking xDSL."""
+
+import random
+
+RANDOM_SEED = 0
+HEX_CHARS = "0123456789ABCDEF"
+
+
+class WorkloadBuilder:
+    """A helper class to programmatically build synthetic workloads."""
+
+    @classmethod
+    def wrap_module(cls, ops: list[str]) -> str:
+        """Wrap a list of operations as a module."""
+        workload = f'"builtin.module"() ({{\n  {"\n  ".join(ops)}\n}}) : () -> ()'
+        return workload
+
+    @classmethod
+    def empty(cls) -> str:
+        """Generate an empty module."""
+        return WorkloadBuilder.wrap_module([])
+
+    @classmethod
+    def constant_folding(cls, size: int = 100) -> str:
+        """Generate a constant folding workload of a given size."""
+        assert size >= 0
+        random.seed(RANDOM_SEED)
+        ops: list[str] = []
+        ops.append(
+            '%0 = "arith.constant"() {"value" = '
+            f"{random.randint(1, 1000)} : i32}} : () -> i32"
+        )
+        for i in range(1, size + 1):
+            if i % 2 == 0:
+                ops.append(
+                    f'%{i} = "arith.addi"(%{i - 1}, %{i - 2}) : (i32, i32) -> i32'
+                )
+            else:
+                ops.append(
+                    f'%{i} = "arith.constant"() {{"value" = '
+                    f"{random.randint(1, 1000)} : i32}} : () -> i32"
+                )
+        ops.append(f'"test.op"(%{(size // 2) * 2}) : (i32) -> ()')
+        return WorkloadBuilder.wrap_module(ops)
+
+    @classmethod
+    def large_dense_attr(cls, x: int = 1024, y: int = 1024) -> str:
+        """Get the MLIR text representation of a large dense attr."""
+        assert x >= 0
+        assert y >= 0
+        random.seed(RANDOM_SEED)
+        dense_attr = [[random.randint(-128, 128) for _ in range(x)] for _ in range(y)]
+        ops = [
+            (
+                '%0 = "arith.constant"() '
+                f"<{{value = dense<{dense_attr}> "
+                f": tensor<{x}x{y}xi8>}}> : () -> tensor<{x}x{y}xi8>"
+            )
+        ]
+        return WorkloadBuilder.wrap_module(ops)
+
+    @classmethod
+    def large_dense_attr_hex(cls, x: int = 1024, y: int = 1024) -> str:
+        """Get the MLIR hex representation of a large dense attr."""
+        assert x >= 0
+        assert y >= 0
+        random.seed(RANDOM_SEED)
+        dense_attr_hex = "".join([random.choice(HEX_CHARS) for _ in range(x * y * 2)])
path: benchmarks/workloads.py
user: login: superlopuh
body: Worth a comment
created_at: 2025-03-18T13:09:55Z
author_association: MEMBER

PR comments:
user: login: codecov[bot]
created_at: 2025-03-17T15:15:28Z
body: ## [Codecov](https://app.codecov.io/gh/xdslproject/xdsl/pull/4066?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xdslproject) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 89.05%. Comparing base [(`50e5d97`)](https://app.codecov.io/gh/xdslproject/xdsl/commit/50e5d97126d55754a675f44f0ae30b30aa368f9d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xdslproject) to head [(`c4be69b`)](https://app.codecov.io/gh/xdslproject/xdsl/commit/c4be69bab17f6972fe56bac74b5dff2e88d1e5b0?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xdslproject).
> Report is 415 commits behind head on main.

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##             main    #4066   +/-   ##
=======================================
  Coverage   89.05%   89.05%           
=======================================
  Files         318      318           
  Lines       43405    43407    +2     
  Branches     5407     5408    +1     
=======================================
+ Hits        38653    38655    +2     
  Misses       3408     3408           
  Partials     1344     1344           
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/xdslproject/xdsl/pull/4066?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xdslproject).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xdslproject).

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
author_association: NONE
user: login: compor
created_at: 2025-03-20T10:43:58Z
body: post-merge review: 👍🏽 thank you
author_association: COLLABORATOR