CG-Level
Graph partitioning and stage-level instruction generation
CG-level compilation converts an ONNX graph into a staged multi-core task graph. The output is a JSON instruction plan organized by core grid position, with keys like core_0_0, core_0_1.
CG-Level Processing Steps
ONNX Preprocessing
Parse the ONNX model and perform shape inference
Dependency Analysis
Build a dependency graph centered on convolution operators
Stage Partitioning
Partition computation stages across the available cores
Communication Planning
Generate communication operations (read, write, send, receive, wait_write)
Model Simplification
Simplify the ONNX graph before partitioning; oversized convolutions may be split
Metadata Generation
Compute operation counts for throughput metrics
Commands
cim-compiler cg-level \
-m model.onnx \
-o output/cg \
-T 8 -K 16 -B 16 -C 64 \
--batch-size 8 \
--strategy dp \
--visualizecimflow compile cg \
-m model.onnx \
-o output/cg \
-t 8 -k 16 -b 16 -c 64 \
--batch-size 8 \
--strategy dpVisualization
Add --visualize (native) to emit graph and core-allocation plots for inspecting partition results.
Parameters
These parameters define the hardware target and compilation strategy. T and K control the CIM macro array dimensions within each core, B sets the NoC flit size (affecting data transfer granularity), and C determines the core grid size (must be a perfect square). See Configuration and Constraints for validation rules and config format details.
| Parameter | CLI Option | Required | Description |
|---|---|---|---|
model-path | -m, --model-path | Yes | Input ONNX model path |
T | -T | No | Macro group size |
K | -K | No | Number of macro groups |
B | -B | No | NoC flit size (bandwidth parameter) |
C | -C | No | Total core count |
strategy | --strategy | No | Partition strategy: dp, baseline1, baseline2 |
batch-size | --batch-size | No | Batch scheduling granularity for instruction generation |
Output Format
CG output file naming:
instructions_<model>_<strategy>_T<T>_K<K>_B<B>_C<C>_batch<N>.jsonExample structure:
{
"metadata": {
"op_count": 1110836224
},
"core_0_0": {
"stages": {
"0": {
"cluster_id": "Conv_0",
"weight_replica_id": 0,
"instructions": [
{"op": "read", "attr": {"tensor_type": "weight", "shape": [64,3,3,3]}},
{"op": "read", "attr": {"tensor_type": "feature", "shape": [1,3,32,32]}},
{"op": "conv", "attr": {"X_shape": [1,3,32,32], "W_shape": [64,3,3,3]}},
{"op": "write", "attr": {"tensor_type": "feature", "shape": [1,64,32,32], "write_id": "node_0_batch_0"}}
]
}
}
}
}Last updated on