Assign lazy features to the ``ndata`` of the input graph for prefetching optimization. When used in a :class:`~dgl.dataloading.Sampler`, lazy features mark which data should be fetched before computation in model. See :ref:`guide-minibatch-prefetching` for a detailed explanation. I
(g, feature_names)
| 21 | |
| 22 | |
| 23 | def set_node_lazy_features(g, feature_names): |
| 24 | """Assign lazy features to the ``ndata`` of the input graph for prefetching optimization. |
| 25 | |
| 26 | When used in a :class:`~dgl.dataloading.Sampler`, lazy features mark which data |
| 27 | should be fetched before computation in model. See :ref:`guide-minibatch-prefetching` |
| 28 | for a detailed explanation. |
| 29 | |
| 30 | If the graph is homogeneous, this is equivalent to: |
| 31 | |
| 32 | .. code:: python |
| 33 | |
| 34 | g.ndata.update({k: LazyFeature(k, g.ndata[dgl.NID]) for k in feature_names}) |
| 35 | |
| 36 | If the graph is heterogeneous, this is equivalent to: |
| 37 | |
| 38 | .. code:: python |
| 39 | |
| 40 | for type_, names in feature_names.items(): |
| 41 | g.nodes[type_].data.update( |
| 42 | {k: LazyFeature(k, g.nodes[type_].data[dgl.NID]) for k in names}) |
| 43 | |
| 44 | Parameters |
| 45 | ---------- |
| 46 | g : DGLGraph |
| 47 | The graph. |
| 48 | feature_names : list[str] or dict[str, list[str]] |
| 49 | The feature names to prefetch. |
| 50 | |
| 51 | See also |
| 52 | -------- |
| 53 | dgl.LazyFeature |
| 54 | """ |
| 55 | return _set_lazy_features(g.nodes, g.ndata, feature_names) |
| 56 | |
| 57 | |
| 58 | def set_edge_lazy_features(g, feature_names): |
no test coverage detected