dgl.dataloading.BlockSampler

class dgl.dataloading.BlockSampler(prefetch_node_feats=None, prefetch_labels=None, prefetch_edge_feats=None, output_device=None)[source]

Base class for sampling mini-batches in the form of Message-passing Flow Graphs (MFGs).

It provides prefetching options to fetch the node features for the first MFG’s srcdata, the node labels for the last MFG’s dstdata and the edge features of all MFG’s edata.

Parameters
  • prefetch_node_feats (list[str] or dict[str, list[str]], optional) –

    The node data to prefetch for the first MFG.

    DGL will populate the first layer’s MFG’s srcnodes and srcdata with the node data of the given names from the original graph.

  • prefetch_labels (list[str] or dict[str, list[str]], optional) –

    The node data to prefetch for the last MFG.

    DGL will populate the last layer’s MFG’s dstnodes and dstdata with the node data of the given names from the original graph.

  • prefetch_edge_feats (list[str] or dict[etype, list[str]], optional) –

    The edge data names to prefetch for all the MFGs.

    DGL will populate every MFG’s edges and edata with the edge data of the given names from the original graph.

  • output_device (device, optional) – The device of the output subgraphs or MFGs. Default is the same as the minibatch of seed nodes.

__init__(prefetch_node_feats=None, prefetch_labels=None, prefetch_edge_feats=None, output_device=None)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([prefetch_node_feats, …])

Initialize self.

assign_lazy_features(result)

Assign lazy features for prefetching.

sample(g, seed_nodes[, exclude_eids])

Sample a list of blocks from the given seed nodes.

sample_blocks(g, seed_nodes[, exclude_eids])

Generates a list of blocks from the given seed nodes.