# unifyai/ivy architecture

> Architecture diagram of the GitHub repository unifyai/ivy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/unifyai/ivy
- Repository: https://github.com/unifyai/ivy

## Overview

Ivy is a framework-portability toolkit: users can transpile framework-specific code, trace callable graphs, and use a common array API backed by multiple frameworks. The documented transpilation workflow accepts a function or module plus source and target frameworks, then returns converted code; module conversion can initialize lazily on first use. The graph also shows the separate tracing and unified-array branches. Relationships involving unsampled implementations are included only where the README or source index supports them; the excerpts do not expose the full transpiler or tracing call flow.

Main entry points: [`ivy/__init__.py`](https://github.com/unifyai/ivy/blob/main/ivy/__init__.py) (Ivy API), [`ivy/transpiler/main.py`](https://github.com/unifyai/ivy/blob/main/ivy/transpiler/main.py) (Transpile entry), [`ivy/utils/backend/handler.py`](https://github.com/unifyai/ivy/blob/main/ivy/utils/backend/handler.py) (Backend selection), [`ivy/tracer/wrapping.py`](https://github.com/unifyai/ivy/blob/main/ivy/tracer/wrapping.py) (Trace entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversion["Code conversion"]
  node_transpile["Transpile entry<br/>[main.py]"]
  node_sourcegen["Source generation<br/>[source_gen.py]"]
  node_objectlike["Object model<br/>[object_like.py]"]
end

subgraph group_tracing["Graph tracing"]
  node_traceapi["Trace entry<br/>[wrapping.py]"]
  node_graph["Traced graph<br/>[graph.py]"]
  node_traceconversion["Trace conversion<br/>[conversion.py]"]
end

subgraph group_api["Unified array API"]
  node_ivyapi["Ivy API<br/>[__init__.py]"]
  node_funcwrapper["Function wrappers<br/>[func_wrapper.py]"]
  node_array["Array operations<br/>[conversions.py]"]
  node_container["Container operations<br/>[base.py]"]
end

subgraph group_frameworks["Framework support"]
  node_backendhandler["Backend selection<br/>[handler.py]"]
  node_subbackend["Sub-backends"]
  node_backendimpl["Backend operations"]
  node_frontend["Framework frontends"]
end

subgraph group_stateful["Stateful modeling"]
  node_stateful["Stateful layers<br/>[layers.py]"]
  node_module["Module abstraction<br/>[module.py]"]
end

node_user(("ML developer"))
node_target(("Target framework"))
node_result["Converted code"]
node_caller(("Callable"))
node_graphresult["Executable graph"]

node_user -->|"requests conversion"| node_transpile
node_transpile -->|"selects target"| node_target
node_transpile -->|"returns converted code"| node_result
node_transpile -.->|"emits source"| node_sourcegen
node_sourcegen -->|"uses object model"| node_objectlike
node_user -->|"requests trace"| node_traceapi
node_traceapi -->|"constructs graph"| node_graph
node_graph -->|"uses conversions"| node_traceconversion
node_traceapi -->|"returns graph"| node_graphresult
node_user -.->|"uses common API"| node_ivyapi
node_ivyapi -->|"exposes operations"| node_array
node_ivyapi -->|"exposes containers"| node_container
node_ivyapi -->|"selects backend"| node_backendhandler
node_backendhandler -->|"loads backend"| node_backendimpl
node_backendhandler -->|"manages sub-backends"| node_subbackend
node_subbackend -->|"loads extensions"| node_backendimpl
node_funcwrapper -->|"uses backend state"| node_backendhandler
node_frontend -.->|"calls Ivy operations"| node_ivyapi
node_stateful -->|"builds on modules"| node_module

click node_transpile "https://github.com/unifyai/ivy/blob/main/ivy/transpiler/main.py"
click node_sourcegen "https://github.com/unifyai/ivy/blob/main/ivy/transpiler/ast/source_gen.py"
click node_objectlike "https://github.com/unifyai/ivy/blob/main/ivy/transpiler/core/object_like.py"
click node_traceapi "https://github.com/unifyai/ivy/blob/main/ivy/tracer/wrapping.py"
click node_graph "https://github.com/unifyai/ivy/blob/main/ivy/tracer/graph.py"
click node_traceconversion "https://github.com/unifyai/ivy/blob/main/ivy/tracer/conversion.py"
click node_ivyapi "https://github.com/unifyai/ivy/blob/main/ivy/__init__.py"
click node_funcwrapper "https://github.com/unifyai/ivy/blob/main/ivy/func_wrapper.py"
click node_array "https://github.com/unifyai/ivy/blob/main/ivy/data_classes/array/conversions.py"
click node_container "https://github.com/unifyai/ivy/blob/main/ivy/data_classes/container/base.py"
click node_backendhandler "https://github.com/unifyai/ivy/blob/main/ivy/utils/backend/handler.py"
click node_subbackend "https://github.com/unifyai/ivy/blob/main/ivy/utils/backend/sub_backend_handler.py"
click node_backendimpl "https://github.com/unifyai/ivy/tree/main/ivy/functional/backends"
click node_frontend "https://github.com/unifyai/ivy/tree/main/ivy/functional/frontends"
click node_stateful "https://github.com/unifyai/ivy/blob/main/ivy/stateful/layers.py"
click node_module "https://github.com/unifyai/ivy/blob/main/ivy/module/module.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_transpile,node_sourcegen,node_objectlike toneBlue
class node_traceapi,node_graph,node_traceconversion toneAmber
class node_ivyapi,node_funcwrapper,node_array,node_container toneMint
class node_backendhandler,node_subbackend,node_backendimpl,node_frontend toneRose
class node_stateful,node_module,node_user,node_target,node_result,node_caller,node_graphresult toneIndigo
```

## Components

### Code conversion

- [Transpile entry](https://github.com/unifyai/ivy/blob/main/ivy/transpiler/main.py): `ivy/transpiler/main.py`
- [Source generation](https://github.com/unifyai/ivy/blob/main/ivy/transpiler/ast/source_gen.py): `ivy/transpiler/ast/source_gen.py`
- [Object model](https://github.com/unifyai/ivy/blob/main/ivy/transpiler/core/object_like.py): `ivy/transpiler/core/object_like.py`

### Graph tracing

- [Trace entry](https://github.com/unifyai/ivy/blob/main/ivy/tracer/wrapping.py): `ivy/tracer/wrapping.py`
- [Traced graph](https://github.com/unifyai/ivy/blob/main/ivy/tracer/graph.py): `ivy/tracer/graph.py`
- [Trace conversion](https://github.com/unifyai/ivy/blob/main/ivy/tracer/conversion.py): `ivy/tracer/conversion.py`

### Unified array API

- [Ivy API](https://github.com/unifyai/ivy/blob/main/ivy/__init__.py): `ivy/__init__.py`
- [Function wrappers](https://github.com/unifyai/ivy/blob/main/ivy/func_wrapper.py): `ivy/func_wrapper.py`
- [Array operations](https://github.com/unifyai/ivy/blob/main/ivy/data_classes/array/conversions.py): `ivy/data_classes/array/conversions.py`
- [Container operations](https://github.com/unifyai/ivy/blob/main/ivy/data_classes/container/base.py): `ivy/data_classes/container/base.py`

### Framework support

- [Backend selection](https://github.com/unifyai/ivy/blob/main/ivy/utils/backend/handler.py): `ivy/utils/backend/handler.py`
- [Sub-backends](https://github.com/unifyai/ivy/blob/main/ivy/utils/backend/sub_backend_handler.py): `ivy/utils/backend/sub_backend_handler.py`
- [Backend operations](https://github.com/unifyai/ivy/tree/main/ivy/functional/backends): `ivy/functional/backends`
- [Framework frontends](https://github.com/unifyai/ivy/tree/main/ivy/functional/frontends): `ivy/functional/frontends`

### Stateful modeling

- [Stateful layers](https://github.com/unifyai/ivy/blob/main/ivy/stateful/layers.py): `ivy/stateful/layers.py`
- [Module abstraction](https://github.com/unifyai/ivy/blob/main/ivy/module/module.py): `ivy/module/module.py`

### Other components

- **ML developer**
- **Target framework**
- **Converted code**
- **Callable**
- **Executable graph**

## Connections

- ML developer → Transpile entry: requests conversion (evidence: `README.md`)
- Transpile entry → Target framework: selects target (evidence: `README.md`)
- Transpile entry → Converted code: returns converted code (evidence: `README.md`)
- Transpile entry → Source generation: emits source
- Source generation → Object model: uses object model (evidence: `ivy/transpiler/ast/source_gen.py`)
- ML developer → Trace entry: requests trace (evidence: `README.md`)
- Trace entry → Traced graph: constructs graph (evidence: `ivy/tracer/wrapping.py`)
- Traced graph → Trace conversion: uses conversions (evidence: `ivy/tracer/graph.py`)
- Trace entry → Executable graph: returns graph (evidence: `README.md`)
- ML developer → Ivy API: uses common API
- Ivy API → Array operations: exposes operations (evidence: `ivy/__init__.py`)
- Ivy API → Container operations: exposes containers (evidence: `ivy/__init__.py`)
- Ivy API → Backend selection: selects backend (evidence: `ivy/__init__.py`)
- Backend selection → Backend operations: loads backend (evidence: `ivy/utils/backend/handler.py`)
- Backend selection → Sub-backends: manages sub-backends (evidence: `ivy/utils/backend/handler.py`)
- Sub-backends → Backend operations: loads extensions (evidence: `ivy/utils/backend/sub_backend_handler.py`)
- Function wrappers → Backend selection: uses backend state (evidence: `ivy/func_wrapper.py`)
- Framework frontends → Ivy API: calls Ivy operations (evidence: `ivy/functional/frontends/numpy/statistics/averages_and_variances.py`)
- Stateful layers → Module abstraction: builds on modules (evidence: `ivy/stateful/layers.py`)
