Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphStore: handle zero-sized edge indices #4962

Merged
merged 4 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added `time_attr` argument to `LinkNeighborLoader` ([#4877](https://github.com/pyg-team/pytorch_geometric/pull/4877), [#4908](https://github.com/pyg-team/pytorch_geometric/pull/4908))
- Added a `filter_per_worker` argument to data loaders to allow filtering of data within sub-processes ([#4873](https://github.com/pyg-team/pytorch_geometric/pull/4873))
- Added a `NeighborLoader` benchmark script ([#4815](https://github.com/pyg-team/pytorch_geometric/pull/4815), [#4862](https://github.com/pyg-team/pytorch_geometric/pull/4862/files))
- Added support for `FeatureStore` and `GraphStore` in `NeighborLoader` ([#4817](https://github.com/pyg-team/pytorch_geometric/pull/4817), [#4851](https://github.com/pyg-team/pytorch_geometric/pull/4851), [#4854](https://github.com/pyg-team/pytorch_geometric/pull/4854), [#4856](https://github.com/pyg-team/pytorch_geometric/pull/4856), [#4857](https://github.com/pyg-team/pytorch_geometric/pull/4857), [#4882](https://github.com/pyg-team/pytorch_geometric/pull/4882), [#4883](https://github.com/pyg-team/pytorch_geometric/pull/4883), [#4929](https://github.com/pyg-team/pytorch_geometric/pull/4929), [#4992](https://github.com/pyg-team/pytorch_geometric/pull/4922))
- Added support for `FeatureStore` and `GraphStore` in `NeighborLoader` ([#4817](https://github.com/pyg-team/pytorch_geometric/pull/4817), [#4851](https://github.com/pyg-team/pytorch_geometric/pull/4851), [#4854](https://github.com/pyg-team/pytorch_geometric/pull/4854), [#4856](https://github.com/pyg-team/pytorch_geometric/pull/4856), [#4857](https://github.com/pyg-team/pytorch_geometric/pull/4857), [#4882](https://github.com/pyg-team/pytorch_geometric/pull/4882), [#4883](https://github.com/pyg-team/pytorch_geometric/pull/4883), [#4929](https://github.com/pyg-team/pytorch_geometric/pull/4929), [#4992](https://github.com/pyg-team/pytorch_geometric/pull/4922), [#4962](https://github.com/pyg-team/pytorch_geometric/pull/4962))
- Added a `normalize` parameter to `dense_diff_pool` ([#4847](https://github.com/pyg-team/pytorch_geometric/pull/4847))
- Added `size=None` explanation to jittable `MessagePassing` modules in the documentation ([#4850](https://github.com/pyg-team/pytorch_geometric/pull/4850))
- Added documentation to the `DataLoaderIterator` class ([#4838](https://github.com/pyg-team/pytorch_geometric/pull/4838))
Expand Down
22 changes: 14 additions & 8 deletions torch_geometric/data/graph_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,12 @@ def edge_tensor_type_to_adj_type(
r"""Converts an EdgeTensorType tensor tuple to a PyG Adj tensor."""
src, dst = tensor_tuple

if attr.layout == EdgeLayout.COO:
# COO: (row, col)
if attr.layout == EdgeLayout.COO: # COO: (row, col)
assert src.dim() == 1 and dst.dim() == 1 and src.numel() == dst.numel()

if src.numel() == 0:
return torch.stack(tensor_tuple, dim=0)

if (src[0].storage().data_ptr() == dst[1].storage().data_ptr()
and src.storage_offset() < dst.storage_offset()):
# Do not copy if the tensor tuple is constructed from the same
Expand All @@ -303,14 +307,16 @@ def edge_tensor_type_to_adj_type(
out.set_(src.storage(), storage_offset=src.storage_offset(),
size=(src.size()[0] + dst.size()[0], ))
return out.view(2, -1)
return torch.stack(tensor_tuple)
elif attr.layout == EdgeLayout.CSR:
# CSR: (rowptr, col)

return torch.stack(tensor_tuple, dim=0)

elif attr.layout == EdgeLayout.CSR: # CSR: (rowptr, col)
return SparseTensor(rowptr=src, col=dst, is_sorted=True,
sparse_sizes=attr.size)
elif attr.layout == EdgeLayout.CSC:
# CSC: (row, colptr) is a transposed adjacency matrix, so rowptr
# is the compressed column and col is the uncompressed row.

elif attr.layout == EdgeLayout.CSC: # CSC: (row, colptr)
# CSC is a transposed adjacency matrix, so rowptr is the compressed
# column and col is the uncompressed row.
sparse_sizes = None if attr.size is None else (attr.size[1],
attr.size[0])
return SparseTensor(rowptr=dst, col=src, is_sorted=True,
Expand Down