diff --git a/test/common_quantization.py b/test/common_quantization.py index a07d49e00af6..3b1827c01534 100644 --- a/test/common_quantization.py +++ b/test/common_quantization.py @@ -7,7 +7,6 @@ r"""Importing this file includes common utility methods and base clases for checking quantization api and properties of resulting modules. """ -import hypothesis import io import torch import torch.nn as nn @@ -18,15 +17,6 @@ from torch.quantization import QuantWrapper, QuantStub, DeQuantStub, \ default_qconfig, QConfig, default_observer, default_weight_observer, \ default_qat_qconfig, propagate_qconfig, convert, DEFAULT_DYNAMIC_MODULE_MAPPING - -# Disable deadline testing if this version of hypthesis supports it, otherwise -# just return the original function -def no_deadline(fn): - try: - return hypothesis.settings(deadline=None)(fn) - except hypothesis.errors.InvalidArgument: - return fn - def test_only_eval_fn(model, calib_data): r""" Default evaluation function takes a torch.utils.data.Dataset or a list of diff --git a/test/hypothesis_utils.py b/test/hypothesis_utils.py index bb83fb20dcc8..ec0dc604f9e5 100644 --- a/test/hypothesis_utils.py +++ b/test/hypothesis_utils.py @@ -2,6 +2,7 @@ from collections import defaultdict import numpy as np import torch +import hypothesis from hypothesis import assume from hypothesis import strategies as st from hypothesis.extra import numpy as stnp @@ -250,3 +251,12 @@ def tensor_conv2d(draw, b = draw(tensor(shapes=(_out_channels,), elements=elements, qparams=qparams[2])) return X, w, b, g + + +# Disable deadline testing if this version of hypthesis supports it, otherwise +# just return the original function +def no_deadline(fn): + try: + return hypothesis.settings(deadline=None)(fn) + except hypothesis.errors.InvalidArgument: + return fn diff --git a/test/test_fake_quant.py b/test/test_fake_quant.py index 3fd411d20afa..1b7454e7edfc 100644 --- a/test/test_fake_quant.py +++ b/test/test_fake_quant.py @@ -6,7 +6,7 @@ import unittest from hypothesis import given from hypothesis import strategies as st import hypothesis_utils as hu -from common_quantization import no_deadline +from hypothesis_utils import no_deadline from common_utils import run_tests from torch.quantization import FakeQuantize diff --git a/test/test_qat.py b/test/test_qat.py index 9bff2b0f002a..1a0547971cb3 100644 --- a/test/test_qat.py +++ b/test/test_qat.py @@ -8,10 +8,10 @@ from torch.nn import Conv2d, BatchNorm2d, ReLU from torch.nn._intrinsic.qat import ConvBn2d, ConvBnReLU2d from torch.quantization.QConfig import default_qat_qconfig from torch.utils.mkldnn import disable_mkldnn_conv -from common_quantization import no_deadline from common_utils import TestCase, run_tests from hypothesis import given from hypothesis import strategies as st +from hypothesis_utils import no_deadline from functools import reduce diff --git a/test/test_quantized.py b/test/test_quantized.py index a88a3ec86a96..f080fd5a4e0c 100644 --- a/test/test_quantized.py +++ b/test/test_quantized.py @@ -9,10 +9,10 @@ from torch.nn.modules.utils import _pair from hypothesis import assume, given from hypothesis import strategies as st import hypothesis_utils as hu +from hypothesis_utils import no_deadline from common_utils import TEST_WITH_UBSAN, TestCase, run_tests, IS_WINDOWS, IS_PPC from common_quantized import _quantize, _dequantize, _calculate_dynamic_qparams -from common_quantization import no_deadline # Make sure we won't have overflows from vpmaddubsw instruction used in FBGEMM. # On the current Intel x86 architecture, we need to utilize vpmaddubsw instruction diff --git a/test/test_quantized_nn_mods.py b/test/test_quantized_nn_mods.py index b9c3e0e9bbf5..76d6f65e4abb 100644 --- a/test/test_quantized_nn_mods.py +++ b/test/test_quantized_nn_mods.py @@ -7,10 +7,11 @@ from torch.nn.quantized.modules import Conv2d from torch.nn._intrinsic.quantized import ConvReLU2d import torch.quantization from common_utils import run_tests, tempfile -from common_quantization import QuantizationTestCase, no_deadline, prepare_dynamic +from common_quantization import QuantizationTestCase, prepare_dynamic from common_quantized import _calculate_dynamic_qparams from hypothesis import given from hypothesis import strategies as st +from hypothesis_utils import no_deadline import unittest '''