Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
eb552eef
提交
eb552eef
authored
11月 20, 2023
作者:
lucianopaz
提交者:
Luciano Paz
11月 20, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add guardrails for cxx -print-search-dirs failure
上级
2bb847cf
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
43 行增加
和
5 行删除
+43
-5
cmodule.py
pytensor/link/c/cmodule.py
+9
-0
test_cmodule.py
tests/link/c/test_cmodule.py
+34
-5
没有找到文件。
pytensor/link/c/cmodule.py
浏览文件 @
eb552eef
...
@@ -2731,6 +2731,15 @@ def default_blas_ldflags():
...
@@ -2731,6 +2731,15 @@ def default_blas_ldflags():
shell
=
True
,
shell
=
True
,
)
)
(
stdout
,
stderr
)
=
p
.
communicate
(
input
=
b
""
)
(
stdout
,
stderr
)
=
p
.
communicate
(
input
=
b
""
)
if
p
.
returncode
!=
0
:
warnings
.
warn
(
"Pytensor cxx failed to communicate its search dirs. As a consequence, "
"it might not be possible to automatically determine the blas link flags to use.
\n
"
f
"Command that was run: {config.cxx} -print-search-dirs
\n
"
f
"Output printed to stderr: {stderr.decode(sys.stderr.encoding)}"
)
return
[]
maybe_lib_dirs
=
[
maybe_lib_dirs
=
[
[
pathlib
.
Path
(
p
)
.
resolve
()
for
p
in
line
[
len
(
"libraries: ="
)
:]
.
split
(
":"
)]
[
pathlib
.
Path
(
p
)
.
resolve
()
for
p
in
line
[
len
(
"libraries: ="
)
:]
.
split
(
":"
)]
for
line
in
stdout
.
decode
(
sys
.
stdout
.
encoding
)
.
splitlines
()
for
line
in
stdout
.
decode
(
sys
.
stdout
.
encoding
)
.
splitlines
()
...
...
tests/link/c/test_cmodule.py
浏览文件 @
eb552eef
...
@@ -6,6 +6,7 @@ deterministic based on the input type and the op.
...
@@ -6,6 +6,7 @@ deterministic based on the input type and the op.
"""
"""
import
multiprocessing
import
multiprocessing
import
os
import
os
import
re
import
sys
import
sys
import
tempfile
import
tempfile
from
unittest.mock
import
MagicMock
,
patch
from
unittest.mock
import
MagicMock
,
patch
...
@@ -207,23 +208,51 @@ def cxx_search_dirs(blas_libs, mock_system):
...
@@ -207,23 +208,51 @@ def cxx_search_dirs(blas_libs, mock_system):
yield
f
"libraries: ={d}"
.
encode
(
sys
.
stdout
.
encoding
),
flags
yield
f
"libraries: ={d}"
.
encode
(
sys
.
stdout
.
encoding
),
flags
@pytest.fixture
(
scope
=
"function"
,
params
=
[
False
,
True
],
ids
=
[
"Working_CXX"
,
"Broken_CXX"
]
)
def
cxx_search_dirs_status
(
request
):
return
request
.
param
@patch
(
"pytensor.link.c.cmodule.std_lib_dirs"
,
return_value
=
[])
@patch
(
"pytensor.link.c.cmodule.std_lib_dirs"
,
return_value
=
[])
@patch
(
"pytensor.link.c.cmodule.check_mkl_openmp"
,
return_value
=
None
)
@patch
(
"pytensor.link.c.cmodule.check_mkl_openmp"
,
return_value
=
None
)
def
test_default_blas_ldflags
(
def
test_default_blas_ldflags
(
mock_std_lib_dirs
,
mock_check_mkl_openmp
,
cxx_search_dirs
mock_std_lib_dirs
,
mock_check_mkl_openmp
,
cxx_search_dirs
,
cxx_search_dirs_status
):
):
cxx_search_dirs
,
expected_blas_ldflags
=
cxx_search_dirs
cxx_search_dirs
,
expected_blas_ldflags
=
cxx_search_dirs
mock_process
=
MagicMock
()
mock_process
=
MagicMock
()
mock_process
.
communicate
=
lambda
*
args
,
**
kwargs
:
(
cxx_search_dirs
,
None
)
if
cxx_search_dirs_status
:
error_message
=
""
mock_process
.
communicate
=
lambda
*
args
,
**
kwargs
:
(
cxx_search_dirs
,
b
""
)
mock_process
.
returncode
=
0
else
:
error_message
=
"Unsupported argument -print-search-dirs"
error_message_bytes
=
error_message
.
encode
(
sys
.
stderr
.
encoding
)
mock_process
.
communicate
=
lambda
*
args
,
**
kwargs
:
(
b
""
,
error_message_bytes
)
mock_process
.
returncode
=
1
with
patch
(
"pytensor.link.c.cmodule.subprocess_Popen"
,
return_value
=
mock_process
):
with
patch
(
"pytensor.link.c.cmodule.subprocess_Popen"
,
return_value
=
mock_process
):
with
patch
.
object
(
with
patch
.
object
(
pytensor
.
link
.
c
.
cmodule
.
GCC_compiler
,
pytensor
.
link
.
c
.
cmodule
.
GCC_compiler
,
"try_compile_tmp"
,
"try_compile_tmp"
,
return_value
=
(
True
,
True
),
return_value
=
(
True
,
True
),
):
):
assert
set
(
default_blas_ldflags
()
.
split
(
" "
))
==
set
(
if
cxx_search_dirs_status
:
expected_blas_ldflags
.
split
(
" "
)
assert
set
(
default_blas_ldflags
()
.
split
(
" "
))
==
set
(
)
expected_blas_ldflags
.
split
(
" "
)
)
else
:
expected_warning
=
re
.
escape
(
"Pytensor cxx failed to communicate its search dirs. As a consequence, "
"it might not be possible to automatically determine the blas link flags to use.
\n
"
f
"Command that was run: {config.cxx} -print-search-dirs
\n
"
f
"Output printed to stderr: {error_message}"
)
with
pytest
.
warns
(
UserWarning
,
match
=
expected_warning
,
):
assert
default_blas_ldflags
()
==
""
def
test_default_blas_ldflags_no_cxx
():
def
test_default_blas_ldflags_no_cxx
():
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论