Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/winml/modelkit/compiler/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,18 @@ def for_vitisai(cls, device: str | None = None) -> WinMLCompileConfig:
when available (target=X1, xclbin=<install>/voe-4.0-win_amd64/
xclbins/phoenix/4x4.xclbin, xlnx_enable_py3_round=0). VitisAI EP
ignores ``device_type``; the correct device hint is the xclbin path.
The cache is placed under WinML's user-writable cache root instead of
VitisAI's installation-relative default, which may resolve through the
protected WindowsApps directory and fail during model compilation.
"""
import os
from pathlib import Path as _Path

provider_options: dict[str, str] = {}
from ..cache import get_cache_dir

vaip_cache_dir = (get_cache_dir() / "vitisai").resolve()
vaip_cache_dir.mkdir(parents=True, exist_ok=True)
provider_options: dict[str, str] = {"cache_dir": str(vaip_cache_dir)}
ryzen_ai = os.environ.get("RYZEN_AI_INSTALLATION_PATH")
if ryzen_ai:
xclbin = _Path(ryzen_ai) / "voe-4.0-win_amd64" / "xclbins" / "phoenix" / "4x4.xclbin"
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/compiler/test_compiler_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,14 @@ def test_for_openvino(self):
assert config.ep_config.provider == "openvino"
assert config.ep_config.enable_ep_context is True

def test_for_vitisai(self):
def test_for_vitisai(self, tmp_path, monkeypatch):
"""Test Vitis AI factory method."""
monkeypatch.setenv("WINML_CACHE_DIR", str(tmp_path))
config = WinMLCompileConfig.for_vitisai()
assert config.ep_config.provider == "vitisai"
assert config.ep_config.enable_ep_context is True
assert config.ep_config.provider_options["cache_dir"] == str(tmp_path / "vitisai")
assert (tmp_path / "vitisai").is_dir()

def test_for_migraphx(self):
"""Test MIGraphX factory method."""
Expand Down
Loading