From 6ccbe117a63874965c547ecd210933a814f3d373 Mon Sep 17 00:00:00 2001 From: ivy-dev-bot Date: Mon, 24 Jun 2024 17:45:55 +0000 Subject: [PATCH] Update compiler.py 8a734de --- 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,