Extract edge features of the given edges from :attr:`graph` and return them in frames. Note that this function does not perform actual tensor memory copy but using `Frame.subframe` to get the features. If :attr:`edges` is None, it performs a shallow copy of the original edge frames
(graph, edges_or_device, store_ids=True)
| 918 | |
| 919 | |
| 920 | def extract_edge_subframes(graph, edges_or_device, store_ids=True): |
| 921 | """Extract edge features of the given edges from :attr:`graph` |
| 922 | and return them in frames. |
| 923 | |
| 924 | Note that this function does not perform actual tensor memory copy but using `Frame.subframe` |
| 925 | to get the features. If :attr:`edges` is None, it performs a shallow copy of the |
| 926 | original edge frames that only copies the dictionary structure but not the tensor |
| 927 | contents. |
| 928 | |
| 929 | Parameters |
| 930 | ---------- |
| 931 | graph : DGLGraph |
| 932 | The graph to extract features from. |
| 933 | edges_or_device : list[Tensor] or device or None |
| 934 | Edge IDs. |
| 935 | If a list, the list length must be equal to the number of edge types |
| 936 | in the graph. |
| 937 | If None, the whole frame is shallow-copied. |
| 938 | store_ids : bool |
| 939 | If True, the returned frames will store :attr:`edges` in the ``dgl.EID`` field |
| 940 | unless it is None. |
| 941 | |
| 942 | Returns |
| 943 | ------- |
| 944 | list[Frame] |
| 945 | Extracted edge frames. |
| 946 | """ |
| 947 | if edges_or_device is None: |
| 948 | edge_frames = [nf.clone() for nf in graph._edge_frames] |
| 949 | elif is_listlike(edges_or_device): |
| 950 | edge_frames = [] |
| 951 | for i, ind_edges in enumerate(edges_or_device): |
| 952 | subf = graph._edge_frames[i].subframe(ind_edges) |
| 953 | if store_ids: |
| 954 | subf[EID] = ind_edges |
| 955 | edge_frames.append(subf) |
| 956 | else: # device object |
| 957 | edge_frames = [nf.to(edges_or_device) for nf in graph._edge_frames] |
| 958 | return edge_frames |
| 959 | |
| 960 | |
| 961 | def set_new_frames(graph, *, node_frames=None, edge_frames=None): |
nothing calls this directly
no test coverage detected