Revert D32599540: [pytorch][PR] implemented 'torch.distributions.constraints.symmetric' checking if the tensor is symmetric at last 2 dimension.
Test Plan: revert-hammer
Differential Revision:
D32599540 (https://github.com/pytorch/pytorch/commit/bc3bdbc8f48ff42238feb949fd7812b0a20bc329)
Original commit changeset: 9227f7e99318
fbshipit-source-id: edfe7072073d910a49be52e1b8c2d374ef71e9ec
diff --git a/test/distributions/test_constraints.py b/test/distributions/test_constraints.py
index f1fc35a..6c6e392 100644
--- a/test/distributions/test_constraints.py
+++ b/test/distributions/test_constraints.py
@@ -7,13 +7,6 @@
from torch.testing._internal.common_cuda import TEST_CUDA
-EXAMPLES = [
- (constraints.symmetric, False, [[2., 0], [2., 2]]),
- (constraints.positive_definite, True, [[2., 0], [2., 2]]),
- (constraints.symmetric, True, [[3., -5], [-5., 3]]),
- (constraints.positive_definite, False, [[3., -5], [-5., 3]]),
-]
-
CONSTRAINTS = [
(constraints.real,),
(constraints.real_vector,),
@@ -48,15 +41,6 @@
t = torch.cuda.DoubleTensor if is_cuda else torch.DoubleTensor
return constraint_fn(*(t(x) if isinstance(x, list) else x for x in args))
-@pytest.mark.parametrize('constraint_fn, result, value', EXAMPLES)
-@pytest.mark.parametrize('is_cuda', [False,
- pytest.param(True, marks=pytest.mark.skipif(not TEST_CUDA,
- reason='CUDA not found.'))])
-def test_constraint(constraint_fn, result, value, is_cuda):
- t = torch.cuda.DoubleTensor if is_cuda else torch.DoubleTensor
- assert constraint_fn.check(t(value)).all() == result, \
- "Error in checking postive example of {}".format(constraint_fn)
-
@pytest.mark.parametrize('constraint_fn, args', [(c[0], c[1:]) for c in CONSTRAINTS])
@pytest.mark.parametrize('is_cuda', [False,
diff --git a/torch/distributions/constraints.py b/torch/distributions/constraints.py
index 3acf04a..5eed19a 100644
--- a/torch/distributions/constraints.py
+++ b/torch/distributions/constraints.py
@@ -22,7 +22,6 @@
- ``constraints.real_vector``
- ``constraints.real``
- ``constraints.simplex``
-- ``constraints.symmetric``
- ``constraints.stack``
- ``constraints.unit_interval``
"""
@@ -55,7 +54,6 @@
'real_vector',
'simplex',
'stack',
- 'symmetric',
'unit_interval',
]
@@ -458,16 +456,6 @@
return _LowerCholesky().check(value) & unit_row_norm
-class _Symmetric(Constraint):
- """
- Constrain to Symmetric square matrices.
- """
- event_dim = 2
-
- def check(self, value):
- return (value.transpose(-2, -1) == value).all(dim=-1).all(dim=-1)
-
-
class _PositiveDefinite(Constraint):
"""
Constrain to positive-definite matrices.
@@ -569,7 +557,6 @@
lower_triangular = _LowerTriangular()
lower_cholesky = _LowerCholesky()
corr_cholesky = _CorrCholesky()
-symmetric = _Symmetric()
positive_definite = _PositiveDefinite()
cat = _Cat
stack = _Stack