How unifyai/ivy works
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: __init__.py Ivy API · main.py Transpile entry · handler.py Backend selection · wrapping.py Trace entry
Components 21
Code conversion
- Transpile entry
ivy/transpiler/main.py - Source generation
ivy/transpiler/ast/source_gen.py - Object model
ivy/transpiler/core/object_like.py
Graph tracing
- Trace entry
ivy/tracer/wrapping.py - Traced graph
ivy/tracer/graph.py - Trace conversion
ivy/tracer/conversion.py
Unified array API
- Ivy API
ivy/__init__.py - Function wrappers
ivy/func_wrapper.py - Array operations
ivy/data_classes/array/conversions.py - Container operations
ivy/data_classes/container/base.py
Framework support
- Backend selection
ivy/utils/backend/handler.py - Sub-backends
ivy/utils/backend/sub_backend_handler.py - Backend operations
ivy/functional/backends - Framework frontends
ivy/functional/frontends
Stateful modeling
- Stateful layers
ivy/stateful/layers.py - Module abstraction
ivy/module/module.py
Other components
- ML developer
- Target framework
- Converted code
- Callable
- Executable graph
Connections 19
- ML developer → Transpile entry: requests conversion
README.md - Transpile entry → Target framework: selects target
README.md - Transpile entry → Converted code: returns converted code
README.md - Transpile entry → Source generation: emits source
- Source generation → Object model: uses object model
ivy/transpiler/ast/source_gen.py - ML developer → Trace entry: requests trace
README.md - Trace entry → Traced graph: constructs graph
ivy/tracer/wrapping.py - Traced graph → Trace conversion: uses conversions
ivy/tracer/graph.py - Trace entry → Executable graph: returns graph
README.md - ML developer → Ivy API: uses common API
- Ivy API → Array operations: exposes operations
ivy/__init__.py - Ivy API → Container operations: exposes containers
ivy/__init__.py - Ivy API → Backend selection: selects backend
ivy/__init__.py - Backend selection → Backend operations: loads backend
ivy/utils/backend/handler.py - Backend selection → Sub-backends: manages sub-backends
ivy/utils/backend/handler.py - Sub-backends → Backend operations: loads extensions
ivy/utils/backend/sub_backend_handler.py - Function wrappers → Backend selection: uses backend state
ivy/func_wrapper.py - Framework frontends → Ivy API: calls Ivy operations
ivy/functional/frontends/numpy/statistics/averages_and_variances.py - Stateful layers → Module abstraction: builds on modules
ivy/stateful/layers.py