Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
32af31fb
提交
32af31fb
authored
11月 23, 2023
作者:
lucianopaz
提交者:
Ricardo Vieira
11月 24, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Include conda Library bin and lib paths to default blas ldflags search dirs
上级
91d3b7c0
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
55 行增加
和
1 行删除
+55
-1
cmodule.py
pytensor/link/c/cmodule.py
+10
-1
test_cmodule.py
tests/link/c/test_cmodule.py
+45
-0
没有找到文件。
pytensor/link/c/cmodule.py
浏览文件 @
32af31fb
...
...
@@ -2744,7 +2744,9 @@ def default_blas_ldflags():
[
pathlib
.
Path
(
p
)
.
resolve
()
for
p
in
line
[
len
(
"libraries: ="
)
:]
.
split
(
":"
)]
for
line
in
stdout
.
decode
(
sys
.
stdout
.
encoding
)
.
splitlines
()
if
line
.
startswith
(
"libraries: ="
)
][
0
]
]
if
len
(
maybe_lib_dirs
)
>
0
:
maybe_lib_dirs
=
maybe_lib_dirs
[
0
]
return
[
str
(
d
)
for
d
in
maybe_lib_dirs
if
d
.
exists
()
and
d
.
is_dir
()]
def
check_libs
(
...
...
@@ -2793,6 +2795,13 @@ def default_blas_ldflags():
cxx_library_dirs
=
get_cxx_library_dirs
()
searched_library_dirs
=
cxx_library_dirs
+
_std_lib_dirs
if
sys
.
platform
==
"win32"
:
# Conda on Windows saves MKL libraries under CONDA_PREFIX\Library\bin
# From the conda manual (https://docs.conda.io/projects/conda-build/en/stable/user-guide/environment-variables.html)
# it seems like conda could also save some libraries into the CONDA_PREFIX\Library\lib
# directory. We will include both in our searched library dirs
searched_library_dirs
.
append
(
os
.
path
.
join
(
sys
.
prefix
,
"Library"
,
"bin"
))
searched_library_dirs
.
append
(
os
.
path
.
join
(
sys
.
prefix
,
"Library"
,
"lib"
))
all_libs
=
[
l
for
path
in
[
...
...
tests/link/c/test_cmodule.py
浏览文件 @
32af31fb
...
...
@@ -260,6 +260,51 @@ def test_default_blas_ldflags_no_cxx():
assert
default_blas_ldflags
()
==
""
@pytest.fixture
()
def
windows_conda_libs
(
blas_libs
):
libtemplate
=
"{lib}.dll"
libraries
=
[]
with
tempfile
.
TemporaryDirectory
()
as
d
:
subdir
=
os
.
path
.
join
(
d
,
"Library"
,
"bin"
)
os
.
makedirs
(
subdir
,
exist_ok
=
True
)
flags
=
f
'-L"{subdir}"'
for
lib
in
blas_libs
:
lib_path
=
os
.
path
.
join
(
subdir
,
libtemplate
.
format
(
lib
=
lib
))
with
open
(
lib_path
,
"wb"
)
as
f
:
f
.
write
(
b
"1"
)
libraries
.
append
(
lib_path
)
flags
+=
f
" -l{lib}"
if
"gomp"
in
blas_libs
and
"mkl_gnu_thread"
not
in
blas_libs
:
flags
+=
" -fopenmp"
if
len
(
blas_libs
)
==
0
:
flags
=
""
yield
d
,
flags
@patch
(
"pytensor.link.c.cmodule.std_lib_dirs"
,
return_value
=
[])
@patch
(
"pytensor.link.c.cmodule.check_mkl_openmp"
,
return_value
=
None
)
def
test_default_blas_ldflags_conda_windows
(
mock_std_lib_dirs
,
mock_check_mkl_openmp
,
windows_conda_libs
):
mock_sys_prefix
,
expected_blas_ldflags
=
windows_conda_libs
mock_process
=
MagicMock
()
mock_process
.
communicate
=
lambda
*
args
,
**
kwargs
:
(
b
""
,
b
""
)
mock_process
.
returncode
=
0
with
patch
(
"sys.platform"
,
"win32"
):
with
patch
(
"sys.prefix"
,
mock_sys_prefix
):
with
patch
(
"pytensor.link.c.cmodule.subprocess_Popen"
,
return_value
=
mock_process
):
with
patch
.
object
(
pytensor
.
link
.
c
.
cmodule
.
GCC_compiler
,
"try_compile_tmp"
,
return_value
=
(
True
,
True
),
):
assert
set
(
default_blas_ldflags
()
.
split
(
" "
))
==
set
(
expected_blas_ldflags
.
split
(
" "
)
)
@patch
(
"os.listdir"
,
return_value
=
[
"mkl_core.1.dll"
,
"mkl_rt.1.0.dll"
,
"mkl_rt.1.1.lib"
]
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论