Skip to content

Support tf.SparseTensor #803

Description

@juanmirocks

tfgnn supports RaggedTensor but, to the best of my knowledge, doesn't support SparseTensor. This can be tested like:

import tensorflow as tf
import tensorflow_gnn as tfgnn

ragged = tf.RaggedTensor.from_row_splits(values=[3, 1, 4, 1, 5, 9, 2, 6], row_splits=[0, 4, 4, 7, 8, 8])
sparse = tf.SparseTensor(indices=[[0, 0], [1, 2]], values=[1, 2], dense_shape=[3, 4])

tfgnn.NodeSet.from_fields(sizes=[5], features={"x": ragged})
# works fine: NodeSet(features={'x': <tf.RaggedTensor: dtype=tf.int32>}, sizes=[5])

tfgnn.NodeSet.from_fields(sizes=[3], features={"x": sparse})
# throws exception

The last line throws an exception like:

ValueError: Attempt to convert a value (SparseTensor(indices=tf.Tensor(
... with an unsupported type (<class 'tensorflow.python.framework.sparse_tensor.SparseTensor'>) to a Tensor.

Is it possible for tfgnn to support SparseTensors? Are there plans for it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions