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

updating repo #1

Merged
merged 4 commits into from
Aug 21, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Changed

- Fixed broken links in `HGBDataset` ([#7907](https://github.com/pyg-team/pytorch_geometric/pull/7907))
- Fixed an issue where `SetTransformerAggregation` produced `NaN` values for isolates nodes ([#7902](https://github.com/pyg-team/pytorch_geometric/pull/7902))
- Fixed `model_summary` on modules with uninitialized parameters ([#7884](https://github.com/pyg-team/pytorch_geometric/pull/7884))
- Updated `QM9` data pre-processing to include the SMILES string ([#7867](https://github.com/pyg-team/pytorch_geometric/pull/7867))
Expand Down
2 changes: 1 addition & 1 deletion test/transforms/test_rooted_subgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_rooted_rw_subgraph():
assert out.n_sub_batch.tolist() == [0, 0, 1, 1, 2, 2]


@withPackage('torch>=1.12.0')
@withPackage('torch>=1.12.0', 'torch<2.1.0')
def test_rooted_subgraph_minibatch():
x = torch.randn(3, 8)
edge_index = torch.tensor([[0, 1, 1, 2], [1, 0, 2, 1]])
Expand Down
6 changes: 3 additions & 3 deletions test/utils/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,13 @@ def test_to_cugraph(edge_weight, directed, relabel_nodes):
edge_list = graph.view_edge_list()
assert edge_list is not None

edge_list = edge_list.sort_values(by=['src', 'dst'])
edge_list = edge_list.sort_values(by=[0, 1])

cu_edge_index = edge_list[['src', 'dst']].to_pandas().values
cu_edge_index = edge_list[[0, 1]].to_pandas().values
cu_edge_index = torch.from_numpy(cu_edge_index).t()
cu_edge_weight = None
if edge_weight is not None:
cu_edge_weight = edge_list['weights'].to_pandas().values
cu_edge_weight = edge_list['2'].to_pandas().values
cu_edge_weight = torch.from_numpy(cu_edge_weight)

cu_edge_index, cu_edge_weight = sort_edge_index(cu_edge_index,
Expand Down
27 changes: 19 additions & 8 deletions torch_geometric/datasets/hgb_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,31 @@ class HGBDataset(InMemoryDataset):
transformed version. The data object will be transformed before
being saved to disk. (default: :obj:`None`)
"""

url = ('https://cloud.tsinghua.edu.cn/d/2d965d2fc2ee41d09def/files/'
'?p=%2F{}.zip&dl=1')

names = {
'acm': 'ACM',
'dblp': 'DBLP',
'freebase': 'Freebase',
'imdb': 'IMDB',
}

def __init__(self, root: str, name: str,
transform: Optional[Callable] = None,
pre_transform: Optional[Callable] = None):
urls = {
'acm': ('https://drive.google.com/uc?'
'export=download&id=1xbJ4QE9pcDJOcALv7dYhHDCPITX2Iddz'),
'dblp': ('https://drive.google.com/uc?'
'export=download&id=1fLLoy559V7jJaQ_9mQEsC06VKd6Qd3SC'),
'freebase': ('https://drive.google.com/uc?'
'export=download&id=1vw-uqbroJZfFsWpriC1CWbtHCJMGdWJ7'),
'imdb': ('https://drive.google.com/uc?'
'export=download&id=18qXmmwKJBrEJxVQaYwKTL3Ny3fPqJeJ2'),
}

def __init__(
self,
root: str,
name: str,
transform: Optional[Callable] = None,
pre_transform: Optional[Callable] = None,
):
self.name = name.lower()
assert self.name in set(self.names.keys())
super().__init__(root, transform, pre_transform)
Expand All @@ -77,7 +88,7 @@ def processed_file_names(self) -> str:
return 'data.pt'

def download(self):
url = self.url.format(self.names[self.name])
url = self.urls[self.name]
path = download_url(url, self.raw_dir)
extract_zip(path, self.raw_dir)
os.unlink(path)
Expand Down
16 changes: 12 additions & 4 deletions torch_geometric/distributed/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,14 @@ def generate_partition(self):
size = (self.data[src].num_nodes, self.data[dst].num_nodes)

mask = part_data.edge_type == i
rows = part_data.edge_index[0, mask]
cols = part_data.edge_index[1, mask]
global_rows = node_id[rows]
global_cols = node_perm[cols]
out[edge_type] = {
'edge_id': edge_id[mask],
'row': part_data.edge_index[0, mask],
'col': part_data.edge_index[1, mask],
'row': global_rows,
'col': global_cols,
'size': size,
}
torch.save(out, osp.join(path, 'graph.pt'))
Expand Down Expand Up @@ -213,12 +217,16 @@ def generate_partition(self):

node_id = node_perm[start:end]
node_map[node_id] = pid
rows = part_data.edge_index[0]
cols = part_data.edge_index[1]
global_rows = node_id[rows]
global_cols = node_perm[cols]

torch.save(
{
'edge_id': edge_id,
'row': part_data.edge_index[0],
'col': part_data.edge_index[1],
'row': global_rows,
'col': global_cols,
'size': (data.num_nodes, data.num_nodes),
}, osp.join(path, 'graph.pt'))

Expand Down
8 changes: 4 additions & 4 deletions torch_geometric/utils/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,13 +457,13 @@ def from_cugraph(g: Any) -> Tuple[Tensor, Optional[Tensor]]:
"""
df = g.view_edge_list()

src = from_dlpack(df['src'].to_dlpack()).long()
dst = from_dlpack(df['dst'].to_dlpack()).long()
src = from_dlpack(df[0].to_dlpack()).long()
dst = from_dlpack(df[1].to_dlpack()).long()
edge_index = torch.stack([src, dst], dim=0)

edge_weight = None
if 'weights' in df:
edge_weight = from_dlpack(df['weights'].to_dlpack())
if '2' in df:
edge_weight = from_dlpack(df['2'].to_dlpack())

return edge_index, edge_weight

Expand Down