1"""Auto-generated preset definitions from config_schema.yaml."""
3from typing
import Dict, List
4from .models
import CompileConfig
7PRESETS: Dict[str, dict] = {
9 "description":
"Image classification models (ResNet, EfficientNet, ViT, etc.)",
10 "config": {
"calibration": {
"mode": 1,
"output": 0}},
13 "description":
"Object detection models (YOLO, SSD, DETR, etc.)",
14 "config": {
"calibration": {
"mode": 1,
"output": 1}},
16 "classification_torchvision": {
17 "description":
"Torchvision classification models with standard preprocessing",
18 "extends":
"classification",
20 "uint8Input": {
"apply":
True,
"inputs": []},
24 "autoConvertFormat":
True,
26 {
"op":
"resize",
"size": 256,
"mode":
"bilinear",
"backend":
"pil"},
27 {
"op":
"centerCrop",
"height": 224,
"width": 224},
30 "mean": [0.485, 0.456, 0.406],
31 "std": [0.229, 0.224, 0.225],
33 "fuseIntoFirstLayer":
True,
41 "description":
"YOLO detection models with 640x640 letterbox preprocessing",
42 "extends":
"detection",
44 "uint8Input": {
"apply":
True,
"inputs": []},
48 "autoConvertFormat":
True,
63 "description":
"YOLO detection models with 1280x1280 letterbox preprocessing",
64 "extends":
"detection",
66 "uint8Input": {
"apply":
True,
"inputs": []},
70 "autoConvertFormat":
True,
85 "description":
"Large Language Models (LLaMA, Qwen, Gemma, etc.)",
87 "equivalentTransformation": {
88 "QK": {
"apply":
True},
89 "UD": {
"apply":
True},
90 "VO": {
"apply":
True},
91 "SpinR1": {
"apply":
True},
92 "SpinR2": {
"apply":
True},
93 "OptimizeFFN": {
"apply":
True},
98 "maxSequenceLength": 4096,
99 "maxCacheLength": 4096,
100 "calibration": {
"useFullSeqLength":
True},
103 "calibration": {
"mode": 0,
"output": 0},
107 "description":
"LLM with faster compilation (less accuracy optimization)",
110 "equivalentTransformation": {
111 "QK": {
"apply":
False},
112 "UD": {
"apply":
False},
113 "VO": {
"apply":
False},
114 "SpinR1": {
"apply":
False},
115 "SpinR2": {
"apply":
False},
116 "OptimizeFFN": {
"apply":
False},
120 "attributes": {
"calibration": {
"useFullSeqLength":
False}},
124 "vision_transformer": {
125 "description":
"Vision Transformer models (ViT, DeiT, Swin, etc.)",
127 "calibration": {
"method": 1,
"mode": 0},
128 "bit": {
"transformer": {
"activation": {
"output": 16,
"ffn": 16}}},
132 "description":
"Multimodal models (CLIP, BLIP, LLaVA, etc.)",
133 "config": {
"calibration": {
"method": 3},
"llm": {
"apply":
True}},
139 """List available preset names."""
140 return list(PRESETS.keys())
144 """Get a CompileConfig from a preset name."""
145 if name
not in PRESETS:
147 raise ValueError(f
"Unknown preset '{name}'. Available: {available}")
149 preset = PRESETS[name]
150 config_data = preset[
"config"].copy()
153 if "extends" in preset:
155 base_data = base.model_dump(by_alias=
True, exclude_none=
True)
158 config_data = base_data
160 return CompileConfig.model_validate(config_data)
164 """Deep merge override into base (mutates base)."""
165 for key, value
in override.items():
166 if key
in base
and isinstance(base[key], dict)
and isinstance(value, dict):
173 """Preset utility class."""
177 """List available preset names."""
181 def get(name: str) -> CompileConfig:
182 """Get a preset by name."""
187 """Get preset description."""
188 if name
not in PRESETS:
189 raise ValueError(f
"Unknown preset: {name}")
190 return PRESETS[name].
get(
"description",
"")
str describe(str name)
Get preset description.
List[str] list()
List available preset names.
CompileConfig get(str name)
Get a preset by name.
List[str] list_presets()
List available preset names.
None _deep_merge(dict base, dict override)
Deep merge override into base (mutates base).
CompileConfig get_preset(str name)
Get a CompileConfig from a preset name.