MCPcopy Index your code
hub / github.com/apache/tvm / _get_targets

Function _get_targets

python/tvm/testing/utils.py:385–442  ·  view source on GitHub ↗
(target_names=None)

Source from the content-addressed store, hash-verified

383
384
385def _get_targets(target_names=None):
386 if target_names is None:
387 target_names = _tvm_test_targets()
388
389 if not target_names:
390 target_names = DEFAULT_TEST_TARGETS
391
392 targets = []
393 for target in target_names:
394 if isinstance(target, dict):
395 target_kind = target["kind"]
396 else:
397 target_kind = target.split()[0]
398
399 if target_kind == "cuda" and "cudnn" in tvm.target.Target(target).attrs.get("libs", []):
400 is_enabled = tvm.support.libinfo().get("USE_CUDNN", "OFF").lower() in [
401 "on",
402 "true",
403 "1",
404 ]
405 is_runnable = is_enabled and cudnn.exists()
406 elif target_kind == "hexagon":
407 is_enabled = tvm.support.libinfo().get("USE_HEXAGON", "OFF").lower() in [
408 "on",
409 "true",
410 "1",
411 ]
412 # If Hexagon has compile-time support, we can always fall back
413 is_runnable = is_enabled and "ANDROID_SERIAL_NUMBER" in os.environ
414 else:
415 is_enabled = tvm.runtime.enabled(target_kind)
416 is_runnable = is_enabled and tvm.device(target_kind).exist
417
418 targets.append(
419 {
420 "target": target,
421 "target_kind": target_kind,
422 "is_enabled": is_enabled,
423 "is_runnable": is_runnable,
424 }
425 )
426
427 if all(not t["is_runnable"] for t in targets):
428 if tvm.runtime.enabled("llvm"):
429 logging.warning(
430 "None of the following targets are supported by this build of TVM: %s."
431 " Try setting TVM_TEST_TARGETS to a supported target. Defaulting to llvm.",
432 target_names,
433 )
434 return _get_targets(["llvm"])
435
436 raise RuntimeError(
437 "None of the following targets are supported by this build of TVM: %s."
438 " Try setting TVM_TEST_TARGETS to a supported target."
439 " Cannot default to llvm, as it is not enabled." % target_names
440 )
441
442 return targets

Callers 2

device_enabledFunction · 0.85
enabled_targetsFunction · 0.85

Calls 7

_tvm_test_targetsFunction · 0.85
allFunction · 0.50
splitMethod · 0.45
getMethod · 0.45
enabledMethod · 0.45
deviceMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…