tglite.TBlock¶
TBlock captures 1-hop relationships between node/time pairs and their neighbors for doing computations. Figure shows the internal structure of a TBlock and the doubly-linked list design with next and prev pointing to sampled neighbors’ TBlock. To have a general idea of how TBlock works, please refer to the tutorial.
Diagram of the doubly-linked list design and internal structure of a TBlock (destination node-time is denoted as <i,t>).¶
- class tglite.TBlock(ctx: TContext, layer: int, dstnodes: np.ndarray, dsttimes: np.ndarray, dstindex: np.ndarray = None, srcnodes: np.ndarray = None, eid: np.ndarray = None, ets: np.ndarray = None)¶
Captures 1-hop relations between node/time pairs and their neighbors for doing computations, such as segmented softmax and message-passing aggregation.
- __init__(ctx: TContext, layer: int, dstnodes: np.ndarray, dsttimes: np.ndarray, dstindex: np.ndarray = None, srcnodes: np.ndarray = None, eid: np.ndarray = None, ets: np.ndarray = None)¶
Internal constructor for creating a TBlock.
- Parameters:
ctx (TContext) – The TContext.
layer (int) – The layer in the GNN.
dstnodes (np.ndarray) – The destination nodes.
dstindex (np.ndarray) – The indices of destination nodes in dstnodes.
srcnodes (np.ndarray) – The source nodes of the edges.
eid (np.ndarray) – The edge indices.
ets (np.ndarray) – The edge timestamps.
Query TBlock attributes¶
Returns the TGraph associated with this TBlock. |
|
Returns the GNN layer to which this TBlock belongs. |
|
Returns the full destination nodes. |
|
Returns the destination node timestamps. |
|
|
Returns the length of destination node array. |
Query neighbor attributes¶
Returns the indices of destination nodes in self.dstnodes() that are used for sampling. |
|
Return the source nodes (temporally sampled neighbors). |
|
|
Returns the length of source node array when self.has_nbrs() is True. |
Returns the edge indices, which are connections towards sampled neighbors. |
|
Returns the edge timestamps. |
|
Returns the number of edges in the block when self.has_nbrs() is True. |
|
|
Returns True when the block has the neighbor attributes, including dstindex, srcnodes, eid and ets. |
Query data¶
Returns the destination node data. |
|
Returns the source node data. |
|
Returns the edge data. |
Query Cache¶
|
Returns a tensor containing the destination nodes concatenated with the source nodes (if available) in pre-defined TGraph's storage device. |
|
Returns a Tensor tuple: (the unique source node indices, the indices of the unique array that reconstructs the source node array) in pre-defined TGraph's storage device. |
|
Returns the edge features in TGraph's computation device, always use pinned memory if possible. |
|
Returns the node features in TGraph's computation device, always use pinned memory if possible. |
|
Returns the source node features in TGraph's computation device, always use pinned memory if possible. |
|
Returns the destination node features in TGraph's computation device, always use pinned memory if possible. |
|
Returns node memory in TGraph's computation device, always use pinned memory if possible. |
|
Returns the node mails in TGraph's computation device, always use pinned memory if possible. |
Computes the timestamp differences between destination nodes (used for sampling) and edges and returns them as a tensor in pre-defined TGraph's computation device. |
Neighbor ops¶
|
Sets the neighbor attributes for the block. |
Clears the neighbor attributes and related cache. |
Linked list ops¶
Returns the previous TBlock. |
|
Returns the next TBlock. |
|
|
Generates the next TBlock with neighbor information. |
Execution ops¶
|
Applies an operator to the block itself and returns the output. |
|
Registers a hook for running post-processing. |
|
Runs registered hooks on the input tensor in reversed order. |
Clears all the hooks. |