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.
- haoline/.streamlit/config.toml +10 -0
- haoline/__init__.py +248 -0
- haoline/analyzer.py +935 -0
- haoline/cli.py +2712 -0
- haoline/compare.py +811 -0
- haoline/compare_visualizations.py +1564 -0
- haoline/edge_analysis.py +525 -0
- haoline/eval/__init__.py +131 -0
- haoline/eval/adapters.py +844 -0
- haoline/eval/cli.py +390 -0
- haoline/eval/comparison.py +542 -0
- haoline/eval/deployment.py +633 -0
- haoline/eval/schemas.py +833 -0
- haoline/examples/__init__.py +15 -0
- haoline/examples/basic_inspection.py +74 -0
- haoline/examples/compare_models.py +117 -0
- haoline/examples/hardware_estimation.py +78 -0
- haoline/format_adapters.py +1001 -0
- haoline/formats/__init__.py +123 -0
- haoline/formats/coreml.py +250 -0
- haoline/formats/gguf.py +483 -0
- haoline/formats/openvino.py +255 -0
- haoline/formats/safetensors.py +273 -0
- haoline/formats/tflite.py +369 -0
- haoline/hardware.py +2307 -0
- haoline/hierarchical_graph.py +462 -0
- haoline/html_export.py +1573 -0
- haoline/layer_summary.py +769 -0
- haoline/llm_summarizer.py +465 -0
- haoline/op_icons.py +618 -0
- haoline/operational_profiling.py +1492 -0
- haoline/patterns.py +1116 -0
- haoline/pdf_generator.py +265 -0
- haoline/privacy.py +250 -0
- haoline/pydantic_models.py +241 -0
- haoline/report.py +1923 -0
- haoline/report_sections.py +539 -0
- haoline/risks.py +521 -0
- haoline/schema.py +523 -0
- haoline/streamlit_app.py +2024 -0
- haoline/tests/__init__.py +4 -0
- haoline/tests/conftest.py +123 -0
- haoline/tests/test_analyzer.py +868 -0
- haoline/tests/test_compare_visualizations.py +293 -0
- haoline/tests/test_edge_analysis.py +243 -0
- haoline/tests/test_eval.py +604 -0
- haoline/tests/test_format_adapters.py +460 -0
- haoline/tests/test_hardware.py +237 -0
- haoline/tests/test_hardware_recommender.py +90 -0
- haoline/tests/test_hierarchical_graph.py +326 -0
- haoline/tests/test_html_export.py +180 -0
- haoline/tests/test_layer_summary.py +428 -0
- haoline/tests/test_llm_patterns.py +540 -0
- haoline/tests/test_llm_summarizer.py +339 -0
- haoline/tests/test_patterns.py +774 -0
- haoline/tests/test_pytorch.py +327 -0
- haoline/tests/test_report.py +383 -0
- haoline/tests/test_risks.py +398 -0
- haoline/tests/test_schema.py +417 -0
- haoline/tests/test_tensorflow.py +380 -0
- haoline/tests/test_visualizations.py +316 -0
- haoline/universal_ir.py +856 -0
- haoline/visualizations.py +1086 -0
- haoline/visualize_yolo.py +44 -0
- haoline/web.py +110 -0
- haoline-0.3.0.dist-info/METADATA +471 -0
- haoline-0.3.0.dist-info/RECORD +70 -0
- haoline-0.3.0.dist-info/WHEEL +4 -0
- haoline-0.3.0.dist-info/entry_points.txt +5 -0
- haoline-0.3.0.dist-info/licenses/LICENSE +22 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Copyright (c) 2025 HaoLine Contributors
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Pytest configuration and shared fixtures for HaoLine tests.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
import tempfile
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
import numpy as np
|
|
15
|
+
import onnx
|
|
16
|
+
import pytest
|
|
17
|
+
from onnx import TensorProto, helper
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@pytest.fixture
|
|
21
|
+
def logger():
|
|
22
|
+
"""Create a test logger."""
|
|
23
|
+
return logging.getLogger("haoline.test")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@pytest.fixture
|
|
27
|
+
def simple_conv_model():
|
|
28
|
+
"""Create a simple Conv model for testing."""
|
|
29
|
+
X = helper.make_tensor_value_info("X", TensorProto.FLOAT, [1, 3, 224, 224])
|
|
30
|
+
W = helper.make_tensor(
|
|
31
|
+
"W",
|
|
32
|
+
TensorProto.FLOAT,
|
|
33
|
+
[64, 3, 7, 7],
|
|
34
|
+
np.random.randn(64, 3, 7, 7).astype(np.float32).flatten().tolist(),
|
|
35
|
+
)
|
|
36
|
+
Y = helper.make_tensor_value_info("Y", TensorProto.FLOAT, [1, 64, 218, 218])
|
|
37
|
+
|
|
38
|
+
conv = helper.make_node("Conv", ["X", "W"], ["Y"], kernel_shape=[7, 7])
|
|
39
|
+
|
|
40
|
+
graph = helper.make_graph([conv], "simple_conv", [X], [Y], [W])
|
|
41
|
+
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 17)])
|
|
42
|
+
|
|
43
|
+
with tempfile.NamedTemporaryFile(suffix=".onnx", delete=False) as f:
|
|
44
|
+
onnx.save(model, f.name)
|
|
45
|
+
yield Path(f.name)
|
|
46
|
+
|
|
47
|
+
# Cleanup
|
|
48
|
+
Path(f.name).unlink(missing_ok=True)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@pytest.fixture
|
|
52
|
+
def conv_bn_relu_model():
|
|
53
|
+
"""Create a Conv-BN-ReLU model for testing."""
|
|
54
|
+
X = helper.make_tensor_value_info("X", TensorProto.FLOAT, [1, 3, 224, 224])
|
|
55
|
+
W = helper.make_tensor(
|
|
56
|
+
"W",
|
|
57
|
+
TensorProto.FLOAT,
|
|
58
|
+
[64, 3, 7, 7],
|
|
59
|
+
np.random.randn(64, 3, 7, 7).astype(np.float32).flatten().tolist(),
|
|
60
|
+
)
|
|
61
|
+
scale = helper.make_tensor(
|
|
62
|
+
"scale", TensorProto.FLOAT, [64], np.ones(64, dtype=np.float32).tolist()
|
|
63
|
+
)
|
|
64
|
+
bias = helper.make_tensor(
|
|
65
|
+
"bias", TensorProto.FLOAT, [64], np.zeros(64, dtype=np.float32).tolist()
|
|
66
|
+
)
|
|
67
|
+
mean = helper.make_tensor(
|
|
68
|
+
"mean", TensorProto.FLOAT, [64], np.zeros(64, dtype=np.float32).tolist()
|
|
69
|
+
)
|
|
70
|
+
var = helper.make_tensor("var", TensorProto.FLOAT, [64], np.ones(64, dtype=np.float32).tolist())
|
|
71
|
+
Y = helper.make_tensor_value_info("Y", TensorProto.FLOAT, [1, 64, 112, 112])
|
|
72
|
+
|
|
73
|
+
conv = helper.make_node(
|
|
74
|
+
"Conv",
|
|
75
|
+
["X", "W"],
|
|
76
|
+
["conv_out"],
|
|
77
|
+
kernel_shape=[7, 7],
|
|
78
|
+
strides=[2, 2],
|
|
79
|
+
pads=[3, 3, 3, 3],
|
|
80
|
+
)
|
|
81
|
+
bn = helper.make_node(
|
|
82
|
+
"BatchNormalization",
|
|
83
|
+
["conv_out", "scale", "bias", "mean", "var"],
|
|
84
|
+
["bn_out"],
|
|
85
|
+
)
|
|
86
|
+
relu = helper.make_node("Relu", ["bn_out"], ["Y"])
|
|
87
|
+
|
|
88
|
+
graph = helper.make_graph(
|
|
89
|
+
[conv, bn, relu], "conv_bn_relu", [X], [Y], [W, scale, bias, mean, var]
|
|
90
|
+
)
|
|
91
|
+
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 17)])
|
|
92
|
+
|
|
93
|
+
with tempfile.NamedTemporaryFile(suffix=".onnx", delete=False) as f:
|
|
94
|
+
onnx.save(model, f.name)
|
|
95
|
+
yield Path(f.name)
|
|
96
|
+
|
|
97
|
+
# Cleanup
|
|
98
|
+
Path(f.name).unlink(missing_ok=True)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@pytest.fixture
|
|
102
|
+
def matmul_model():
|
|
103
|
+
"""Create a simple MatMul model for testing."""
|
|
104
|
+
X = helper.make_tensor_value_info("X", TensorProto.FLOAT, [1, 512])
|
|
105
|
+
W = helper.make_tensor(
|
|
106
|
+
"W",
|
|
107
|
+
TensorProto.FLOAT,
|
|
108
|
+
[512, 1000],
|
|
109
|
+
np.random.randn(512, 1000).astype(np.float32).flatten().tolist(),
|
|
110
|
+
)
|
|
111
|
+
Y = helper.make_tensor_value_info("Y", TensorProto.FLOAT, [1, 1000])
|
|
112
|
+
|
|
113
|
+
matmul = helper.make_node("MatMul", ["X", "W"], ["Y"])
|
|
114
|
+
|
|
115
|
+
graph = helper.make_graph([matmul], "matmul", [X], [Y], [W])
|
|
116
|
+
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 17)])
|
|
117
|
+
|
|
118
|
+
with tempfile.NamedTemporaryFile(suffix=".onnx", delete=False) as f:
|
|
119
|
+
onnx.save(model, f.name)
|
|
120
|
+
yield Path(f.name)
|
|
121
|
+
|
|
122
|
+
# Cleanup
|
|
123
|
+
Path(f.name).unlink(missing_ok=True)
|