TACHY-Compiler 0.1.1__tar.gz
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.
- tachy_compiler-0.1.1/PKG-INFO +93 -0
- tachy_compiler-0.1.1/README.md +75 -0
- tachy_compiler-0.1.1/pyproject.toml +40 -0
- tachy_compiler-0.1.1/setup.cfg +4 -0
- tachy_compiler-0.1.1/src/TACHY_Compiler.egg-info/PKG-INFO +93 -0
- tachy_compiler-0.1.1/src/TACHY_Compiler.egg-info/SOURCES.txt +37 -0
- tachy_compiler-0.1.1/src/TACHY_Compiler.egg-info/dependency_links.txt +1 -0
- tachy_compiler-0.1.1/src/TACHY_Compiler.egg-info/entry_points.txt +2 -0
- tachy_compiler-0.1.1/src/TACHY_Compiler.egg-info/requires.txt +10 -0
- tachy_compiler-0.1.1/src/TACHY_Compiler.egg-info/top_level.txt +1 -0
- tachy_compiler-0.1.1/src/tachy_compiler/__init__.py +10 -0
- tachy_compiler-0.1.1/src/tachy_compiler/cli.py +41 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/__init__.py +8 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/constraint.py +65 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/convert_layer2block.py +590 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/convert_tachy2tachyrt.py +168 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/editor.py +1831 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/extract.py +179 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/format_prototxt.py +365 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/functions.py +870 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/graph.py +720 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/map_address.py +44 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/onnx2tachy.py +416 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/pipeline.py +74 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/runtime.py +93 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/tachy_block.py +700 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/tachy_format.py +61 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/tachy_inference.py +150 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/tachy_layers.py +1166 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/tachy_model.py +319 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/tachy_prototxt.py +290 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/tachy_viewer.py +25 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/tachyrt_model.py +280 -0
- tachy_compiler-0.1.1/src/tachy_compiler/compiler/verify.py +15 -0
- tachy_compiler-0.1.1/src/tachy_compiler/mcp_server.py +83 -0
- tachy_compiler-0.1.1/src/tachy_compiler/platform_converter/__init__.py +8 -0
- tachy_compiler-0.1.1/src/tachy_compiler/platform_converter/deploy_pt_yolov9.py +128 -0
- tachy_compiler-0.1.1/src/tachy_compiler/platform_converter/pt2onnx.py +126 -0
- tachy_compiler-0.1.1/src/tachy_compiler/platform_converter/yolov9_utils/__init__.py +46 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: TACHY-Compiler
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: TACHY model compiler and platform conversion tools.
|
|
5
|
+
Author: Deeper-I
|
|
6
|
+
License: BSD-3-Clause
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: numpy
|
|
10
|
+
Requires-Dist: networkx
|
|
11
|
+
Requires-Dist: onnx
|
|
12
|
+
Requires-Dist: commentjson
|
|
13
|
+
Requires-Dist: ordered-set
|
|
14
|
+
Requires-Dist: easydict
|
|
15
|
+
Requires-Dist: DDesignerAPI
|
|
16
|
+
Provides-Extra: yolov9
|
|
17
|
+
Requires-Dist: torch; extra == "yolov9"
|
|
18
|
+
|
|
19
|
+
# TACHY-Compiler
|
|
20
|
+
|
|
21
|
+
TACHY-Compiler is a comprehensive deep learning compiler and platform conversion framework developed by Deeper-I. It is designed to bridge the gap between popular deep learning frameworks (like PyTorch) and the TACHY hardware accelerator runtime environment.
|
|
22
|
+
|
|
23
|
+
This compiler handles model parsing, optimization, tensor alignment, and binary generation. It robustly supports large-scale models, complex operators, and dual-checkpoint pipelines out of the box.
|
|
24
|
+
|
|
25
|
+
## Key Features
|
|
26
|
+
|
|
27
|
+
- **PyTorch to ONNX to TACHY**: Seamless end-to-end compilation pipeline.
|
|
28
|
+
- **Dual Checkpoint Compilation (`compile-dual`)**: Officially supports simultaneous parsing and compilation of Reference (`eval` / `pre`) and Target (`comp` / `opt`) checkpoints into a unified output structure.
|
|
29
|
+
- **Large Model Support**: Built-in mechanisms to handle models larger than the Protobuf 2GB limit using `external_data` mapping.
|
|
30
|
+
- **Robust ONNX Versioning**: Automatically utilizes ONNX Opset 18 for stability, equipped with automatic version conversion and fallback mechanisms to mitigate `onnxscript` conversion issues.
|
|
31
|
+
- **MCP Server Integrated**: Exposes tools to LLMs and agentic frameworks via the Model Context Protocol (MCP) using `FastMCP`.
|
|
32
|
+
- **Dynamic Binary Resolution**: Intelligently locates dependency binaries utilizing environment variables (`TACHY_UTIL_PATH`) and relative package paths.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
You can install TACHY-Compiler directly via PyPI:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install TACHY-Compiler
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Requirements
|
|
43
|
+
- Python >= 3.8
|
|
44
|
+
- `numpy`, `networkx`, `onnx`, `commentjson`, `ordered-set`, `easydict`, `DDesignerAPI`
|
|
45
|
+
- (Optional) `torch` if utilizing the PyTorch to ONNX conversion pipeline.
|
|
46
|
+
|
|
47
|
+
## CLI Usage
|
|
48
|
+
|
|
49
|
+
TACHY-Compiler provides a simple, unified command-line interface under the `tachy` command.
|
|
50
|
+
|
|
51
|
+
### 1. Dual Checkpoint Compilation
|
|
52
|
+
Best for executing the full compilation pipeline for two checkpoints (e.g. `eval` and `comp`) simultaneously. Intermediate files are automatically managed and cleaned up if requested.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
tachy compile-dual \
|
|
56
|
+
--eval_model ./eval_model.pth \
|
|
57
|
+
--comp_model ./comp_model.pth \
|
|
58
|
+
--input_shape "[1,3,224,224]" \
|
|
59
|
+
--output_dir ./dual_output \
|
|
60
|
+
--cleanup
|
|
61
|
+
```
|
|
62
|
+
Outputs will be cleanly structured into `./dual_output/final_binaries/eval/` and `./dual_output/final_binaries/comp/`.
|
|
63
|
+
|
|
64
|
+
### 2. Single Model Pipeline Steps
|
|
65
|
+
If you need granular control, you can execute the pipeline steps individually.
|
|
66
|
+
|
|
67
|
+
**Convert PyTorch to ONNX**
|
|
68
|
+
```bash
|
|
69
|
+
tachy convert-pt2onnx ./model.pth ./model.onnx "[1,3,224,224]" False
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Convert ONNX to TACHY Format**
|
|
73
|
+
```bash
|
|
74
|
+
tachy convert-onnx ./model.onnx ./model.json
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Compile TACHY JSON to Runtime Binaries**
|
|
78
|
+
```bash
|
|
79
|
+
tachy compile ./model.json ./output_bin_dir
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 3. Model Context Protocol (MCP) Server
|
|
83
|
+
You can spin up the built-in MCP server to allow LLMs and AI Agents to compile models on your behalf.
|
|
84
|
+
```bash
|
|
85
|
+
tachy mcp
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Environment Variables
|
|
89
|
+
- `TACHY_UTIL_PATH` (Optional): An absolute path to the directory containing external utility binaries (`fc.out`, `block_4bit.out`). If not set, the compiler will intelligently look for the `optional` directory within the installed package.
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
This project is licensed under the BSD-3-Clause License. See the LICENSE file for details.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# TACHY-Compiler
|
|
2
|
+
|
|
3
|
+
TACHY-Compiler is a comprehensive deep learning compiler and platform conversion framework developed by Deeper-I. It is designed to bridge the gap between popular deep learning frameworks (like PyTorch) and the TACHY hardware accelerator runtime environment.
|
|
4
|
+
|
|
5
|
+
This compiler handles model parsing, optimization, tensor alignment, and binary generation. It robustly supports large-scale models, complex operators, and dual-checkpoint pipelines out of the box.
|
|
6
|
+
|
|
7
|
+
## Key Features
|
|
8
|
+
|
|
9
|
+
- **PyTorch to ONNX to TACHY**: Seamless end-to-end compilation pipeline.
|
|
10
|
+
- **Dual Checkpoint Compilation (`compile-dual`)**: Officially supports simultaneous parsing and compilation of Reference (`eval` / `pre`) and Target (`comp` / `opt`) checkpoints into a unified output structure.
|
|
11
|
+
- **Large Model Support**: Built-in mechanisms to handle models larger than the Protobuf 2GB limit using `external_data` mapping.
|
|
12
|
+
- **Robust ONNX Versioning**: Automatically utilizes ONNX Opset 18 for stability, equipped with automatic version conversion and fallback mechanisms to mitigate `onnxscript` conversion issues.
|
|
13
|
+
- **MCP Server Integrated**: Exposes tools to LLMs and agentic frameworks via the Model Context Protocol (MCP) using `FastMCP`.
|
|
14
|
+
- **Dynamic Binary Resolution**: Intelligently locates dependency binaries utilizing environment variables (`TACHY_UTIL_PATH`) and relative package paths.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
You can install TACHY-Compiler directly via PyPI:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install TACHY-Compiler
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Requirements
|
|
25
|
+
- Python >= 3.8
|
|
26
|
+
- `numpy`, `networkx`, `onnx`, `commentjson`, `ordered-set`, `easydict`, `DDesignerAPI`
|
|
27
|
+
- (Optional) `torch` if utilizing the PyTorch to ONNX conversion pipeline.
|
|
28
|
+
|
|
29
|
+
## CLI Usage
|
|
30
|
+
|
|
31
|
+
TACHY-Compiler provides a simple, unified command-line interface under the `tachy` command.
|
|
32
|
+
|
|
33
|
+
### 1. Dual Checkpoint Compilation
|
|
34
|
+
Best for executing the full compilation pipeline for two checkpoints (e.g. `eval` and `comp`) simultaneously. Intermediate files are automatically managed and cleaned up if requested.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
tachy compile-dual \
|
|
38
|
+
--eval_model ./eval_model.pth \
|
|
39
|
+
--comp_model ./comp_model.pth \
|
|
40
|
+
--input_shape "[1,3,224,224]" \
|
|
41
|
+
--output_dir ./dual_output \
|
|
42
|
+
--cleanup
|
|
43
|
+
```
|
|
44
|
+
Outputs will be cleanly structured into `./dual_output/final_binaries/eval/` and `./dual_output/final_binaries/comp/`.
|
|
45
|
+
|
|
46
|
+
### 2. Single Model Pipeline Steps
|
|
47
|
+
If you need granular control, you can execute the pipeline steps individually.
|
|
48
|
+
|
|
49
|
+
**Convert PyTorch to ONNX**
|
|
50
|
+
```bash
|
|
51
|
+
tachy convert-pt2onnx ./model.pth ./model.onnx "[1,3,224,224]" False
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Convert ONNX to TACHY Format**
|
|
55
|
+
```bash
|
|
56
|
+
tachy convert-onnx ./model.onnx ./model.json
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Compile TACHY JSON to Runtime Binaries**
|
|
60
|
+
```bash
|
|
61
|
+
tachy compile ./model.json ./output_bin_dir
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 3. Model Context Protocol (MCP) Server
|
|
65
|
+
You can spin up the built-in MCP server to allow LLMs and AI Agents to compile models on your behalf.
|
|
66
|
+
```bash
|
|
67
|
+
tachy mcp
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Environment Variables
|
|
71
|
+
- `TACHY_UTIL_PATH` (Optional): An absolute path to the directory containing external utility binaries (`fc.out`, `block_4bit.out`). If not set, the compiler will intelligently look for the `optional` directory within the installed package.
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
This project is licensed under the BSD-3-Clause License. See the LICENSE file for details.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "TACHY-Compiler"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "TACHY model compiler and platform conversion tools."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = {text = "BSD-3-Clause"}
|
|
12
|
+
authors = [{name = "Deeper-I"}]
|
|
13
|
+
|
|
14
|
+
dependencies = [
|
|
15
|
+
"numpy",
|
|
16
|
+
"networkx",
|
|
17
|
+
"onnx",
|
|
18
|
+
"commentjson",
|
|
19
|
+
"ordered-set",
|
|
20
|
+
"easydict",
|
|
21
|
+
"DDesignerAPI",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
yolov9 = [
|
|
26
|
+
"torch",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[tool.setuptools]
|
|
30
|
+
include-package-data = true
|
|
31
|
+
|
|
32
|
+
[tool.setuptools.packages.find]
|
|
33
|
+
where = ["src"]
|
|
34
|
+
include = [
|
|
35
|
+
"tachy_compiler",
|
|
36
|
+
"tachy_compiler.*",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.scripts]
|
|
40
|
+
tachy = "tachy_compiler.cli:main"
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: TACHY-Compiler
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: TACHY model compiler and platform conversion tools.
|
|
5
|
+
Author: Deeper-I
|
|
6
|
+
License: BSD-3-Clause
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: numpy
|
|
10
|
+
Requires-Dist: networkx
|
|
11
|
+
Requires-Dist: onnx
|
|
12
|
+
Requires-Dist: commentjson
|
|
13
|
+
Requires-Dist: ordered-set
|
|
14
|
+
Requires-Dist: easydict
|
|
15
|
+
Requires-Dist: DDesignerAPI
|
|
16
|
+
Provides-Extra: yolov9
|
|
17
|
+
Requires-Dist: torch; extra == "yolov9"
|
|
18
|
+
|
|
19
|
+
# TACHY-Compiler
|
|
20
|
+
|
|
21
|
+
TACHY-Compiler is a comprehensive deep learning compiler and platform conversion framework developed by Deeper-I. It is designed to bridge the gap between popular deep learning frameworks (like PyTorch) and the TACHY hardware accelerator runtime environment.
|
|
22
|
+
|
|
23
|
+
This compiler handles model parsing, optimization, tensor alignment, and binary generation. It robustly supports large-scale models, complex operators, and dual-checkpoint pipelines out of the box.
|
|
24
|
+
|
|
25
|
+
## Key Features
|
|
26
|
+
|
|
27
|
+
- **PyTorch to ONNX to TACHY**: Seamless end-to-end compilation pipeline.
|
|
28
|
+
- **Dual Checkpoint Compilation (`compile-dual`)**: Officially supports simultaneous parsing and compilation of Reference (`eval` / `pre`) and Target (`comp` / `opt`) checkpoints into a unified output structure.
|
|
29
|
+
- **Large Model Support**: Built-in mechanisms to handle models larger than the Protobuf 2GB limit using `external_data` mapping.
|
|
30
|
+
- **Robust ONNX Versioning**: Automatically utilizes ONNX Opset 18 for stability, equipped with automatic version conversion and fallback mechanisms to mitigate `onnxscript` conversion issues.
|
|
31
|
+
- **MCP Server Integrated**: Exposes tools to LLMs and agentic frameworks via the Model Context Protocol (MCP) using `FastMCP`.
|
|
32
|
+
- **Dynamic Binary Resolution**: Intelligently locates dependency binaries utilizing environment variables (`TACHY_UTIL_PATH`) and relative package paths.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
You can install TACHY-Compiler directly via PyPI:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install TACHY-Compiler
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Requirements
|
|
43
|
+
- Python >= 3.8
|
|
44
|
+
- `numpy`, `networkx`, `onnx`, `commentjson`, `ordered-set`, `easydict`, `DDesignerAPI`
|
|
45
|
+
- (Optional) `torch` if utilizing the PyTorch to ONNX conversion pipeline.
|
|
46
|
+
|
|
47
|
+
## CLI Usage
|
|
48
|
+
|
|
49
|
+
TACHY-Compiler provides a simple, unified command-line interface under the `tachy` command.
|
|
50
|
+
|
|
51
|
+
### 1. Dual Checkpoint Compilation
|
|
52
|
+
Best for executing the full compilation pipeline for two checkpoints (e.g. `eval` and `comp`) simultaneously. Intermediate files are automatically managed and cleaned up if requested.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
tachy compile-dual \
|
|
56
|
+
--eval_model ./eval_model.pth \
|
|
57
|
+
--comp_model ./comp_model.pth \
|
|
58
|
+
--input_shape "[1,3,224,224]" \
|
|
59
|
+
--output_dir ./dual_output \
|
|
60
|
+
--cleanup
|
|
61
|
+
```
|
|
62
|
+
Outputs will be cleanly structured into `./dual_output/final_binaries/eval/` and `./dual_output/final_binaries/comp/`.
|
|
63
|
+
|
|
64
|
+
### 2. Single Model Pipeline Steps
|
|
65
|
+
If you need granular control, you can execute the pipeline steps individually.
|
|
66
|
+
|
|
67
|
+
**Convert PyTorch to ONNX**
|
|
68
|
+
```bash
|
|
69
|
+
tachy convert-pt2onnx ./model.pth ./model.onnx "[1,3,224,224]" False
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Convert ONNX to TACHY Format**
|
|
73
|
+
```bash
|
|
74
|
+
tachy convert-onnx ./model.onnx ./model.json
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Compile TACHY JSON to Runtime Binaries**
|
|
78
|
+
```bash
|
|
79
|
+
tachy compile ./model.json ./output_bin_dir
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 3. Model Context Protocol (MCP) Server
|
|
83
|
+
You can spin up the built-in MCP server to allow LLMs and AI Agents to compile models on your behalf.
|
|
84
|
+
```bash
|
|
85
|
+
tachy mcp
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Environment Variables
|
|
89
|
+
- `TACHY_UTIL_PATH` (Optional): An absolute path to the directory containing external utility binaries (`fc.out`, `block_4bit.out`). If not set, the compiler will intelligently look for the `optional` directory within the installed package.
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
This project is licensed under the BSD-3-Clause License. See the LICENSE file for details.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/TACHY_Compiler.egg-info/PKG-INFO
|
|
4
|
+
src/TACHY_Compiler.egg-info/SOURCES.txt
|
|
5
|
+
src/TACHY_Compiler.egg-info/dependency_links.txt
|
|
6
|
+
src/TACHY_Compiler.egg-info/entry_points.txt
|
|
7
|
+
src/TACHY_Compiler.egg-info/requires.txt
|
|
8
|
+
src/TACHY_Compiler.egg-info/top_level.txt
|
|
9
|
+
src/tachy_compiler/__init__.py
|
|
10
|
+
src/tachy_compiler/cli.py
|
|
11
|
+
src/tachy_compiler/mcp_server.py
|
|
12
|
+
src/tachy_compiler/compiler/__init__.py
|
|
13
|
+
src/tachy_compiler/compiler/constraint.py
|
|
14
|
+
src/tachy_compiler/compiler/convert_layer2block.py
|
|
15
|
+
src/tachy_compiler/compiler/convert_tachy2tachyrt.py
|
|
16
|
+
src/tachy_compiler/compiler/editor.py
|
|
17
|
+
src/tachy_compiler/compiler/extract.py
|
|
18
|
+
src/tachy_compiler/compiler/format_prototxt.py
|
|
19
|
+
src/tachy_compiler/compiler/functions.py
|
|
20
|
+
src/tachy_compiler/compiler/graph.py
|
|
21
|
+
src/tachy_compiler/compiler/map_address.py
|
|
22
|
+
src/tachy_compiler/compiler/onnx2tachy.py
|
|
23
|
+
src/tachy_compiler/compiler/pipeline.py
|
|
24
|
+
src/tachy_compiler/compiler/runtime.py
|
|
25
|
+
src/tachy_compiler/compiler/tachy_block.py
|
|
26
|
+
src/tachy_compiler/compiler/tachy_format.py
|
|
27
|
+
src/tachy_compiler/compiler/tachy_inference.py
|
|
28
|
+
src/tachy_compiler/compiler/tachy_layers.py
|
|
29
|
+
src/tachy_compiler/compiler/tachy_model.py
|
|
30
|
+
src/tachy_compiler/compiler/tachy_prototxt.py
|
|
31
|
+
src/tachy_compiler/compiler/tachy_viewer.py
|
|
32
|
+
src/tachy_compiler/compiler/tachyrt_model.py
|
|
33
|
+
src/tachy_compiler/compiler/verify.py
|
|
34
|
+
src/tachy_compiler/platform_converter/__init__.py
|
|
35
|
+
src/tachy_compiler/platform_converter/deploy_pt_yolov9.py
|
|
36
|
+
src/tachy_compiler/platform_converter/pt2onnx.py
|
|
37
|
+
src/tachy_compiler/platform_converter/yolov9_utils/__init__.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tachy_compiler
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import subprocess
|
|
3
|
+
|
|
4
|
+
def main():
|
|
5
|
+
if len(sys.argv) < 2 or sys.argv[1] in ("-h", "--help"):
|
|
6
|
+
print("TACHY-Compiler CLI")
|
|
7
|
+
print("Usage: tachy <command> [args...]")
|
|
8
|
+
print("\nAvailable commands:")
|
|
9
|
+
print(" convert-pt2onnx Convert PyTorch model to ONNX")
|
|
10
|
+
print(" convert-onnx Convert ONNX model to TACHY format")
|
|
11
|
+
print(" compile Compile TACHY model to runtime binaries")
|
|
12
|
+
print(" compile-dual Compile dual models (eval & comp) in one pipeline")
|
|
13
|
+
print(" mcp Start the MCP server")
|
|
14
|
+
sys.exit(0)
|
|
15
|
+
|
|
16
|
+
command = sys.argv[1]
|
|
17
|
+
forward_args = sys.argv[2:]
|
|
18
|
+
|
|
19
|
+
if command == "convert-pt2onnx":
|
|
20
|
+
module = "tachy_compiler.platform_converter.pt2onnx"
|
|
21
|
+
elif command == "convert-onnx":
|
|
22
|
+
module = "tachy_compiler.compiler.onnx2tachy"
|
|
23
|
+
elif command == "compile":
|
|
24
|
+
module = "tachy_compiler.compiler.runtime"
|
|
25
|
+
elif command == "compile-dual":
|
|
26
|
+
module = "tachy_compiler.compiler.pipeline"
|
|
27
|
+
elif command == "mcp":
|
|
28
|
+
module = "tachy_compiler.mcp_server"
|
|
29
|
+
else:
|
|
30
|
+
print(f"Unknown command: {command}")
|
|
31
|
+
sys.exit(1)
|
|
32
|
+
|
|
33
|
+
cmd = [sys.executable, "-m", module] + forward_args
|
|
34
|
+
try:
|
|
35
|
+
result = subprocess.run(cmd)
|
|
36
|
+
sys.exit(result.returncode)
|
|
37
|
+
except KeyboardInterrupt:
|
|
38
|
+
sys.exit(1)
|
|
39
|
+
|
|
40
|
+
if __name__ == "__main__":
|
|
41
|
+
main()
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
def align_odd_width(block_config):
|
|
4
|
+
_, in_w, _ = block_config["input_shape"]
|
|
5
|
+
ker_h, ker_w, _, _ = block_config["kernel_shape"]
|
|
6
|
+
str_h, str_w = block_config["stride_shape"]
|
|
7
|
+
p_t, p_l, p_b, p_r, _ = block_config["padding_shape"]
|
|
8
|
+
|
|
9
|
+
is_odd = (in_w % 2 == 1)
|
|
10
|
+
is_ker_1x1 = (ker_h == 1 and ker_w == 1)
|
|
11
|
+
is_str_2x2 = (str_h == 2 and str_w == 2)
|
|
12
|
+
is_no_pad = ((p_t == 0) and (p_l == 0) and (p_b == 0) and (p_r == 0))
|
|
13
|
+
|
|
14
|
+
if is_odd and is_ker_1x1 and is_str_2x2 and is_no_pad:
|
|
15
|
+
block_config["padding_shape"][2] += 1 # add bottom padding
|
|
16
|
+
block_config["padding_shape"][3] += 1 # add right padding
|
|
17
|
+
|
|
18
|
+
return block_config
|
|
19
|
+
|
|
20
|
+
def add_dummy_padding(block_config):
|
|
21
|
+
in_h, in_w, _ = block_config["input_shape"]
|
|
22
|
+
out_h, out_w, _ = block_config["output_shape"]
|
|
23
|
+
ker_h, ker_w, _, __ = block_config["kernel_shape"]
|
|
24
|
+
str_h, str_w = block_config["stride_shape"]
|
|
25
|
+
p_t, p_l, p_b, p_r, p_s = block_config["padding_shape"]
|
|
26
|
+
|
|
27
|
+
op = block_config["operation"]
|
|
28
|
+
if op == "Conv":
|
|
29
|
+
if out_w < 7:
|
|
30
|
+
for i in range(8):
|
|
31
|
+
if (1 + (in_w - 1 + p_l + p_r + i - (ker_w - 1)) / str_w >= 7):
|
|
32
|
+
p_s = i
|
|
33
|
+
break
|
|
34
|
+
p_r += p_s
|
|
35
|
+
else:
|
|
36
|
+
if op == "MaxPool": # Warning: Only for synergy ai
|
|
37
|
+
if ker_w+1 > in_w:
|
|
38
|
+
add_pad = max((ker_w + 1 - in_w), 0)
|
|
39
|
+
p_r += add_pad
|
|
40
|
+
p_s += ((in_w + p_r) - ker_w)
|
|
41
|
+
|
|
42
|
+
block_config["padding_shape"] = [p_t, p_l, p_b, p_r, p_s]
|
|
43
|
+
return block_config
|
|
44
|
+
|
|
45
|
+
# def add_dummy_padding(block_config):
|
|
46
|
+
# in_h, in_w, _ = block_config["input_shape"]
|
|
47
|
+
# ker_h, ker_w, _, __ = block_config["kernel_shape"]
|
|
48
|
+
#
|
|
49
|
+
# p_t, p_l, p_b, p_r, p_s = block_config["padding_shape"]
|
|
50
|
+
#
|
|
51
|
+
# op = block_config["operation"]
|
|
52
|
+
# if op == "Conv":
|
|
53
|
+
# if in_w < 7:
|
|
54
|
+
# add_pad = (7 - in_w)
|
|
55
|
+
# p_r += add_pad
|
|
56
|
+
# p_s += add_pad
|
|
57
|
+
# else:
|
|
58
|
+
# if op == "MaxPool": # Warning: Only for synergy ai
|
|
59
|
+
# if ker_w+1 > in_w:
|
|
60
|
+
# add_pad = max((ker_w + 1 - in_w), 0)
|
|
61
|
+
# p_r += add_pad
|
|
62
|
+
# p_s += ((in_w + p_r) - ker_w)
|
|
63
|
+
#
|
|
64
|
+
# block_config["padding_shape"] = [p_t, p_l, p_b, p_r, p_s]
|
|
65
|
+
# return block_config
|