提交 0d34af2e authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Fix mkl warning in default_blas_ldflags

上级 d660ea78
""" """
Test config options. Test config options.
""" """
import logging
from unittest.mock import patch
from theano.configdefaults import default_blas_ldflags
from theano.configparser import THEANO_FLAGS_DICT, AddConfigVar, ConfigParam from theano.configparser import THEANO_FLAGS_DICT, AddConfigVar, ConfigParam
class TestConfig: def test_invalid_default():
def test_invalid_default(self): # Ensure an invalid default value found in the Theano code only causes
# Ensure an invalid default value found in the Theano code only causes # a crash if it is not overridden by the user.
# a crash if it is not overridden by the user.
def filter(val):
def filter(val): if val == "invalid":
if val == "invalid": raise ValueError()
raise ValueError() else:
else: return val
return val
try:
try: # This should raise a ValueError because the default value is
# This should raise a ValueError because the default value is # invalid.
# invalid.
AddConfigVar(
"T_config.test_invalid_default_a",
doc="unittest",
configparam=ConfigParam("invalid", filter=filter),
in_c_key=False,
)
raise AssertionError()
except ValueError:
pass
THEANO_FLAGS_DICT["T_config.test_invalid_default_b"] = "ok"
# This should succeed since we defined a proper value, even
# though the default was invalid.
AddConfigVar( AddConfigVar(
"T_config.test_invalid_default_b", "T_config.test_invalid_default_a",
doc="unittest", doc="unittest",
configparam=ConfigParam("invalid", filter=filter), configparam=ConfigParam("invalid", filter=filter),
in_c_key=False, in_c_key=False,
) )
raise AssertionError()
except ValueError:
pass
THEANO_FLAGS_DICT["T_config.test_invalid_default_b"] = "ok"
# This should succeed since we defined a proper value, even
# though the default was invalid.
AddConfigVar(
"T_config.test_invalid_default_b",
doc="unittest",
configparam=ConfigParam("invalid", filter=filter),
in_c_key=False,
)
# Check that the flag has been removed
assert "T_config.test_invalid_default_b" not in THEANO_FLAGS_DICT
# TODO We should remove these dummy options on test exit.
@patch("theano.configdefaults.try_blas_flag", return_value=None)
@patch("theano.configdefaults.sys")
def test_default_blas_ldflags(sys_mock, try_blas_flag_mock, caplog):
sys_mock.version = "3.8.0 | packaged by conda-forge | (default, Nov 22 2019, 19:11:38) \n[GCC 7.3.0]"
# Check that the flag has been removed with patch.dict("sys.modules", {"mkl": None}):
assert "T_config.test_invalid_default_b" not in THEANO_FLAGS_DICT with caplog.at_level(logging.WARNING):
default_blas_ldflags()
# TODO We should remove these dummy options on test exit. assert "install mkl with" in caplog.text
...@@ -1835,7 +1835,7 @@ def default_blas_ldflags(): ...@@ -1835,7 +1835,7 @@ def default_blas_ldflags():
# the fallback and test -lblas could give slow computation, so # the fallback and test -lblas could give slow computation, so
# warn about this. # warn about this.
for warn in warn_record: for warn in warn_record:
_logger.warning(*warn) _logger.warning(warn)
del warn_record del warn_record
# Some environment don't have the lib dir in LD_LIBRARY_PATH. # Some environment don't have the lib dir in LD_LIBRARY_PATH.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论