Skip to content

vllm.model_executor.kernels.linear.zentorch_utils

Gates zentorch CPU linear dispatch on platform/op availability.

has_zentorch_op

has_zentorch_op(op_names: list[str]) -> bool

Return True when running on Zen CPU with all named ops registered.

Source code in vllm/model_executor/kernels/linear/zentorch_utils.py
def has_zentorch_op(op_names: list[str]) -> bool:
    """Return ``True`` when running on Zen CPU with all named ops registered."""
    if not op_names:
        raise ValueError("has_zentorch_op requires at least one op name")
    if not current_platform.is_zen_cpu():
        return False
    ns = getattr(torch.ops, "zentorch", None)
    if ns is None:
        return False
    return all(hasattr(ns, op_name) for op_name in op_names)