MCPcopy Index your code
hub / github.com/dmlc/dgl / sparse_matrix

Function sparse_matrix

python/dgl/backend/tensorflow/tensor.py:80–93  ·  view source on GitHub ↗
(data, index, shape, force_format=False)

Source from the content-addressed store, hash-verified

78
79
80def sparse_matrix(data, index, shape, force_format=False):
81 fmt = index[0]
82 if fmt != "coo":
83 raise TypeError(
84 "Tensorflow backend only supports COO format. But got %s." % fmt
85 )
86 # tf.SparseTensor only supports int64 indexing,
87 # therefore manually casting to int64 when input in int32
88 spmat = tf.SparseTensor(
89 indices=tf.cast(tf.transpose(index[1], (1, 0)), tf.int64),
90 values=data,
91 dense_shape=shape,
92 )
93 return spmat, None
94
95
96def sparse_matrix_indices(spmat):

Callers

nothing calls this directly

Calls 1

transposeMethod · 0.80

Tested by

no test coverage detected