cornellius-gp / gpytorch

A highly efficient implementation of Gaussian Processes in PyTorch
MIT License
3.56k stars 559 forks source link

Add input validation to LazyTensor constructors and methods #275

Open Balandat opened 6 years ago

Balandat commented 6 years ago

Currently, incompatibilities in shape, device or dtype between LazyTensors can be very hard to debug, since they manifest at evaluation time deep inside the code, multiple levels deep.

Let's add validation of these to all the LazyTensor constructors and/or methods. For instance, in the MatmulLazyTensor constructor we'd validate that both args have the same device and dtype, and that their shapes are compatible for matrix multiplication: https://github.com/cornellius-gp/gpytorch/blob/master/gpytorch/lazy/matmul_lazy_tensor.py#L20 Similarly, we'd check this compatibility in the _matmul method here: https://github.com/cornellius-gp/gpytorch/blob/master/gpytorch/lazy/matmul_lazy_tensor.py#L42

eytan commented 6 years ago

There are many other places for validation too, including active_dims for the RBFKernel().