dgl.dataloading.base.LazyFeature¶
-
class
dgl.dataloading.base.
LazyFeature
(name=None, id_=None)[source]¶ Placeholder for feature prefetching.
One can assign this object to
ndata
oredata
of the graphs returned by various samplers’sample
method. When DGL’s dataloader receives the subgraphs returned by the sampler, it will automatically look up all thendata
andedata
whose data is a LazyFeature, replacing them with the actual data of the corresponding nodes/edges from the original graph instead. In particular, for a subgraph returned by the sampler has a LazyFeature with namek
insubgraph.ndata[key]
:subgraph.ndata[key] = LazyFeature(k)
Assuming that
graph
is the original graph, DGL’s dataloader will performsubgraph.ndata[key] = graph.ndata[k][subgraph.ndata[dgl.NID]]
DGL dataloader performs similar replacement for
edata
. For heterogeneous graphs, the replacement is:subgraph.nodes[ntype].data[key] = graph.nodes[ntype].data[k][ subgraph.nodes[ntype].data[dgl.NID]]
For MFGs’
srcdata
(and similarlydstdata
), the replacement ismfg.srcdata[key] = graph.ndata[k][mfg.srcdata[dgl.NID]]
- Parameters
name (str) – The name of the data in the original graph.
id_ (Tensor, optional) – The ID tensor.
-
__init__
(name=None, id_=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
([name, id_])Initialize self.
pin_memory_
()No-op.
to
(*args, **kwargs)No-op.
unpin_memory_
()No-op.
Attributes
data
No-op.
id_
name