Skip to content

Commit c62c324

Browse files
authored
Merge pull request #2615 from saitcakmak/cleanup_deprecated_tensor
Remove deprecated lazy tensor
2 parents bb86550 + 96bd347 commit c62c324

File tree

5 files changed

+16
-287
lines changed

5 files changed

+16
-287
lines changed

gpytorch/__init__.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
variational,
2525
)
2626
from .functions import inv_matmul, log_normal_cdf, logdet, matmul # Deprecated
27-
from .lazy import cat, delazify, lazify
2827
from .mlls import ExactMarginalLogLikelihood
2928
from .module import Module
3029

@@ -116,7 +115,10 @@ def inv_quad(input: Anysor, inv_quad_rhs: Tensor, reduce_inv_quad: bool = True)
116115

117116

118117
def inv_quad_logdet(
119-
input: Anysor, inv_quad_rhs: Optional[Tensor] = None, logdet: bool = False, reduce_inv_quad: bool = True
118+
input: Anysor,
119+
inv_quad_rhs: Optional[Tensor] = None,
120+
logdet: bool = False,
121+
reduce_inv_quad: bool = True,
120122
) -> Tuple[Tensor, Tensor]:
121123
r"""
122124
Calls both :func:`inv_quad_logdet` and :func:`logdet` on a positive definite matrix (or batch) :math:`\mathbf A`.
@@ -133,12 +135,18 @@ def inv_quad_logdet(
133135
If `reduce_inv_quad=True`, the inverse quadratic term is of shape (...). Otherwise, it is (... x M).
134136
"""
135137
return linear_operator.inv_quad_logdet(
136-
input=input, inv_quad_rhs=inv_quad_rhs, logdet=logdet, reduce_inv_quad=reduce_inv_quad
138+
input=input,
139+
inv_quad_rhs=inv_quad_rhs,
140+
logdet=logdet,
141+
reduce_inv_quad=reduce_inv_quad,
137142
)
138143

139144

140145
def pivoted_cholesky(
141-
input: Anysor, rank: int, error_tol: Optional[float] = None, return_pivots: bool = False
146+
input: Anysor,
147+
rank: int,
148+
error_tol: Optional[float] = None,
149+
return_pivots: bool = False,
142150
) -> Union[Tensor, Tuple[Tensor, Tensor]]:
143151
r"""
144152
Performs a partial pivoted Cholesky factorization of a positive definite matrix (or batch of matrices).
@@ -201,7 +209,10 @@ def root_inv_decomposition(
201209
:return: A tensor :math:`\mathbf R` such that :math:`\mathbf R \mathbf R^\top \approx \mathbf A^{-1}`.
202210
"""
203211
return linear_operator.root_inv_decomposition(
204-
input=input, initial_vectors=initial_vectors, test_vectors=test_vectors, method=method
212+
input=input,
213+
initial_vectors=initial_vectors,
214+
test_vectors=test_vectors,
215+
method=method,
205216
)
206217

207218

@@ -307,11 +318,7 @@ def sqrt_inv_matmul(input: Anysor, rhs: Tensor, lhs: Optional[Tensor] = None) ->
307318
# Other
308319
"__version__",
309320
# Deprecated
310-
"add_diag",
311-
"cat",
312-
"delazify",
313321
"inv_matmul",
314-
"lazify",
315322
"logdet",
316323
"log_normal_cdf",
317324
"matmul",

gpytorch/lazy/__init__.py

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,84 +2,8 @@
22

33
from __future__ import annotations
44

5-
import warnings
6-
from typing import Any, Optional, Tuple, Union
7-
8-
import torch
9-
from linear_operator import LinearOperator, operators
10-
from linear_operator.operators.cat_linear_operator import cat as _cat
11-
125
from .lazy_evaluated_kernel_tensor import LazyEvaluatedKernelTensor
13-
from .lazy_tensor import delazify, deprecated_lazy_tensor
14-
from .non_lazy_tensor import lazify
15-
16-
# We will dynamically import LazyTensor/NonLazyTensor to trigger DeprecationWarnings
17-
18-
19-
_deprecated_lazy_tensors = {
20-
"AddedDiagLazyTensor": deprecated_lazy_tensor(operators.AddedDiagLinearOperator),
21-
"BatchRepeatLazyTensor": deprecated_lazy_tensor(operators.BatchRepeatLinearOperator),
22-
"BlockDiagLazyTensor": deprecated_lazy_tensor(operators.BlockDiagLinearOperator),
23-
"BlockInterleavedLazyTensor": deprecated_lazy_tensor(operators.BlockInterleavedLinearOperator),
24-
"BlockLazyTensor": deprecated_lazy_tensor(operators.BlockLinearOperator),
25-
"CatLazyTensor": deprecated_lazy_tensor(operators.CatLinearOperator),
26-
"CholLazyTensor": deprecated_lazy_tensor(operators.CholLinearOperator),
27-
"ConstantMulLazyTensor": deprecated_lazy_tensor(operators.ConstantMulLinearOperator),
28-
"ConstantDiagLazyTensor": deprecated_lazy_tensor(operators.ConstantDiagLinearOperator),
29-
"DiagLazyTensor": deprecated_lazy_tensor(operators.DiagLinearOperator),
30-
"IdentityLazyTensor": deprecated_lazy_tensor(operators.IdentityLinearOperator),
31-
"InterpolatedLazyTensor": deprecated_lazy_tensor(operators.InterpolatedLinearOperator),
32-
"KeOpsLazyTensor": deprecated_lazy_tensor(operators.KeOpsLinearOperator),
33-
"KroneckerProductAddedDiagLazyTensor": deprecated_lazy_tensor(operators.KroneckerProductAddedDiagLinearOperator),
34-
"KroneckerProductDiagLazyTensor": deprecated_lazy_tensor(operators.KroneckerProductDiagLinearOperator),
35-
"KroneckerProductLazyTensor": deprecated_lazy_tensor(operators.KroneckerProductLinearOperator),
36-
"KroneckerProductTriangularLazyTensor": deprecated_lazy_tensor(operators.KroneckerProductTriangularLinearOperator),
37-
"LowRankRootAddedDiagLazyTensor": deprecated_lazy_tensor(operators.LowRankRootAddedDiagLinearOperator),
38-
"LowRankRootLazyTensor": deprecated_lazy_tensor(operators.LowRankRootLinearOperator),
39-
"MatmulLazyTensor": deprecated_lazy_tensor(operators.MatmulLinearOperator),
40-
"MulLazyTensor": deprecated_lazy_tensor(operators.MulLinearOperator),
41-
"PsdSumLazyTensor": deprecated_lazy_tensor(operators.PsdSumLinearOperator),
42-
"RootLazyTensor": deprecated_lazy_tensor(operators.RootLinearOperator),
43-
"SumBatchLazyTensor": deprecated_lazy_tensor(operators.SumBatchLinearOperator),
44-
"SumKroneckerLazyTensor": deprecated_lazy_tensor(operators.SumKroneckerLinearOperator),
45-
"SumLazyTensor": deprecated_lazy_tensor(operators.SumLinearOperator),
46-
"ToeplitzLazyTensor": deprecated_lazy_tensor(operators.ToeplitzLinearOperator),
47-
"TriangularLazyTensor": deprecated_lazy_tensor(operators.TriangularLinearOperator),
48-
"ZeroLazyTensor": deprecated_lazy_tensor(operators.ZeroLinearOperator),
49-
}
50-
51-
52-
def cat(
53-
inputs: Tuple[Union[LinearOperator, torch.Tensor], ...], dim: int = 0, output_device: Optional[torch.device] = None
54-
) -> Union[torch.Tensor, LinearOperator]:
55-
warnings.warn("gpytorch.lazy.cat is deprecated in favor of linear_operator.cat")
56-
return _cat(inputs, dim=dim, output_device=output_device)
57-
586

597
__all__ = [
60-
"delazify",
61-
"lazify",
62-
"cat",
638
"LazyEvaluatedKernelTensor",
64-
"LazyTensor",
659
]
66-
67-
68-
def __getattr__(name: str) -> Any:
69-
if not name.startswith("_"):
70-
warnings.warn(
71-
"GPyTorch will be replacing all LazyTensor functionality with the linear operator package. "
72-
"Replace all references to gpytorch.lazy.*LazyTensor with linear_operator.operators.*LinearOperator.",
73-
DeprecationWarning,
74-
)
75-
if name == "LazyTensor":
76-
from .lazy_tensor import LazyTensor
77-
78-
return deprecated_lazy_tensor(LazyTensor)
79-
elif name == "NonLazyTensor":
80-
from .non_lazy_tensor import NonLazyTensor
81-
82-
return deprecated_lazy_tensor(NonLazyTensor)
83-
elif name in _deprecated_lazy_tensors:
84-
return _deprecated_lazy_tensors[name]
85-
raise AttributeError(f"module gpytorch.lazy has no attribute {name}")

gpytorch/lazy/lazy_tensor.py

Lines changed: 0 additions & 82 deletions
This file was deleted.

gpytorch/lazy/non_lazy_tensor.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

test/lazy/test_lazy_tensor_deprecation.py

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)