|
4 | 4 | import scipy.spatial |
5 | 5 | import torch |
6 | 6 | from torch_cluster import radius, radius_graph |
7 | | -from torch_cluster.testing import devices, floating_dtypes, tensor |
| 7 | +from torch_cluster.testing import ( |
| 8 | + devices, |
| 9 | + floating_dtypes, |
| 10 | + has_compiler, |
| 11 | + tensor, |
| 12 | +) |
8 | 13 |
|
9 | 14 |
|
10 | 15 | def to_set(edge_index): |
@@ -44,10 +49,19 @@ def test_radius(dtype, device): |
44 | 49 | assert to_set(edge_index) == set([(0, 0), (0, 1), (0, 2), (0, 3), (1, 1), |
45 | 50 | (1, 2), (1, 5), (1, 6)]) |
46 | 51 |
|
47 | | - jit = torch.compile(radius) |
48 | | - edge_index = jit(x, y, 2, max_num_neighbors=4) |
49 | | - assert to_set(edge_index) == set([(0, 0), (0, 1), (0, 2), (0, 3), (1, 1), |
50 | | - (1, 2), (1, 5), (1, 6)]) |
| 52 | + if has_compiler(): |
| 53 | + jit = torch.compile(radius) |
| 54 | + edge_index = jit(x, y, 2, max_num_neighbors=4) |
| 55 | + assert to_set(edge_index) == set([ |
| 56 | + (0, 0), |
| 57 | + (0, 1), |
| 58 | + (0, 2), |
| 59 | + (0, 3), |
| 60 | + (1, 1), |
| 61 | + (1, 2), |
| 62 | + (1, 5), |
| 63 | + (1, 6), |
| 64 | + ]) |
51 | 65 |
|
52 | 66 | edge_index = radius(x, y, 2, batch_x, batch_y, max_num_neighbors=4) |
53 | 67 | assert to_set(edge_index) == set([(0, 0), (0, 1), (0, 2), (0, 3), (1, 5), |
@@ -78,10 +92,19 @@ def test_radius_graph(dtype, device): |
78 | 92 | assert to_set(edge_index) == set([(1, 0), (3, 0), (0, 1), (2, 1), (1, 2), |
79 | 93 | (3, 2), (0, 3), (2, 3)]) |
80 | 94 |
|
81 | | - jit = torch.compile(radius_graph) |
82 | | - edge_index = jit(x, r=2.5, flow='source_to_target') |
83 | | - assert to_set(edge_index) == set([(1, 0), (3, 0), (0, 1), (2, 1), (1, 2), |
84 | | - (3, 2), (0, 3), (2, 3)]) |
| 95 | + if has_compiler(): |
| 96 | + jit = torch.compile(radius_graph) |
| 97 | + edge_index = jit(x, r=2.5, flow='source_to_target') |
| 98 | + assert to_set(edge_index) == set([ |
| 99 | + (1, 0), |
| 100 | + (3, 0), |
| 101 | + (0, 1), |
| 102 | + (2, 1), |
| 103 | + (1, 2), |
| 104 | + (3, 2), |
| 105 | + (0, 3), |
| 106 | + (2, 3), |
| 107 | + ]) |
85 | 108 |
|
86 | 109 | edge_index = radius_graph(x, r=100, flow='source_to_target', |
87 | 110 | max_num_neighbors=1) |
|
0 commit comments