Skip to content

Commit 574861f

Browse files
authored
[enums] monkey patch register_attribute_builder (#670)
Hack/patch to workaround overlapping `AttrBuilder` registrations. Needed until iree-org/iree#19324 and llvm/llvm-project#117918 get resolved.
1 parent b585963 commit 574861f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

tuner/tuner/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,18 @@
33
# Licensed under the Apache License v2.0 with LLVM Exceptions.
44
# See https://llvm.org/LICENSE.txt for license information.
55
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
7+
from iree.compiler import ir # type: ignore
8+
9+
10+
# Substitute `replace=True` so that colliding registration don't error.
11+
# TODO(makslevental): remove after https://github.com/llvm/llvm-project/pull/117918 is resolved.
12+
def register_attribute_builder(kind, replace=True):
13+
def decorator_builder(func):
14+
ir.AttrBuilder.insert(kind, func, replace=replace)
15+
return func
16+
17+
return decorator_builder
18+
19+
20+
ir.register_attribute_builder = register_attribute_builder

tuner/tuner/libtuner_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,3 +499,7 @@ def test_validate_devices_with_invalid_device() -> None:
499499
exit_program=True,
500500
)
501501
assert expected_call in mock_handle_error.call_args_list
502+
503+
504+
def test_enum_collision():
505+
from iree.compiler.dialects import linalg, vector, iree_gpu, iree_codegen, iree_input # type: ignore

0 commit comments

Comments
 (0)