MCPcopy
hub / github.com/dmlc/dgl / tensor

Function tensor

python/dgl/backend/tensorflow/tensor.py:50–59  ·  view source on GitHub ↗
(data, dtype=None)

Source from the content-addressed store, hash-verified

48
49
50def tensor(data, dtype=None):
51 if isinstance(data, tf.Tensor):
52 if dtype is None or data.dtype == dtype:
53 return data
54 else:
55 return tf.cast(data, dtype=dtype)
56 else:
57 if isinstance(data, numbers.Number):
58 data = [data]
59 return tf.convert_to_tensor(data, dtype=dtype)
60
61
62def initialize_context():

Callers 1

gradFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected