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

Add tf.SparseTensor and tf.IndexedSlices support to a number of T… #18633

Merged
merged 1 commit into from
Oct 25, 2023
Merged
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
3 changes: 2 additions & 1 deletion keras/backend/common/dtypes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from keras import ops
from keras.backend.common import dtypes
from keras.backend.common.variables import ALLOWED_DTYPES
from keras.backend.torch.core import to_torch_dtype
from keras.testing import test_case
from keras.testing.test_utils import named_product

Expand All @@ -13,6 +12,8 @@ class DtypesTest(test_case.TestCase, parameterized.TestCase):
"""Test the dtype to verify that the behavior matches JAX."""

if backend.backend() == "torch":
from keras.backend.torch.core import to_torch_dtype

# TODO: torch doesn't support uint64.
ALL_DTYPES = []
for x in ALLOWED_DTYPES:
Expand Down
2 changes: 2 additions & 0 deletions keras/backend/tensorflow/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def convert_to_tensor(x, dtype=None, sparse=True):
def convert_to_numpy(x):
if isinstance(x, tf.SparseTensor):
x = tf.sparse.to_dense(x)
elif isinstance(x, tf.IndexedSlices):
x = tf.convert_to_tensor(x)
return np.array(x)


Expand Down
Loading