Repository: cornellius-gp/gpytorch
Pull request #906 (2019-10-16 18:59:31)

Interpolated lazy tensor size fix
Interpolated lazy tensor size fix for #900 and #904 


Patch:
diff --git a/gpytorch/lazy/interpolated_lazy_tensor.py b/gpytorch/lazy/interpolated_lazy_tensor.py
index e68e16d5..9430a42e 100644
--- a/gpytorch/lazy/interpolated_lazy_tensor.py
+++ b/gpytorch/lazy/interpolated_lazy_tensor.py
@@ -56,10 +56,10 @@ class InterpolatedLazyTensor(LazyTensor):
             )
 
         if right_interp_indices is None:
-            num_rows = base_lazy_tensor.size(-2)
-            right_interp_indices = torch.arange(0, num_rows, dtype=torch.long, device=base_lazy_tensor.device)
+            num_cols = base_lazy_tensor.size(-1)
+            right_interp_indices = torch.arange(0, num_cols, dtype=torch.long, device=base_lazy_tensor.device)
             right_interp_indices.unsqueeze_(-1)
-            right_interp_indices = right_interp_indices.expand(*base_lazy_tensor.batch_shape, num_rows, 1)
+            right_interp_indices = right_interp_indices.expand(*base_lazy_tensor.batch_shape, num_cols, 1)
 
         if right_interp_values is None:
             right_interp_values = torch.ones(
@@ -308,7 +308,7 @@ class InterpolatedLazyTensor(LazyTensor):
                 return self._sparse_left_interp_t_memo
 
         left_interp_t = sparse.make_sparse_from_indices_and_values(
-            left_interp_indices_tensor, left_interp_values_tensor, self.base_lazy_tensor.size()[-1]
+            left_interp_indices_tensor, left_interp_values_tensor, self.base_lazy_tensor.size()[-2]
         )
         self._left_interp_indices_memo = left_interp_indices_tensor
         self._left_interp_values_memo = left_interp_values_tensor


Test patch:
diff --git a/test/lazy/test_interpolated_lazy_tensor.py b/test/lazy/test_interpolated_lazy_tensor.py
index 20671f04..6a972dbd 100644
--- a/test/lazy/test_interpolated_lazy_tensor.py
+++ b/test/lazy/test_interpolated_lazy_tensor.py
@@ -139,5 +139,36 @@ class TestInterpolatedLazyTensorMultiBatch(LazyTensorTestCase, unittest.TestCase
         return actual
 
 
+def empty_method(self):
+    pass
+
+
+class TestInterpolatedLazyTensorRectangular(LazyTensorTestCase, unittest.TestCase):
+    def create_lazy_tensor(self):
+        itplzt = InterpolatedLazyTensor(NonLazyTensor(torch.rand(3, 4)))
+        return itplzt
+
+    def evaluate_lazy_tensor(self, lazy_tensor):
+        return lazy_tensor.base_lazy_tensor.tensor
+
+    # Disable tests meant for square matrices
+    test_add_diag = empty_method
+    test_diag = empty_method
+    test_inv_matmul_matrix = empty_method
+    test_inv_matmul_matrix_broadcast = empty_method
+    test_inv_matmul_matrix_cholesky = empty_method
+    test_inv_matmul_matrix_with_left = empty_method
+    test_inv_matmul_vector = empty_method
+    test_inv_matmul_vector_with_left = empty_method
+    test_inv_matmul_vector_with_left_cholesky = empty_method
+    test_inv_quad_logdet = empty_method
+    test_inv_quad_logdet_no_reduce = empty_method
+    test_inv_quad_logdet_no_reduce_cholesky = empty_method
+    test_quad_form_derivative = empty_method
+    test_root_decomposition = empty_method
+    test_root_decomposition_cholesky = empty_method
+    test_root_inv_decomposition = empty_method
+
+
 if __name__ == "__main__":
     unittest.main()