# eml-eda/match architecture

> Architecture diagram of the GitHub repository eml-eda/match, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eml-eda/match
- Repository: https://github.com/eml-eda/match

## Overview

##### Project Type & Purpose
- MATCH is a compiler tool (not a web app or microservice).

##### Architectural Patterns & Design Principles
- Plugin architecture for new targets (inherit MatchTarget & ExecModule)
- Separation of concerns: parsing, partitioning, scheduling, codegen, runtime
- Modular cost-model interface to plug in new performance/energy models
- Use of template-based codegen to decouple C API definitions from core compiler

##### Technologies & Frameworks
– Python 3.8+ for compiler logic
– Apache TVM for host code generation fallback
– ZigZag temporal mapper (external submodule)
– ONNX & Relay IR for model representation
– C/C++17 for generated code and runtime libs
– Docker for environment reproducibility

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-level pipeline
    UI["User Interface / Entry Point"]:::frontend
    UI -->|"invokes"| FE["Front-End"]:::frontend
    FE -->|"parses model"| IR["IR & Data Model"]:::data
    IR -->|"provides MatchModel"| PART["Partitioning Engine"]:::engine
    PART -->|"splits into subgraphs"| OPT["Optimization & Scheduling"]:::optimization
    OPT -->|"generates schedules"| CG["Code Generation"]:::codegen
    CG -->|"emits C sources"| BUILD["Build & Packaging"]:::build
    BUILD -->|"compiles & links"| RUNTIME["Runtime & Graph Execution"]:::runtime
    RUNTIME -->|"runs graph"| UI

    %% Extension & Plugins
    TARGET["Target Abstraction Layer"]:::target
    TARGET -->|"uses"| PART
    TARGET -->|"interfaces with"| OPT
    TARGET -->|"provides APIs to"| CG

    %% Side modules
    TEST["Examples & Tests"]:::test
    UI -.-> TEST
    CG -.-> TEST
    BUILD -.-> TEST

    %% Click events
    click UI "https://github.com/eml-eda/match/blob/master/run.py"
    click UI "https://github.com/eml-eda/match/blob/master/match/run.py"
    click UI "https://github.com/eml-eda/match/blob/master/test/test.py"
    click FE "https://github.com/eml-eda/match/blob/master/match/parser/tvm_parser.py"
    click FE "https://github.com/eml-eda/match/blob/master/match/parser/relay.py"
    click FE "https://github.com/eml-eda/match/blob/master/match/parser/workload.py"
    click IR "https://github.com/eml-eda/match/blob/master/match/model/model.py"
    click IR "https://github.com/eml-eda/match/blob/master/match/model/dynamic_dim.py"
    click PART "https://github.com/eml-eda/match/blob/master/match/partition/partition.py"
    click PART "https://github.com/eml-eda/match/blob/master/match/partition/partitioning_pattern.py"
    click OPT "https://github.com/eml-eda/match/blob/master/match/opt/basic.py"
    click OPT "https://github.com/eml-eda/match/blob/master/match/opt/basic_plus.py"
    click OPT "https://github.com/eml-eda/match/blob/master/match/opt/engine.py"
    click OPT "https://github.com/eml-eda/match/blob/master/match/opt/generator.py"
    click OPT "https://github.com/eml-eda/match/blob/master/match/opt/passes/fuse_blocks.py"
    click OPT "https://github.com/eml-eda/match/blob/master/match/opt/passes/remove_loops.py"
    click OPT "https://github.com/eml-eda/match/blob/master/match/opt/passes/schedule_pass.py"
    click OPT "https://github.com/eml-eda/match/blob/master/match/opt/zigzag/zigzag.py"
    click OPT "https://github.com/eml-eda/match/blob/master/match/opt/zigzag/parser.py"
    click OPT "https://github.com/eml-eda/match/blob/master/match/opt/zigzag/transform.py"
    click OPT "https://github.com/eml-eda/match/blob/master/match/opt/zigzag/architecture.py"
    click OPT "https://github.com/eml-eda/match/blob/master/match/cost_model/zigzag.py"
    click CG "https://github.com/eml-eda/match/blob/master/match/codegen/codegen.py"
    click CG "https://github.com/eml-eda/match/blob/master/match/codegen/template_writer.py"
    click CG "https://github.com/eml-eda/match/blob/master/docs/dev/apis.md"
    click TARGET "https://github.com/eml-eda/match/blob/master/match/target/target.py"
    click TARGET "https://github.com/eml-eda/match/blob/master/match/target/exec_module.py"
    click TARGET "https://github.com/eml-eda/match/blob/master/match/target/get_target.py"
    click TARGET "https://github.com/eml-eda/match/blob/master/match/target/memory_inst.py"
    click TARGET "https://github.com/eml-eda/match/tree/master/match/target/examples/diana"
    click TARGET "https://github.com/eml-eda/match/tree/master/match/target/examples/gap9"
    click RUNTIME "https://github.com/eml-eda/match/blob/master/match/runtime/graph/graph.py"
    click RUNTIME "https://github.com/eml-eda/match/blob/master/match/runtime/graph/alloc.py"
    click RUNTIME "https://github.com/eml-eda/match/blob/master/match/runtime/graph/memplan.py"
    click RUNTIME "https://github.com/eml-eda/match/blob/master/match/runtime/graph/tensor.py"
    click RUNTIME "https://github.com/eml-eda/match/blob/master/match/runtime/graph/utils.py"
    click RUNTIME "https://github.com/eml-eda/match/tree/master/match/libs/c/static"
    click RUNTIME "https://github.com/eml-eda/match/tree/master/match/libs/c/mako"
    click BUILD "https://github.com/eml-eda/match/blob/master/setup.py"
    click BUILD "https://github.com/eml-eda/match/blob/master/requirements.txt"
    click BUILD "https://github.com/eml-eda/match/tree/master/Makefile"
    click BUILD "https://github.com/eml-eda/match/tree/master/docker/Dockerfile"
    click BUILD "https://github.com/eml-eda/match/tree/master/docker/pulp_open/Dockerfile"
    click BUILD "https://github.com/eml-eda/match/tree/master/.github/workflows/"
    click TEST "https://github.com/eml-eda/match/tree/master/examples/"
    click TEST "https://github.com/eml-eda/match/tree/master/test/"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#1E90FF
    classDef data fill:#FDE9A9,stroke:#DAA520,shape:cylinder
    classDef engine fill:#FFD1DC,stroke:#FF69B4
    classDef optimization fill:#E2F0CB,stroke:#7CB342
    classDef codegen fill:#D1C4E9,stroke:#673AB7
    classDef build fill:#FFECB3,stroke:#FF9800
    classDef runtime fill:#C8E6C9,stroke:#388E3C
    classDef target fill:#B3E5FC,stroke:#0288D1
    classDef test fill:#FFE0B2,stroke:#F57C00
    class UI,FE,IR,PART,OPT,CG,BUILD,RUNTIME,TARGET,TEST frontend,data,engine,optimization,codegen,build,runtime,target,test
```
