char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

kurquharsnapdragon: python SDK setup (Windows) (#27903)d7bd3bfca

char/aliceai-t5-moe
2.1 KiB62 linesraw
1import os
2from pathlib import Path
3
4
5SDK_CONFIGS = (
6    {
7        "name": "Hexagon SDK",
8        "repo": "snapdragon-toolchain/hexagon-sdk",
9        "default_version": "6.6.0.0",
10        "parent_dir": "Hexagon_SDK",
11        "archive_prefix": "hexagon-sdk-v",
12        "markers": ("hexagon_sdk.json",),
13    },
14    {
15        "name": "OpenCL SDK",
16        "repo": "snapdragon-toolchain/opencl-sdk",
17        "default_version": "2.3.2",
18        "parent_dir": "OpenCL_SDK",
19        "archive_prefix": "adreno-opencl-sdk-v",
20        "markers": ("include/CL", "lib/OpenCL.lib"),
21    },
22)
23
24
25def is_valid_sdk(config, target_dir):
26    return target_dir.is_dir() and all((target_dir / marker).exists() for marker in config["markers"])
27
28
29def get_hexagon_tools_dir(hexagon_dir):
30    tools_parent = hexagon_dir / "tools" / "HEXAGON_Tools"
31    if not tools_parent.is_dir():
32        raise RuntimeError(f"Expected Hexagon tools directory in {tools_parent}")
33    tools_dirs = [path for path in tools_parent.iterdir() if path.is_dir()]
34    if len(tools_dirs) != 1:
35        raise RuntimeError(f"Expected one Hexagon tools directory in {tools_parent}")
36    return tools_dirs[0]
37
38
39def validate_windows_sdks():
40    hexagon_config, opencl_config = SDK_CONFIGS
41    hexagon_dir = os.environ.get("HEXAGON_SDK_ROOT")
42    tools_dir = os.environ.get("HEXAGON_TOOLS_ROOT")
43    opencl_dir = os.environ.get("OPENCL_SDK_ROOT")
44    missing = []
45
46    expected_tools_dir = None
47    if not hexagon_dir or not is_valid_sdk(hexagon_config, Path(hexagon_dir)):
48        missing.append("HEXAGON_SDK_ROOT")
49    else:
50        try:
51            expected_tools_dir = get_hexagon_tools_dir(Path(hexagon_dir))
52        except RuntimeError:
53            pass
54    if not tools_dir or not expected_tools_dir or Path(tools_dir) != expected_tools_dir:
55        missing.append("HEXAGON_TOOLS_ROOT")
56    if not opencl_dir or not is_valid_sdk(opencl_config, Path(opencl_dir)):
57        missing.append("OPENCL_SDK_ROOT")
58    if missing:
59        raise RuntimeError(
60            f"Missing or invalid Windows SDK paths: {', '.join(missing)}. "
61            "Run scripts/snapdragon/setup-sdk.py first."
62        )