You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
The current implementation of ivy.transpile supports "jax","numpy" and "tensorflow" as valid target argument. This allows transpiling framework-specific code such as PyTorch functions or classes to target frameworks like TensorFlow, JAX, or NumPy. This task aims to extend the functionality by adding Pytorch as a valid target, enabling code to be transpiled to Pytorch.
For example, after completing this task, we should be able to transpile TensorFlow code using:
The main objective is to implement the final stage of the transpilation pipeline:
Lower Ivy IR representation to native Pytorch code.
Once this stage is complete, the rest of the pipeline can be reused to target other frameworks like JAX, PyTorch, or NumPy. The steps would look as follows:
Add Native Framework-Specific Implementations for Core Transformation Passes:
For example, implement the ivy_to_torch_postprocessing_transformer.py for doing postprocessing on the Ivy code when lowering it to Pytorch (eg: mapping ivy dtypes (eg: ivy.float32) to torch dtypes(torch.float32)
Use ivy_to_jax_postprocessing_transformer.py as a reference (example here)
2 Define the Transformation Pipeline for Ivy IR to Torch
Create a new pipeline in ivy_to_source_translator_config.py to handle the stage source='ivy', target='torch' (example here).
Add Stateful Classes for torch.nn APIs:
Add a subclass implementation for torch.nn.Module that exposes the similar interface as that of ivy.Module.
Reference the existing implementation for keras.Model or nnx.Module(example 1) (example 2)
Explore reusable components in the existing PyTorch pipeline, especially for AST transformers and configuration management.
Testing:
Familiarize yourself with the transpilation flow by exploring transpiler tests
Add appropriate tests to validate Pytorch target transpilation at the final stage of the pipeline.
Additional Notes:
Keep in mind the modular and extensible design of the transpiler, ensuring that the new implementation integrates smoothly into the existing architecture.
The text was updated successfully, but these errors were encountered:
Description:
The current implementation of
ivy.transpile
supports"jax"
,"numpy"
and"tensorflow"
as validtarget
argument. This allows transpiling framework-specific code such as PyTorch functions or classes to target frameworks like TensorFlow, JAX, or NumPy. This task aims to extend the functionality by adding Pytorch as a validtarget
, enabling code to be transpiled to Pytorch.For example, after completing this task, we should be able to transpile TensorFlow code using:
Goals:
The main objective is to implement the final stage of the transpilation pipeline:
Once this stage is complete, the rest of the pipeline can be reused to target other frameworks like JAX, PyTorch, or NumPy. The steps would look as follows:
This mirrors the existing pipeline for eg: PyTorch -> TF:
Key Tasks:
ivy_to_torch_postprocessing_transformer.py
for doing postprocessing on the Ivy code when lowering it to Pytorch (eg: mapping ivy dtypes (eg:ivy.float32
) to torch dtypes(torch.float32
)ivy_to_jax_postprocessing_transformer.py
as a reference (example here)2 Define the Transformation Pipeline for Ivy IR to Torch
ivy_to_source_translator_config.py
to handle the stagesource='ivy', target='torch'
(example here).Add Stateful Classes for
torch.nn
APIs:torch.nn.Module
that exposes the similar interface as that ofivy.Module
.keras.Model
ornnx.Module
(example 1) (example 2)Understand and Leverage Reusability:
Testing:
Additional Notes:
The text was updated successfully, but these errors were encountered: