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

fix act logger (#1158)

上级 2952d4ce
......@@ -18,8 +18,6 @@ import sys
import numpy as np
import inspect
import shutil
from collections import namedtuple
from collections.abc import Iterable
from time import gmtime, strftime
import platform
import paddle
......@@ -392,7 +390,7 @@ class AutoCompression:
shutil.move(tmp_params_file, final_params_file)
shutil.rmtree(self.tmp_dir)
_logger.info(
"==> Finished the ACT process and the final model is saved in:{}".
"==> The ACT compression has been completed and the final model is saved in `{}`".
format(final_model_path))
os._exit(0)
......
......@@ -38,6 +38,8 @@ from smac.scenario.scenario import Scenario
from paddleslim.common import get_logger
from paddleslim.quant import quant_post
_logger = get_logger(__name__, level=logging.INFO)
SMAC_TMP_FILE_PATTERN = "smac3-output*"
......@@ -53,7 +55,7 @@ def remove(path):
os.remove(p)
class QuantConfig:
class QuantConfig(object):
"""quant config"""
def __init__(self,
......@@ -252,7 +254,7 @@ def eval_quant_model():
emd_sum = cal_emd_lose(out_float_list, out_quant_list,
out_len_sum / float(valid_data_num))
print("output diff:", emd_sum)
_logger.info("output diff: {}".format(emd_sum))
return float(emd_sum)
......@@ -323,7 +325,7 @@ def quantize(cfg):
emd_loss = float(abs(float_metric - quant_metric)) / float_metric
print("emd loss: ", emd_loss)
_logger.info("emd loss: {}".format(emd_loss))
if emd_loss < g_min_emd_loss:
g_min_emd_loss = emd_loss
if os.path.exists(g_quant_config.quantize_model_path):
......@@ -510,7 +512,7 @@ def quant_post_hpo(
# Example call of the function with default values
# It returns: Status, Cost, Runtime, Additional Infos
def_value = smac.get_tae_runner().run(cs.get_default_configuration(), 1)[1]
print("Value for default configuration: %.8f" % def_value)
_logger.info("Value for default configuration: %.8f" % def_value)
# Start optimization
try:
......@@ -519,7 +521,7 @@ def quant_post_hpo(
incumbent = smac.solver.incumbent
inc_value = smac.get_tae_runner().run(incumbent, 1)[1]
print("Optimized Value: %.8f" % inc_value)
_logger.info("Optimized Value: %.8f" % inc_value)
shutil.rmtree(g_quant_model_cache_path)
remove(SMAC_TMP_FILE_PATTERN)
print("quantize completed")
_logger.info("Quantization completed.")
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册