Skip to content

Commit 3d1c45f

Browse files
committed
- Only AOT compilation paths ensure "executor" is provided as a Target attribute.
1 parent da37ead commit 3d1c45f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

python/tvm/relay/build_module.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,13 +740,13 @@ def create_executor(kind="debug", mod=None, device=None, target="llvm", params=N
740740
if device is not None:
741741
assert device.device_type == raw_targets[0].kind.device_type
742742
else:
743-
# Use the first target as the device.
743+
# Derive the default device from the first target.
744744
device = _nd.device(raw_targets[0].kind.device_type, 0)
745745

746746
if params is not None:
747747
mod = IRModule.from_expr(bind_params_by_name(mod["main"], params))
748748

749-
assert raw_targets[0].attrs.get("executor") == kind
749+
assert "executor" not in raw_targets[0].attrs or raw_targets[0].attrs["executor"] == kind
750750

751751
if kind == "debug":
752752
assert len(raw_targets) == 1, "The interpreter currently only supports a single target"
@@ -756,5 +756,9 @@ def create_executor(kind="debug", mod=None, device=None, target="llvm", params=N
756756
if kind == "vm":
757757
return VMExecutor(mod, device, raw_targets)
758758
if kind == "aot":
759+
# The AOT requires the executor as a target attribute.
760+
# (The compilation paths for the other executors currently do not always provide this
761+
# attribute, hence the above generic assert is more forgiving).
762+
assert "executor" in raw_targets[0].attrs
759763
return AotExecutor(mod, device, raw_targets)
760764
raise RuntimeError("unknown execution strategy: {0}".format(kind))

0 commit comments

Comments
 (0)