r"""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
(self, etype_dict, cross_reducer, apply_node_func=None)
| 5159 | ################################################################# |
| 5160 | |
| 5161 | def multi_update_all(self, etype_dict, cross_reducer, apply_node_func=None): |
| 5162 | r"""Send messages along all the edges, reduce them by first type-wisely |
| 5163 | then across different types, and then update the node features of all |
| 5164 | the nodes. |
| 5165 | |
| 5166 | Parameters |
| 5167 | ---------- |
| 5168 | etype_dict : dict |
| 5169 | Arguments for edge-type-wise message passing. The keys are edge types |
| 5170 | while the values are message passing arguments. |
| 5171 | |
| 5172 | The allowed key formats are: |
| 5173 | |
| 5174 | * ``(str, str, str)`` for source node type, edge type and destination node type. |
| 5175 | * or one ``str`` edge type name if the name can uniquely identify a |
| 5176 | triplet format in the graph. |
| 5177 | |
| 5178 | The value must be a tuple ``(message_func, reduce_func, [apply_node_func])``, where |
| 5179 | |
| 5180 | * message_func : dgl.function.BuiltinFunction or callable |
| 5181 | The message function to generate messages along the edges. |
| 5182 | It must be either a :ref:`api-built-in` or a :ref:`apiudf`. |
| 5183 | * reduce_func : dgl.function.BuiltinFunction or callable |
| 5184 | The reduce function to aggregate the messages. |
| 5185 | It must be either a :ref:`api-built-in` or a :ref:`apiudf`. |
| 5186 | * apply_node_func : callable, optional |
| 5187 | An optional apply function to further update the node features |
| 5188 | after the message reduction. It must be a :ref:`apiudf`. |
| 5189 | |
| 5190 | cross_reducer : str or callable function |
| 5191 | Cross type reducer. One of ``"sum"``, ``"min"``, ``"max"``, ``"mean"``, ``"stack"`` |
| 5192 | or a callable function. If a callable function is provided, the input argument must be |
| 5193 | a single list of tensors containing aggregation results from each edge type, and the |
| 5194 | output of function must be a single tensor. |
| 5195 | apply_node_func : callable, optional |
| 5196 | An optional apply function after the messages are reduced both |
| 5197 | type-wisely and across different types. |
| 5198 | It must be a :ref:`apiudf`. |
| 5199 | |
| 5200 | Notes |
| 5201 | ----- |
| 5202 | DGL recommends using DGL's bulit-in function for the message_func |
| 5203 | and the reduce_func in the type-wise message passing arguments, |
| 5204 | because DGL will invoke efficient kernels that avoids copying node features to |
| 5205 | edge features in this case. |
| 5206 | |
| 5207 | |
| 5208 | Examples |
| 5209 | -------- |
| 5210 | >>> import dgl |
| 5211 | >>> import dgl.function as fn |
| 5212 | >>> import torch |
| 5213 | |
| 5214 | Instantiate a heterograph. |
| 5215 | |
| 5216 | >>> g = dgl.heterograph({ |
| 5217 | ... ('user', 'follows', 'user'): ([0, 1], [1, 1]), |
| 5218 | ... ('game', 'attracts', 'user'): ([0], [1]) |