CIMFlow LogoCIMFlow

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 \
  --visualize
cimflow compile cg \
  -m model.onnx \
  -o output/cg \
  -t 8 -k 16 -b 16 -c 64 \
  --batch-size 8 \
  --strategy dp

Visualization

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.

ParameterCLI OptionRequiredDescription
model-path-m, --model-pathYesInput ONNX model path
T-TNoMacro group size
K-KNoNumber of macro groups
B-BNoNoC flit size (bandwidth parameter)
C-CNoTotal core count
strategy--strategyNoPartition strategy: dp, baseline1, baseline2
batch-size--batch-sizeNoBatch scheduling granularity for instruction generation


Output Format

CG output file naming:

instructions_<model>_<strategy>_T<T>_K<K>_B<B>_C<C>_batch<N>.json

Example 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