diff --git a/src/target/target_kind.cc b/src/target/target_kind.cc index d037b9dfdbdb6..777e016939392 100644 --- a/src/target/target_kind.cc +++ b/src/target/target_kind.cc @@ -217,11 +217,9 @@ Map UpdateROCmAttrs(Map attrs) { Map UpdateVulkanAttrs(Map attrs) { if (attrs.count("from_device")) { int device_id = Downcast(attrs.at("from_device")); + attrs.erase("from_device"); + Device device{kDLVulkan, device_id}; - const PackedFunc* get_target_property = - runtime::Registry::Get("device_api.vulkan.get_target_property"); - ICHECK(get_target_property) - << "Requested to read Vulkan parameters from device, but no Vulkan runtime available"; // Current vulkan implementation is partially a proof-of-concept, // with long-term goal to move the -from_device functionality to @@ -251,23 +249,31 @@ Map UpdateVulkanAttrs(Map attrs) { "max_spirv_version"}; std::vector str_opts = {"device_name"}; - for (auto& key : bool_opts) { - if (!attrs.count(key)) { - attrs.Set(key, Bool(static_cast((*get_target_property)(device, key)))); + const PackedFunc* get_target_property = + runtime::Registry::Get("device_api.vulkan.get_target_property"); + + if (get_target_property) { + for (auto& key : bool_opts) { + if (!attrs.count(key)) { + attrs.Set(key, Bool(static_cast((*get_target_property)(device, key)))); + } } - } - for (auto& key : int_opts) { - if (!attrs.count(key)) { - attrs.Set(key, Integer(static_cast((*get_target_property)(device, key)))); + for (auto& key : int_opts) { + if (!attrs.count(key)) { + attrs.Set(key, Integer(static_cast((*get_target_property)(device, key)))); + } } - } - for (auto& key : str_opts) { - if (!attrs.count(key)) { - attrs.Set(key, (*get_target_property)(device, key)); + for (auto& key : str_opts) { + if (!attrs.count(key)) { + attrs.Set(key, (*get_target_property)(device, key)); + } } - } - attrs.erase("from_device"); + } else { + DLOG(WARNING) + << "Requested to read Vulkan parameters from device, but no Vulkan runtime available. " + << "Defaulting to the minimum provided by the Vulkan 1.0 spec."; + } } // Set defaults here, rather than in the .add_attr_option() calls. diff --git a/tests/python/topi/python/test_topi_batch_matmul.py b/tests/python/topi/python/test_topi_batch_matmul.py index 8c8ad37287dc0..29308ab4d1bc9 100644 --- a/tests/python/topi/python/test_topi_batch_matmul.py +++ b/tests/python/topi/python/test_topi_batch_matmul.py @@ -85,7 +85,8 @@ def check_device(target, dev): tvm.testing.assert_allclose(c.numpy(), c_np, rtol=1e-5) for target, dev in tvm.testing.enabled_targets(): - if dynamic and (target == "cuda" or target == "nvptx"): + target_kind = tvm.target.Target(target).kind.name + if dynamic and target_kind in ["cuda", "nvptx"]: print("Dynamic batch matmul test is skippped on %s" % target) continue