From 6ce43b00308a4be2ec107cefa4b192bfcf4b60d5 Mon Sep 17 00:00:00 2001 From: Sam Armstrong <88863522+Sam-Armstrong@users.noreply.github.com> Date: Mon, 24 Jun 2024 18:53:35 +0100 Subject: [PATCH] Update compiler.py 8a734de (#28778) Co-authored-by: ivy-dev-bot --- binaries.json | 67 ++++++++++++++++++++++++++++++++++++++++ ivy/compiler/compiler.py | 33 ++++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/binaries.json b/binaries.json index 7d3828fe49f0a..8fa03137f07a9 100644 --- a/binaries.json +++ b/binaries.json @@ -22,7 +22,21 @@ "DX", "I", "IC", + "ICC", + "ICD", + "ICI", + "ICL", + "ICM", + "ICV", + "ICX", "ID", + "IDC", + "IDD", + "IDI", + "IDL", + "IDM", + "IDV", + "IDX", "II", "IIC", "IID", @@ -32,10 +46,37 @@ "IIV", "IIX", "IL", + "ILC", + "ILD", + "ILI", + "ILL", + "ILM", + "ILV", + "ILX", "IM", + "IMC", + "IMD", + "IMI", + "IML", + "IMM", + "IMV", + "IMX", "IV", + "IVC", + "IVD", "IVI", + "IVL", + "IVM", + "IVV", + "IVX", "IX", + "IXC", + "IXD", + "IXI", + "IXL", + "IXM", + "IXV", + "IXX", "L", "LC", "LD", @@ -56,10 +97,36 @@ "VC", "VD", "VI", + "VIC", + "VID", + "VII", + "VIL", + "VIM", + "VIV", + "VIX", "VL", + "VLC", + "VLI", + "VLL", + "VLV", + "VLX", "VM", "VV", + "VVC", + "VVD", + "VVI", + "VVL", + "VVM", + "VVV", + "VVX", "VX", + "VXC", + "VXD", + "VXI", + "VXL", + "VXM", + "VXV", + "VXX", "X", "XC", "XD", diff --git a/ivy/compiler/compiler.py b/ivy/compiler/compiler.py index e6b55feda51b9..6390134c580ce 100644 --- a/ivy/compiler/compiler.py +++ b/ivy/compiler/compiler.py @@ -1,6 +1,39 @@ from typing import Callable, Optional, List, Union, Iterable, Sequence, Mapping +def source_to_source( + object, + source: str = "torch", + target: str = "torch_frontend", + profiling: bool = False, +): + """Converts a given object (class/function) from one framework to another. + + This function performs source-to-source translation of a given object from the source framework + to the target framework. + + The object can be translated between two frameworks or in-between the Ivy IR + as well e.g. (source="torch_frontend", target="ivy") or (source="torch_frontend", target="tensorflow") etc. + + Args: + object: The object (class/function) to be translated. + source (str, optional): The source framework. Defaults to 'torch'. + target (str, optional): The target framework. Defaults to 'torch_frontend'. + profiling: Whether to add performance profiling. + + Returns: + The translated object.""" + + from ._compiler import source_to_source as _source_to_source + + return _source_to_source( + object=object, + source=source, + target=target, + profiling=profiling, + ) + + def trace_graph( *objs: Callable, stateful: Optional[List] = None,