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"},
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,
50 {
"op":
"letterbox",
"height": 640,
"width": 640,
"padValue": 114}
57 "description":
"YOLO detection models with 1280x1280 letterbox preprocessing",
58 "extends":
"detection",
60 "uint8Input": {
"apply":
True,
"inputs": []},
64 "autoConvertFormat":
True,
66 {
"op":
"letterbox",
"height": 1280,
"width": 1280,
"padValue": 114}
73 "description":
"Large Language Models (LLaMA, Qwen, Gemma, etc.)",
75 "equivalentTransformation": {
76 "QK": {
"apply":
True},
77 "UD": {
"apply":
True},
78 "VO": {
"apply":
True},
79 "SpinR1": {
"apply":
True},
80 "SpinR2": {
"apply":
True},
81 "OptimizeFFN": {
"apply":
True},
86 "maxSequenceLength": 4096,
87 "maxCacheLength": 4096,
88 "calibration": {
"useFullSeqLength":
True},
91 "calibration": {
"mode": 0,
"output": 0},
95 "description":
"LLM with faster compilation (less accuracy optimization)",
98 "equivalentTransformation": {
99 "QK": {
"apply":
False},
100 "UD": {
"apply":
False},
101 "VO": {
"apply":
False},
102 "SpinR1": {
"apply":
False},
103 "SpinR2": {
"apply":
False},
104 "OptimizeFFN": {
"apply":
False},
108 "attributes": {
"calibration": {
"useFullSeqLength":
False}},
112 "vision_transformer": {
113 "description":
"Vision Transformer models (ViT, DeiT, Swin, etc.)",
115 "calibration": {
"method": 1,
"mode": 0},
116 "bit": {
"transformer": {
"activation": {
"output": 16,
"ffn": 16}}},
120 "description":
"Multimodal models (CLIP, BLIP, LLaVA, etc.)",
121 "config": {
"calibration": {
"method": 3},
"llm": {
"apply":
True}},
127 """List available preset names."""
128 return list(PRESETS.keys())
132 """Get a CompileConfig from a preset name."""
133 if name
not in PRESETS:
135 raise ValueError(f
"Unknown preset '{name}'. Available: {available}")
137 preset = PRESETS[name]
138 config_data = preset[
"config"].copy()
141 if "extends" in preset:
143 base_data = base.model_dump(by_alias=
True, exclude_none=
True)
146 config_data = base_data
148 return CompileConfig.model_validate(config_data)
152 """Deep merge override into base (mutates base)."""
153 for key, value
in override.items():
154 if key
in base
and isinstance(base[key], dict)
and isinstance(value, dict):
161 """Preset utility class."""
165 """List available preset names."""
169 def get(name: str) -> CompileConfig:
170 """Get a preset by name."""
175 """Get preset description."""
176 if name
not in PRESETS:
177 raise ValueError(f
"Unknown preset: {name}")
178 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.