def f(r, y): PD = r.dot(r.T) L = gpu_cholesky(PD) A = gpu_solve_lower_triangular(L, y) AAT = theano.tensor.dot(A, A.T) B = AAT + theano.tensor.eye(N) LB = gpu_cholesky(B) return theano.tensor.sum(theano.tensor.log(theano.tensor.diag(LB)))