Repository: pyg-team/pytorch_geometric
Pull request #9396 (2024-06-06 02:23:32)

Unit tests using `@onlyXPU` should only run on XPU devices
This PR ensure that unit tests annotated with @onlyXPU are only executed on XPU devices.  

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/pyg-team/pytorch_geometric/pull/9396?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyg-team) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 86.86%. Comparing base [(`476e768`)](https://app.codecov.io/gh/pyg-team/pytorch_geometric/commit/476e768593d91c1622b02440e25bbc93fc7f5294?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyg-team) to head [(`d7889cb`)](https://app.codecov.io/gh/pyg-team/pytorch_geometric/commit/d7889cb992d83d8907b02296775cdde4a414c80a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyg-team).
> Report is 3 commits behind head on master.


<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #9396      +/-   ##
==========================================
- Coverage   87.99%   86.86%   -1.14%     
==========================================
  Files         473      462      -11     
  Lines       30820    30503     -317     
==========================================
- Hits        27120    26496     -624     
- Misses       3700     4007     +307     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/pyg-team/pytorch_geometric/pull/9396?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyg-team).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyg-team).


Patch:
diff --git a/torch_geometric/nn/norm/batch_norm.py b/torch_geometric/nn/norm/batch_norm.py
index 2fcc6e6ce..3830f5499 100644
--- a/torch_geometric/nn/norm/batch_norm.py
+++ b/torch_geometric/nn/norm/batch_norm.py
@@ -88,7 +88,7 @@ class BatchNorm(torch.nn.Module):
         return self.module(x)
 
     def __repr__(self):
-        return f'{self.__class__.__name__}({self.module.num_features})'
+        return f'{self.__class__.__name__}({self.module.extra_repr()})'
 
 
 class HeteroBatchNorm(torch.nn.Module):


Test patch:
diff --git a/test/nn/norm/test_batch_norm.py b/test/nn/norm/test_batch_norm.py
index 9846bc8f4..c548c0fa6 100644
--- a/test/nn/norm/test_batch_norm.py
+++ b/test/nn/norm/test_batch_norm.py
@@ -13,7 +13,8 @@ def test_batch_norm(device, conf):
     norm = BatchNorm(16, affine=conf, track_running_stats=conf).to(device)
     norm.reset_running_stats()
     norm.reset_parameters()
-    assert str(norm) == 'BatchNorm(16)'
+    assert str(norm) == (f'BatchNorm(16, eps=1e-05, momentum=0.1, '
+                         f'affine={conf}, track_running_stats={conf})')
 
     if is_full_test():
         torch.jit.script(norm)
diff --git a/test/profile/test_profile.py b/test/profile/test_profile.py
index d6245f2d7..082afb315 100644
--- a/test/profile/test_profile.py
+++ b/test/profile/test_profile.py
@@ -92,9 +92,10 @@ def test_profileit_xpu(get_dataset):
     warnings.filterwarnings('ignore', '.*arguments of DataFrame.drop.*')
 
     dataset = get_dataset(name='Cora')
-    data = dataset[0].cuda()
+    device = torch.device('xpu')
+    data = dataset[0].to(device)
     model = GraphSAGE(dataset.num_features, hidden_channels=64, num_layers=3,
-                      out_channels=dataset.num_classes).cuda()
+                      out_channels=dataset.num_classes).to(device)
     optimizer = torch.optim.Adam(model.parameters(), lr=0.01)
 
     @profileit('xpu')