dgl.DGLGraph.multi_update_all¶
-
DGLGraph.
multi_update_all
(etype_dict, cross_reducer, apply_node_func=None)[source]¶ Send messages along all the edges, reduce them by first type-wisely then across different types, and then update the node features of all the nodes.
- Parameters
etype_dict (dict) –
Arguments for edge-type-wise message passing. The keys are edge types while the values are message passing arguments.
The allowed key formats are:
(str, str, str)
for source node type, edge type and destination node type.or one
str
edge type name if the name can uniquely identify a triplet format in the graph.
The value must be a tuple
(message_func, reduce_func, [apply_node_func])
, where- message_funcdgl.function.BuiltinFunction or callable
The message function to generate messages along the edges. It must be either a DGL Built-in Function or a User-defined Functions.
- reduce_funcdgl.function.BuiltinFunction or callable
The reduce function to aggregate the messages. It must be either a DGL Built-in Function or a User-defined Functions.
- apply_node_funccallable, optional
An optional apply function to further update the node features after the message reduction. It must be a User-defined Functions.
cross_reducer (str or callable function) – Cross type reducer. One of
"sum"
,"min"
,"max"
,"mean"
,"stack"
or a callable function. If a callable function is provided, the input argument must be a single list of tensors containing aggregation results from each edge type, and the output of function must be a single tensor.apply_node_func (callable, optional) – An optional apply function after the messages are reduced both type-wisely and across different types. It must be a User-defined Functions.
Notes
DGL recommends using DGL’s bulit-in function for the message_func and the reduce_func in the type-wise message passing arguments, because DGL will invoke efficient kernels that avoids copying node features to edge features in this case.
Examples
Instantiate a heterograph.
Update all.
User-defined cross reducer equivalent to “sum”.
Use the user-defined cross reducer.