haoline 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. haoline/.streamlit/config.toml +10 -0
  2. haoline/__init__.py +248 -0
  3. haoline/analyzer.py +935 -0
  4. haoline/cli.py +2712 -0
  5. haoline/compare.py +811 -0
  6. haoline/compare_visualizations.py +1564 -0
  7. haoline/edge_analysis.py +525 -0
  8. haoline/eval/__init__.py +131 -0
  9. haoline/eval/adapters.py +844 -0
  10. haoline/eval/cli.py +390 -0
  11. haoline/eval/comparison.py +542 -0
  12. haoline/eval/deployment.py +633 -0
  13. haoline/eval/schemas.py +833 -0
  14. haoline/examples/__init__.py +15 -0
  15. haoline/examples/basic_inspection.py +74 -0
  16. haoline/examples/compare_models.py +117 -0
  17. haoline/examples/hardware_estimation.py +78 -0
  18. haoline/format_adapters.py +1001 -0
  19. haoline/formats/__init__.py +123 -0
  20. haoline/formats/coreml.py +250 -0
  21. haoline/formats/gguf.py +483 -0
  22. haoline/formats/openvino.py +255 -0
  23. haoline/formats/safetensors.py +273 -0
  24. haoline/formats/tflite.py +369 -0
  25. haoline/hardware.py +2307 -0
  26. haoline/hierarchical_graph.py +462 -0
  27. haoline/html_export.py +1573 -0
  28. haoline/layer_summary.py +769 -0
  29. haoline/llm_summarizer.py +465 -0
  30. haoline/op_icons.py +618 -0
  31. haoline/operational_profiling.py +1492 -0
  32. haoline/patterns.py +1116 -0
  33. haoline/pdf_generator.py +265 -0
  34. haoline/privacy.py +250 -0
  35. haoline/pydantic_models.py +241 -0
  36. haoline/report.py +1923 -0
  37. haoline/report_sections.py +539 -0
  38. haoline/risks.py +521 -0
  39. haoline/schema.py +523 -0
  40. haoline/streamlit_app.py +2024 -0
  41. haoline/tests/__init__.py +4 -0
  42. haoline/tests/conftest.py +123 -0
  43. haoline/tests/test_analyzer.py +868 -0
  44. haoline/tests/test_compare_visualizations.py +293 -0
  45. haoline/tests/test_edge_analysis.py +243 -0
  46. haoline/tests/test_eval.py +604 -0
  47. haoline/tests/test_format_adapters.py +460 -0
  48. haoline/tests/test_hardware.py +237 -0
  49. haoline/tests/test_hardware_recommender.py +90 -0
  50. haoline/tests/test_hierarchical_graph.py +326 -0
  51. haoline/tests/test_html_export.py +180 -0
  52. haoline/tests/test_layer_summary.py +428 -0
  53. haoline/tests/test_llm_patterns.py +540 -0
  54. haoline/tests/test_llm_summarizer.py +339 -0
  55. haoline/tests/test_patterns.py +774 -0
  56. haoline/tests/test_pytorch.py +327 -0
  57. haoline/tests/test_report.py +383 -0
  58. haoline/tests/test_risks.py +398 -0
  59. haoline/tests/test_schema.py +417 -0
  60. haoline/tests/test_tensorflow.py +380 -0
  61. haoline/tests/test_visualizations.py +316 -0
  62. haoline/universal_ir.py +856 -0
  63. haoline/visualizations.py +1086 -0
  64. haoline/visualize_yolo.py +44 -0
  65. haoline/web.py +110 -0
  66. haoline-0.3.0.dist-info/METADATA +471 -0
  67. haoline-0.3.0.dist-info/RECORD +70 -0
  68. haoline-0.3.0.dist-info/WHEEL +4 -0
  69. haoline-0.3.0.dist-info/entry_points.txt +5 -0
  70. haoline-0.3.0.dist-info/licenses/LICENSE +22 -0
@@ -0,0 +1,241 @@
1
+ # generated by datamodel-codegen:
2
+ # filename: inspection_report_schema.json
3
+ # timestamp: 2025-12-04T22:53:59+00:00
4
+
5
+ from __future__ import annotations
6
+
7
+ from datetime import datetime
8
+ from enum import Enum
9
+ from typing import Annotated, Any
10
+
11
+ from pydantic import BaseModel, Field
12
+
13
+
14
+ class Metadata(BaseModel):
15
+ path: Annotated[str, Field(description="Path to the ONNX model file")]
16
+ ir_version: Annotated[int, Field(description="ONNX IR version", ge=1)]
17
+ producer_name: Annotated[str, Field(description="Name of the tool that produced the model")]
18
+ producer_version: Annotated[str | None, Field(description="Version of the producer tool")] = (
19
+ None
20
+ )
21
+ domain: Annotated[str | None, Field(description="Model domain")] = None
22
+ model_version: Annotated[int | None, Field(description="Model version number")] = None
23
+ doc_string: Annotated[str | None, Field(description="Model documentation string")] = None
24
+ opsets: Annotated[dict[str, int], Field(description="Opset versions by domain")]
25
+
26
+
27
+ class GraphSummary(BaseModel):
28
+ num_nodes: Annotated[int | None, Field(description="Total number of nodes in graph", ge=0)] = (
29
+ None
30
+ )
31
+ num_inputs: Annotated[int | None, Field(description="Number of graph inputs", ge=0)] = None
32
+ num_outputs: Annotated[int | None, Field(description="Number of graph outputs", ge=0)] = None
33
+ num_initializers: Annotated[
34
+ int | None, Field(description="Number of initializers (weights)", ge=0)
35
+ ] = None
36
+ input_shapes: Annotated[
37
+ dict[str, list[int | str]] | None, Field(description="Input tensor shapes by name")
38
+ ] = None
39
+ output_shapes: Annotated[
40
+ dict[str, list[int | str]] | None,
41
+ Field(description="Output tensor shapes by name"),
42
+ ] = None
43
+ op_type_counts: Annotated[
44
+ dict[str, int] | None, Field(description="Count of each operator type")
45
+ ] = None
46
+
47
+
48
+ class SharedWeights(BaseModel):
49
+ count: Annotated[
50
+ int | None, Field(description="Number of weights shared across 2+ nodes", ge=0)
51
+ ] = None
52
+ details: Annotated[
53
+ dict[str, list[str]] | None,
54
+ Field(description="Shared weight name to list of node names using it"),
55
+ ] = None
56
+
57
+
58
+ class ParamCounts(BaseModel):
59
+ total: Annotated[int | None, Field(description="Total parameter count", ge=0)] = None
60
+ trainable: Annotated[int | None, Field(description="Trainable parameter count", ge=0)] = None
61
+ non_trainable: Annotated[
62
+ int | None, Field(description="Non-trainable parameter count", ge=0)
63
+ ] = None
64
+ by_op_type: Annotated[
65
+ dict[str, float] | None,
66
+ Field(description="Parameters by operator type (fractional for shared weights)"),
67
+ ] = None
68
+ shared_weights: Annotated[
69
+ SharedWeights | None, Field(description="Information about shared weights")
70
+ ] = None
71
+ precision_breakdown: Annotated[
72
+ dict[str, int] | None,
73
+ Field(description="Parameter count by data type (fp32, fp16, int8, etc.)"),
74
+ ] = None
75
+ is_quantized: Annotated[
76
+ bool | None, Field(description="Whether model uses quantized weights or ops")
77
+ ] = None
78
+ quantized_ops: Annotated[
79
+ list[str] | None, Field(description="List of quantized operation types detected")
80
+ ] = None
81
+
82
+
83
+ class Hotspot(BaseModel):
84
+ name: str | None = None
85
+ op_type: str | None = None
86
+ flops: Annotated[int | None, Field(ge=0)] = None
87
+
88
+
89
+ class FlopCounts(BaseModel):
90
+ total: Annotated[int | None, Field(description="Total estimated FLOPs", ge=0)] = None
91
+ by_node_type: Annotated[dict[str, int] | None, Field(description="FLOPs by operator type")] = (
92
+ None
93
+ )
94
+ hotspots: Annotated[list[Hotspot] | None, Field(description="Top compute-intensive nodes")] = (
95
+ None
96
+ )
97
+
98
+
99
+ class KvCacheConfig(BaseModel):
100
+ num_layers: Annotated[int | None, Field(ge=0)] = None
101
+ hidden_dim: Annotated[int | None, Field(ge=0)] = None
102
+ seq_len: Annotated[int | None, Field(ge=0)] = None
103
+ bytes_per_element: Annotated[int | None, Field(ge=1)] = None
104
+
105
+
106
+ class Breakdown(BaseModel):
107
+ weights_by_op_type: dict[str, int] | None = None
108
+ activations_by_op_type: dict[str, int] | None = None
109
+
110
+
111
+ class MemoryEstimates(BaseModel):
112
+ model_size_bytes: Annotated[int | None, Field(description="Model size in bytes", ge=0)] = None
113
+ peak_activation_bytes: Annotated[
114
+ int | None, Field(description="Peak activation memory in bytes", ge=0)
115
+ ] = None
116
+ kv_cache_bytes_per_token: Annotated[
117
+ int | None, Field(description="KV cache memory per token (transformers)", ge=0)
118
+ ] = None
119
+ kv_cache_bytes_full_context: Annotated[
120
+ int | None, Field(description="KV cache for full context length", ge=0)
121
+ ] = None
122
+ kv_cache_config: Annotated[
123
+ KvCacheConfig | None, Field(description="KV cache configuration")
124
+ ] = None
125
+ breakdown: Annotated[Breakdown | None, Field(description="Memory breakdown by component")] = (
126
+ None
127
+ )
128
+
129
+
130
+ class DetectedBlock(BaseModel):
131
+ block_type: Annotated[str, Field(description="Type of block (e.g., ResidualAdd, Attention)")]
132
+ name: Annotated[str, Field(description="Block identifier")]
133
+ nodes: Annotated[list[str] | None, Field(description="Node names in this block")] = None
134
+ start_node: str | None = None
135
+ end_node: str | None = None
136
+ attributes: Annotated[dict[str, Any] | None, Field(description="Block-specific attributes")] = (
137
+ None
138
+ )
139
+
140
+
141
+ class ArchitectureType(Enum):
142
+ transformer = "transformer"
143
+ cnn = "cnn"
144
+ mlp = "mlp"
145
+ hybrid = "hybrid"
146
+ unknown = "unknown"
147
+
148
+
149
+ class Severity(Enum):
150
+ info = "info"
151
+ warning = "warning"
152
+ high = "high"
153
+
154
+
155
+ class RiskSignal(BaseModel):
156
+ id: Annotated[str, Field(description="Risk signal identifier")]
157
+ severity: Annotated[Severity, Field(description="Severity level")]
158
+ description: Annotated[str, Field(description="Human-readable description")]
159
+ nodes: Annotated[list[str] | None, Field(description="Affected node names")] = None
160
+ recommendation: Annotated[str | None, Field(description="Recommended action")] = None
161
+
162
+
163
+ class HardwareProfile(BaseModel):
164
+ name: str | None = None
165
+ vram_bytes: Annotated[int | None, Field(ge=0)] = None
166
+ peak_fp32_tflops: Annotated[float | None, Field(ge=0.0)] = None
167
+ peak_fp16_tflops: Annotated[float | None, Field(ge=0.0)] = None
168
+ memory_bandwidth_gbps: Annotated[float | None, Field(ge=0.0)] = None
169
+ tdp_watts: int | None = None
170
+
171
+
172
+ class HardwareEstimates(BaseModel):
173
+ device: str | None = None
174
+ precision: str | None = None
175
+ batch_size: Annotated[int | None, Field(ge=1)] = None
176
+ vram_required_bytes: Annotated[int | None, Field(ge=0)] = None
177
+ fits_in_vram: bool | None = None
178
+ theoretical_latency_ms: Annotated[float | None, Field(ge=0.0)] = None
179
+ bottleneck: str | None = None
180
+ compute_utilization_estimate: Annotated[float | None, Field(ge=0.0)] = None
181
+ gpu_saturation: Annotated[float | None, Field(ge=0.0)] = None
182
+
183
+
184
+ class LlmSummary(BaseModel):
185
+ success: bool | None = None
186
+ short_summary: str | None = None
187
+ detailed_summary: str | None = None
188
+ model: str | None = None
189
+ error: str | None = None
190
+
191
+
192
+ class DatasetInfo(BaseModel):
193
+ task: str | None = None
194
+ num_classes: Annotated[int | None, Field(ge=0)] = None
195
+ class_names: list[str] | None = None
196
+ source: str | None = None
197
+
198
+
199
+ class HaolineInspectionReport(BaseModel):
200
+ metadata: Annotated[Metadata, Field(description="Model metadata extracted from ONNX proto")]
201
+ generated_at: Annotated[
202
+ datetime, Field(description="ISO 8601 timestamp when report was generated")
203
+ ]
204
+ autodoc_version: Annotated[
205
+ str,
206
+ Field(
207
+ description="Version of HaoLine that generated the report",
208
+ pattern=r"^[0-9]+\.[0-9]+\.[0-9]+",
209
+ ),
210
+ ]
211
+ graph_summary: Annotated[
212
+ GraphSummary | None, Field(description="Summary statistics about the ONNX graph")
213
+ ] = None
214
+ param_counts: Annotated[ParamCounts | None, Field(description="Parameter count statistics")] = (
215
+ None
216
+ )
217
+ flop_counts: Annotated[FlopCounts | None, Field(description="FLOP estimation statistics")] = (
218
+ None
219
+ )
220
+ memory_estimates: Annotated[
221
+ MemoryEstimates | None, Field(description="Memory usage estimates")
222
+ ] = None
223
+ detected_blocks: Annotated[
224
+ list[DetectedBlock] | None, Field(description="Detected architectural blocks")
225
+ ] = None
226
+ architecture_type: Annotated[
227
+ ArchitectureType | None, Field(description="Detected architecture type")
228
+ ] = None
229
+ risk_signals: Annotated[list[RiskSignal] | None, Field(description="Detected risk signals")] = (
230
+ None
231
+ )
232
+ hardware_profile: Annotated[
233
+ HardwareProfile | None, Field(description="Target hardware profile")
234
+ ] = None
235
+ hardware_estimates: Annotated[
236
+ HardwareEstimates | None, Field(description="Hardware-specific estimates")
237
+ ] = None
238
+ llm_summary: Annotated[LlmSummary | None, Field(description="LLM-generated summary")] = None
239
+ dataset_info: Annotated[
240
+ DatasetInfo | None, Field(description="Dataset and class information")
241
+ ] = None