ivy enables you to convert ML models, tools and libraries between frameworks using ivy.transpile
The easiest way to install ivy is using pip:
pip install ivyFrom 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 .These are the frameworks that ivy.transpile currently supports conversions from and to.
| Framework | Source | Target |
|---|---|---|
| PyTorch | ✓ | planned |
| TensorFlow | planned | ✓ |
| JAX | planned | ✓ |
| NumPy | planned | ✓ |
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()
