diff --git a/paddleslim/auto_compression/compressor.py b/paddleslim/auto_compression/compressor.py index 5aaff9bbe9a092d646947b6e0a52d02e4371823b..146cb2d6d4caad515a7670c5dcff3388bad94ebb 100644 --- a/paddleslim/auto_compression/compressor.py +++ b/paddleslim/auto_compression/compressor.py @@ -18,9 +18,11 @@ import sys import numpy as np import inspect from collections import namedtuple, Iterable +import platform import paddle import paddle.distributed.fleet as fleet -from ..quant.quant_post_hpo import quant_post_hpo +if platform.system().lower() == 'linux': + from ..quant.quant_post_hpo import quant_post_hpo from ..quant.quanter import convert from ..common.recover_program import recover_inference_program from ..common import get_logger @@ -231,6 +233,10 @@ class AutoCompression: def compress(self): ### start compress, including train/eval model if self._strategy == 'ptq_hpo': + if platform.system().lower() != 'linux': + raise NotImplementedError( + "post-quant-hpo is not support in system other than linux") + quant_post_hpo( self._exe, self._places, diff --git a/paddleslim/quant/__init__.py b/paddleslim/quant/__init__.py index 134165b3de6998b4bab01ecf2a4dfae1b2587da8..808a9abc8faed2aacaa664187bf0e0fe3b19438a 100644 --- a/paddleslim/quant/__init__.py +++ b/paddleslim/quant/__init__.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import platform import logging import paddle @@ -32,7 +33,12 @@ try: from .quanter import quant_aware, convert, quant_post_static, quant_post_dynamic from .quanter import quant_post, quant_post_only_weight from .quant_aware_with_infermodel import quant_aware_with_infermodel, export_quant_infermodel - from .quant_post_hpo import quant_post_hpo + if platform.system().lower() == 'linux': + from .quant_post_hpo import quant_post_hpo + else: + _logger.warning( + "post-quant-hpo is not support in system other than linux") + except Exception as e: _logger.warning(e) _logger.warning( diff --git a/requirements.txt b/requirements.txt index 155422f3dea5e13b533a872dbcea9d9c030c0bf4..f576bf879a835c47fc0b93e0c7d8d77b6181233e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,4 @@ pillow pyyaml scikit-learn smac -paddleslim-opt-tools \ No newline at end of file +paddleslim-opt-tools