diff --git a/CHANGELOG.md b/CHANGELOG.md index e9193a871d82..9d309282733f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/test/transforms/test_rooted_subgraph.py b/test/transforms/test_rooted_subgraph.py index ae7699a48637..eaee4b148bf0 100644 --- a/test/transforms/test_rooted_subgraph.py +++ b/test/transforms/test_rooted_subgraph.py @@ -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]]) diff --git a/test/utils/test_convert.py b/test/utils/test_convert.py index 93ea55d84586..8e4b8280a98f 100644 --- a/test/utils/test_convert.py +++ b/test/utils/test_convert.py @@ -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, diff --git a/torch_geometric/datasets/hgb_dataset.py b/torch_geometric/datasets/hgb_dataset.py index 2d77fd673600..223276e5408d 100644 --- a/torch_geometric/datasets/hgb_dataset.py +++ b/torch_geometric/datasets/hgb_dataset.py @@ -40,10 +40,6 @@ 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', @@ -51,9 +47,24 @@ class HGBDataset(InMemoryDataset): '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) @@ -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) diff --git a/torch_geometric/distributed/partition.py b/torch_geometric/distributed/partition.py index 918d03648de5..13b72bc835f0 100644 --- a/torch_geometric/distributed/partition.py +++ b/torch_geometric/distributed/partition.py @@ -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')) @@ -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')) diff --git a/torch_geometric/utils/convert.py b/torch_geometric/utils/convert.py index eccb23051bbb..e0fa499b5799 100644 --- a/torch_geometric/utils/convert.py +++ b/torch_geometric/utils/convert.py @@ -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