gpytorch
gpytorch copied to clipboard
slight improvements to IndexKernel for the rank == 0 (diagonal) case
This PR tweaks IndexKernel to have slightly better performance/behavior in the corner case of rank == 0, where the underlying covariance matrix is diagonal. Although this case is atypical from the point of view of multitask GPs, I have found this construction useful as a component of larger covariance structures.
Two changes are proposed:
- the kernel only registers the
covar_factorparameter (the low-rank component whenrank > 0) whenrank > 0 - in the
rank == 0case, thecovar_matrix()method returns aDiagLinearOpeatorrather than aPsdSumLinearOperator(RootLinearOperator, DiagLinearOperator)
I've added a branch to _eval_covar_matrix() to handle the diagonal case to partially address @Balandat's comments.
I guess I would still like to see this covered by a unit test though :)