Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: jit-compile TF functions #441

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/tensorwaves/function/sympy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,20 @@ def numba_lambdify() -> Callable:

def tensorflow_lambdify() -> Callable:
try:
import tensorflow as tf
import tensorflow.experimental.numpy as tnp # pyright: ignore[reportMissingImports]
except ImportError: # pragma: no cover
raise_missing_module_error("tensorflow", extras_require="tf")
from ._printer import TensorflowPrinter

return _sympy_lambdify(
func = _sympy_lambdify(
expression,
symbols,
modules=tnp,
printer=TensorflowPrinter(),
use_cse=use_cse,
)
return tf.function(func, jit_compile=True)

modules = get_backend_modules(backend)
if isinstance(backend, str):
Expand Down
2 changes: 2 additions & 0 deletions tests/function/test_sympy.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def test_fast_lambdify(backend: str, max_complexity: int, use_cse: bool):
else:
# cspell:ignore lambdifygenerated
repr_start = "<function _lambdifygenerated"
if backend == "tf":
repr_start = "<tensorflow.python.eager."
if backend == "jax":
repr_start = "<PjitFunction of " + repr_start
# cspell:ignore Pjit
Expand Down
Loading