mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
move no_deadline to hypothesis_utils.py (#25598)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/25598 att Test Plan: CI Imported from OSS Differential Revision: D17192467 fbshipit-source-id: 9ee93b02cc293bb71ed114534d92eedda3ddee88
This commit is contained in:
committed by
Facebook Github Bot
parent
80820b2610
commit
76b6b1b1a6
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
'''
|
||||
|
Reference in New Issue
Block a user