Skip to content

Commit

Permalink
[compiler][python] Make target_backends optional (iree-org#18151)
Browse files Browse the repository at this point in the history
When compiling through the iree-compile executable don't require the
target backend(s) to be specified.
It should be allowed to specify multiple target devices instead of
multiple backends.
This is inline with the deprecation of the target backends CLI option.

---------

Signed-off-by: Boian Petkantchin <boian.petkantchin@amd.com>
  • Loading branch information
sogartar authored Aug 9, 2024
1 parent bff3104 commit ab12a4e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
7 changes: 3 additions & 4 deletions compiler/bindings/python/iree/compiler/tools/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,16 @@ def build_compile_command_line(
List of strings of command line.
"""
iree_compile = find_tool("iree-compile")
if not options.target_backends:
raise ValueError("Expected a non-empty list for 'target_backends'")

cl = [
iree_compile,
input_file,
f"--iree-input-type={options.input_type!s}",
f"--iree-vm-bytecode-module-output-format={options.output_format!s}",
]
for target_backend in options.target_backends:
cl.append(f"--iree-hal-target-backends={target_backend}")
if options.target_backends is not None:
for target_backend in options.target_backends:
cl.append(f"--iree-hal-target-backends={target_backend}")

# Output file.
if options.output_file:
Expand Down
6 changes: 0 additions & 6 deletions compiler/bindings/python/test/tools/compiler_core_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ def testQueryTargets(self):
# The VMVX target is always enabled.
self.assertIn("vmvx", target_names)

def testNoTargetBackends(self):
with self.assertRaisesRegex(
ValueError, "Expected a non-empty list for 'target_backends'"
):
binary = iree.compiler.tools.compile_str(SIMPLE_MUL_ASM)

def testCompileStr(self):
binary = iree.compiler.tools.compile_str(
SIMPLE_MUL_ASM, target_backends=iree.compiler.tools.DEFAULT_TESTING_BACKENDS
Expand Down

0 comments on commit ab12a4e

Please sign in to comment.