Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
21adebb5
提交
21adebb5
authored
11月 19, 2015
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3654 from nouiz/blas
Better detect if we can use -lblas and more reuse of anaconda blas.
上级
80197cf5
29ca5137
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
43 行增加
和
11 行删除
+43
-11
cmodule.py
theano/gof/cmodule.py
+10
-9
blas.py
theano/tensor/blas.py
+33
-2
没有找到文件。
theano/gof/cmodule.py
浏览文件 @
21adebb5
...
@@ -1627,6 +1627,16 @@ def std_lib_dirs_and_libs():
...
@@ -1627,6 +1627,16 @@ def std_lib_dirs_and_libs():
# Typical include directory: /usr/include/python2.6
# Typical include directory: /usr/include/python2.6
libname
=
os
.
path
.
basename
(
python_inc
)
libname
=
os
.
path
.
basename
(
python_inc
)
std_lib_dirs_and_libs
.
data
=
[
libname
],
[]
std_lib_dirs_and_libs
.
data
=
[
libname
],
[]
# sometimes, the linker cannot find -lpython so we need to tell it
# explicitly where it is located this returns
# somepath/lib/python2.x
python_lib
=
distutils
.
sysconfig
.
get_python_lib
(
plat_specific
=
1
,
standard_lib
=
1
)
python_lib
=
os
.
path
.
dirname
(
python_lib
)
if
python_lib
not
in
std_lib_dirs_and_libs
.
data
[
1
]:
std_lib_dirs_and_libs
.
data
[
1
]
.
append
(
python_lib
)
return
std_lib_dirs_and_libs
.
data
return
std_lib_dirs_and_libs
.
data
std_lib_dirs_and_libs
.
data
=
None
std_lib_dirs_and_libs
.
data
=
None
...
@@ -2107,15 +2117,6 @@ class GCC_compiler(Compiler):
...
@@ -2107,15 +2117,6 @@ class GCC_compiler(Compiler):
libs
=
std_libs
()
+
libs
libs
=
std_libs
()
+
libs
lib_dirs
=
std_lib_dirs
()
+
lib_dirs
lib_dirs
=
std_lib_dirs
()
+
lib_dirs
# sometimes, the linker cannot find -lpython so we need to tell it
# explicitly where it is located
# this returns somepath/lib/python2.x
python_lib
=
distutils
.
sysconfig
.
get_python_lib
(
plat_specific
=
1
,
standard_lib
=
1
)
python_lib
=
os
.
path
.
dirname
(
python_lib
)
if
python_lib
not
in
lib_dirs
:
lib_dirs
.
append
(
python_lib
)
cppfilename
=
os
.
path
.
join
(
location
,
'mod.cpp'
)
cppfilename
=
os
.
path
.
join
(
location
,
'mod.cpp'
)
cppfile
=
open
(
cppfilename
,
'w'
)
cppfile
=
open
(
cppfilename
,
'w'
)
...
...
theano/tensor/blas.py
浏览文件 @
21adebb5
...
@@ -129,6 +129,7 @@ import copy
...
@@ -129,6 +129,7 @@ import copy
import
logging
import
logging
import
os
import
os
import
sys
import
sys
import
textwrap
import
time
import
time
import
warnings
import
warnings
...
@@ -305,6 +306,13 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in
...
@@ -305,6 +306,13 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in
[])
[])
if
GCC_compiler
.
try_flags
(
ret
):
if
GCC_compiler
.
try_flags
(
ret
):
return
' '
.
join
(
ret
)
return
' '
.
join
(
ret
)
# Try to add the anaconda lib directory to runtime loading of lib.
# This fix some case with Anaconda 2.3 on Linux.
if
"Anaconda"
in
sys
.
version
and
"linux"
in
sys
.
platform
:
lib_path
=
os
.
path
.
join
(
sys
.
prefix
,
'lib'
)
ret
.
append
(
'-Wl,-rpath,'
+
lib_path
)
if
GCC_compiler
.
try_flags
(
ret
):
return
' '
.
join
(
ret
)
except
KeyError
:
except
KeyError
:
pass
pass
...
@@ -312,8 +320,31 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in
...
@@ -312,8 +320,31 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in
# Even if we could not detect what was used for numpy, or if these
# Even if we could not detect what was used for numpy, or if these
# libraries are not found, most Linux systems have a libblas.so
# libraries are not found, most Linux systems have a libblas.so
# readily available. We try to see if that's the case, rather
# readily available. We try to see if that's the case, rather
# than disable blas.
# than disable blas. To test it correctly, we must load a program.
if
GCC_compiler
.
try_flags
([
"-lblas"
]):
# Otherwise, there could be problem in the LD_LIBRARY_PATH.
test_code
=
textwrap
.
dedent
(
"""
\
extern "C" float sdot_(int*, float*, int*, float*, int*);
int main(int argc, char** argv)
{
int Nx = 5;
int Sx = 1;
float x[5] = {0, 1, 2, 3, 4};
float r = sdot_(&Nx, x, &Sx, x, &Sx);
if ((r - 30.f) > 1e-6 || (r - 30.f) < -1e-6)
{
return -1;
}
return 0;
}
"""
)
flags
=
[
'-lblas'
]
flags
.
extend
(
'-L'
.
join
(
theano
.
gof
.
cmodule
.
std_lib_dirs
()))
res
=
GCC_compiler
.
try_compile_tmp
(
test_code
,
tmp_prefix
=
'try_blas_'
,
flags
=
flags
,
try_run
=
True
)
if
res
[
0
]
and
res
[
1
]:
return
"-lblas"
return
"-lblas"
else
:
else
:
return
""
return
""
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论