Extract node features of the given nodes from :attr:`graph` and return them in frames on the given device. Note that this function does not perform actual tensor memory copy but using `Frame.subframe` to get the features. If :attr:`nodes` is None, it performs a shallow copy of the o
(graph, nodes_or_device, store_ids=True)
| 840 | |
| 841 | |
| 842 | def extract_node_subframes(graph, nodes_or_device, store_ids=True): |
| 843 | """Extract node features of the given nodes from :attr:`graph` |
| 844 | and return them in frames on the given device. |
| 845 | |
| 846 | Note that this function does not perform actual tensor memory copy but using `Frame.subframe` |
| 847 | to get the features. If :attr:`nodes` is None, it performs a shallow copy of the |
| 848 | original node frames that only copies the dictionary structure but not the tensor |
| 849 | contents. |
| 850 | |
| 851 | Parameters |
| 852 | ---------- |
| 853 | graph : DGLGraph |
| 854 | The graph to extract features from. |
| 855 | nodes : list[Tensor] or device or None |
| 856 | Node IDs or device. |
| 857 | If a list, the list length must be equal to the number of node types |
| 858 | in the graph. |
| 859 | If None, the whole frame is shallow-copied. |
| 860 | store_ids : bool |
| 861 | If True, the returned frames will store :attr:`nodes` in the ``dgl.NID`` field |
| 862 | unless it is None. |
| 863 | |
| 864 | Returns |
| 865 | ------- |
| 866 | list[Frame] |
| 867 | Extracted node frames. |
| 868 | """ |
| 869 | if nodes_or_device is None: |
| 870 | node_frames = [nf.clone() for nf in graph._node_frames] |
| 871 | elif is_listlike(nodes_or_device): |
| 872 | node_frames = [] |
| 873 | for i, ind_nodes in enumerate(nodes_or_device): |
| 874 | subf = graph._node_frames[i].subframe(ind_nodes) |
| 875 | if store_ids: |
| 876 | subf[NID] = ind_nodes |
| 877 | node_frames.append(subf) |
| 878 | else: # device object |
| 879 | node_frames = [nf.to(nodes_or_device) for nf in graph._node_frames] |
| 880 | return node_frames |
| 881 | |
| 882 | |
| 883 | def extract_node_subframes_for_block(graph, srcnodes, dstnodes): |
nothing calls this directly
no test coverage detected