Repository: geomstats/geomstats

Issue:
Bug: In-place operation in pytorch backend
### Describe the bug

In SPDBuresWassersteinMetric.parallel_transport (line 921), in-place operation happens, which is not supported by torch autograd
`partial_horizontal_velocity += Matrices.transpose(partial_horizontal_velocity)`

### Steps/Code to Reproduce

In SPDBuresWassersteinMetric.parallel_transport (line 921), in-place operation happens, which is not supported by torch autograd
`partial_horizontal_velocity += Matrices.transpose(partial_horizontal_velocity)`

### Expected Behaviour

partial_horizontal_velocity = partial_horizontal_velocity + Matrices.transpose(partial_horizontal_velocity)

### Actual Behaviour

partial_horizontal_velocity += Matrices.transpose(partial_horizontal_velocity)
RuntimeError: unsupported operation: some elements of the input tensor and the written-to tensor refer to a single memory location. Please clone() the tensor before performing the operation.

### Your environment

```shell
Geomstats -master
```


Discussion:

Patch:
diff --git a/geomstats/geometry/spd_matrices.py b/geomstats/geometry/spd_matrices.py
index f6b718b05..8e07926b0 100644
--- a/geomstats/geometry/spd_matrices.py
+++ b/geomstats/geometry/spd_matrices.py
@@ -918,7 +918,9 @@ class SPDBuresWassersteinMetric(RiemannianMetric):
 
         horizontal_velocity = gs.matmul(inverse_square_root_bp, square_root_lift)
         partial_horizontal_velocity = Matrices.mul(horizontal_velocity, square_root_bp)
-        partial_horizontal_velocity += Matrices.transpose(partial_horizontal_velocity)
+        partial_horizontal_velocity = partial_horizontal_velocity + Matrices.transpose(
+            partial_horizontal_velocity
+        )
 
         def force(state, time):
             horizontal_geodesic_t = (


Test patch:
diff --git a/tests/tests_geomstats/test_spd_matrices.py b/tests/tests_geomstats/test_spd_matrices.py
index 08d10c5e9..38044de49 100644
--- a/tests/tests_geomstats/test_spd_matrices.py
+++ b/tests/tests_geomstats/test_spd_matrices.py
@@ -140,7 +140,6 @@ class TestSPDBuresWassersteinMetric(RiemannianMetricTestCase, metaclass=Parametr
         result = space.metric.log(point, base_point)
         self.assertAllClose(result, expected)
 
-    @tests.conftest.np_and_autograd_only
     def test_parallel_transport(self, space):
         space.equip_with_metric(self.Metric)
         n = space.n