tvm_tirx.testing#

TIRX test utilities and local capability probes.

tvm_tirx.testing.run_with_gpu_lock(func: Callable[[...], _R], /, *args: Any, **kwargs: Any) → _R#

Run a callable while holding the machine-local GPU lock.

The lock avoids contentious GPU access that may break GPU-related tests.

Parameters:
  • func (Callable) – Callable containing the complete live local-GPU lifetime.

  • *args (Any) – Positional arguments forwarded to func.

  • **kwargs (Any) – Keyword arguments forwarded to func.

Returns:

result – The return value of func.

Return type:

Any

tvm_tirx.testing.assert_allclose(actual, desired, rtol=1e-07, atol=1e-07, verbose=True)#

Version of np.testing.assert_allclose with atol and rtol fields set in reasonable defaults.

Arguments actual and desired are not interchangeable, since the function compares the abs(actual-desired) with atol+rtol*abs(desired). Since we often allow desired to be close to zero, we generally want non-zero atol.

tvm_tirx.testing.device_enabled(target)#

Return whether the target’s runtime and local device are available.

tvm_tirx.testing.generate_random_array(dtype: str, shape: tuple) → ndarray#

Generate a random array by generating random bits and casting to the target dtype.

Supported dtypes:
  • “int8”, “uint8”, “float16”, “float32”, “bfloat16”, “float8_e4m3fn”, “float8_e5m2”

tvm_tirx.testing.identity_after(x, sleep)#

Testing function to return identity after sleep

Parameters:
  • x (int) – The input value.

  • sleep (float) – The amount of time to sleep

Returns:

x – The original value

Return type:

object

tvm_tirx.testing.np_dtype_from_str(dtype: str) → dtype#

Convert a string dtype to a numpy dtype.

tvm_tirx.testing.terminate_self()#

Testing function to terminate the process.