Skip to content

Commit

Permalink
Update compiler.py 4920372
Browse files Browse the repository at this point in the history
  • Loading branch information
ivy-dev-bot committed Sep 13, 2024
1 parent eda6453 commit 1366489
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion binaries.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@
}
]
}
}
}
47 changes: 23 additions & 24 deletions ivy/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@


def clear_graph_cache():
"""Clears the graph cache which gets populated if `graph_caching` is set to
`True` in `ivy.trace_graph`, `ivy.transpile` or `ivy.unify`. Use this to
"""Clears the graph cache which gets populated if `graph_caching` is set
to `True` in `ivy.trace_graph`, `ivy.transpile` or `ivy.unify`. Use this to
reset or clear the graph cache if needed.
Examples
--------
>>> import ivy
>>> ivy.clear_graph_cache()
"""
>>> ivy.clear_graph_cache()"""

from ._compiler import clear_graph_cache as _clear_graph_cache

return _clear_graph_cache()
Expand Down Expand Up @@ -55,8 +55,8 @@ def graph_transpile(
Returns
-------
Either a transpiled Graph or a non-initialized LazyGraph.
"""
Either a transpiled Graph or a non-initialized LazyGraph."""

from ._compiler import graph_transpile as _graph_transpile

return _graph_transpile(
Expand All @@ -82,7 +82,10 @@ def graph_transpile(


def source_to_source(
object, source: str = "torch", target: str = "tensorflow", profiling: bool = False
object,
source: str = "torch",
target: str = "tensorflow",
reuse_existing: bool = True,
):
"""Converts a given object (class/function) from one framework to another.
Expand All @@ -93,23 +96,25 @@ def source_to_source(
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 'tensorflow'.
profiling: Whether to add performance profiling.
reuse_existing (bool, optional): If True, the function will check if `object`
already exists in the translated directory and reuse it.
If False, it will re-translate `object`,
even if it already exists in the directory, and overwrite
the old implementation. Defaults to 'True'.
Returns:
-------
The translated object.
"""
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,
reuse_existing=reuse_existing,
)


Expand All @@ -133,8 +138,7 @@ def trace_graph(
params_v=None,
v=None
):
"""Takes `fn` and traces it into a more efficient composition of backend
operations.
"""Takes `fn` and traces it into a more efficient composition of backend operations.
Parameters
----------
Expand Down Expand Up @@ -204,8 +208,8 @@ def trace_graph(
>>> start = time.time()
>>> graph(x)
>>> print(time.time() - start)
0.0001785755157470703
"""
0.0001785755157470703"""

from ._compiler import trace_graph as _trace_graph

return _trace_graph(
Expand Down Expand Up @@ -234,7 +238,6 @@ def transpile(
object,
source: str = "torch",
target: str = "tensorflow",
profiling: bool = False,
reuse_existing: bool = True,
):
"""Converts a given object (class/function) from one framework to another.
Expand All @@ -246,28 +249,24 @@ def transpile(
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 'tensorflow'.
profiling: Whether to add performance profiling.
reuse_existing (bool, optional): If True, the function will check if `object`
already exists in the translated directory and reuse it.
If False, it will re-translate `object`,
even if it already exists in the directory, and overwrite
the old implementation. Defaults to 'True'.
Returns:
-------
The translated object.
"""
The translated object."""

from ._compiler import transpile as _transpile

return _transpile(
object=object,
source=source,
target=target,
profiling=profiling,
reuse_existing=reuse_existing,
)

Expand Down

0 comments on commit 1366489

Please sign in to comment.