未验证 提交 6d490cc4 编写于 作者: G Guanghua Yu 提交者: GitHub

lazy import smac (#1361)

上级 43a25b63
......@@ -35,7 +35,7 @@ try:
except Exception as e:
_logger.warning(e)
_logger.warning(
f"If you want to use training-aware and post-training quantization, "
"please use Paddle >= {min_paddle_version} or develop version")
"If you want to use training-aware and post-training quantization, "
"please use Paddle >= {} or develop version".format(min_paddle_version))
from .quant_embedding import quant_embedding
......@@ -29,13 +29,7 @@ import shutil
import glob
from scipy.stats import wasserstein_distance
# smac
from ConfigSpace.hyperparameters import CategoricalHyperparameter, \
UniformFloatHyperparameter, UniformIntegerHyperparameter
from smac.configspace import ConfigurationSpace
from smac.facade.smac_hpo_facade import SMAC4HPO
from smac.scenario.scenario import Scenario
import pkg_resources as pkg
from paddleslim.common import get_logger
from paddleslim.quant import quant_post
......@@ -417,6 +411,18 @@ def quant_post_hpo(
None
"""
try:
pkg.require('smac')
except:
from pip._internal import main
main(['install', 'smac'])
# smac
from ConfigSpace.hyperparameters import CategoricalHyperparameter, \
UniformFloatHyperparameter, UniformIntegerHyperparameter
from smac.configspace import ConfigurationSpace
from smac.facade.smac_hpo_facade import SMAC4HPO
from smac.scenario.scenario import Scenario
global g_quant_config
g_quant_config = QuantConfig(
executor, place, model_dir, quantize_model_path, algo, hist_percent,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册