Skip to content

Commit f62de39

Browse files
committed
bug fix for 1d case
1 parent 8d272de commit f62de39

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

gpytorch/kernels/matern52_kernel_grad.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ def forward(self, x1, x2, diag=False, **params):
118118
part3 = 1 + sqrt5 * distance_matrix
119119

120120
K[..., n1:, n2:] = part1.repeat([*([1] * n_batch_dims), d, d]).mul_(
121-
part2.sub_(kp.to_dense().mul_(part3.repeat([*([1] * n_batch_dims), d, d])))
121+
# need to use kp.to_dense().mul instead of kp.to_dense().mul_
122+
# because otherwise a RuntimeError is raised due to how autograd works with
123+
# view + inplace operations in the case of 1-dimensional input
124+
part2.sub_(kp.to_dense().mul(part3.repeat([*([1] * n_batch_dims), d, d])))
122125
)
123126

124127
# Symmetrize for stability

0 commit comments

Comments
 (0)