djl11/ivy

Public

Convert Machine Learning Code Between Frameworks

  • Stars14.2k
  • Forks5.4k
  • Watchers63
  • Issues945
  • Ngày tạo19/01/2021
  • Cập nhật gần nhất10/11/2026
  • Ngôn ngữPython
  • Giấy phép—
README.md13.9 KBRaw

ivy, a unify project. Convert machine learning code between frameworks.

Docs · Discord · License

Convert Machine Learning Code Between Frameworks

ivy enables you to convert ML models, tools and libraries between frameworks using ivy.transpile

ONNX, PyTorch, NumPy, TensorFlow, JAX and MXNet, frameworks ivy works with


Installation

The easiest way to install ivy is using pip:

pip install ivy
From Source

You can also install ivy from source if you want to take advantage of the latest changes:

git clone https://github.com/ivy-llc/ivy.git
cd ivy
pip install --user -e .

Supported Frameworks

These are the frameworks that ivy.transpile currently supports conversions from and to.

Framework Source Target
PyTorch ✓ planned
TensorFlow planned ✓
JAX planned ✓
NumPy planned ✓

Using ivy

Here's some examples, to help you get started using ivy! The examples page also features a wide range of demos and tutorials showcasing some more use cases for ivy.

Transpiling any code from one framework to another
import ivy
import torch
import tensorflow as tf

def torch_fn(x):
    a = torch.mul(x, x)
    b = torch.mean(x)
    return x * a + b

tf_fn = ivy.transpile(torch_fn, source="torch", target="tensorflow")

tf_x = tf.convert_to_tensor([1., 2., 3.])
ret = tf_fn(tf_x)
Tracing a computational graph of any code
import ivy
import torch

def torch_fn(x):
    a = torch.mul(x, x)
    b = torch.mean(x)
    return x * a + b

torch_x = torch.tensor([1., 2., 3.])
graph = ivy.trace_graph(jax_fn, to="torch", args=(torch_x,))
ret = graph(torch_x)
How does ivy work?

ivy's transpiler allows you to use code from any other framework in your own code. Feel free to head over to the docs for the full API reference, but the functions you'd most likely want to use are:

# Converts framework-specific code to a target framework of choice. See usage in the documentation
ivy.transpile()

# Traces an efficient fully-functional graph from a function, removing all wrapping and redundant code. See usage in the documentation
ivy.trace_graph()

ivy.transpile will eagerly transpile if a class or function is provided

Nội dung README thuộc về djl11 và cộng đồng đóng góp, giấy phép Không có giấy phép. Nguồn: github.com/djl11/ivy