Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9d0f6f8b
提交
9d0f6f8b
authored
6月 23, 2015
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Better use of @memoize to avoid caching config flag
Now, theano.config.blas.ldflags will be read each time. Also cache the result of equivalent calls when specifying default values explicitly.
上级
fae5d713
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
49 行增加
和
9 行删除
+49
-9
blas.py
theano/tensor/blas.py
+49
-9
没有找到文件。
theano/tensor/blas.py
浏览文件 @
9d0f6f8b
...
...
@@ -529,20 +529,59 @@ ger = Ger(destructive=False)
ger_destructive
=
Ger
(
destructive
=
True
)
@utils.memoize
def
ldflags
(
libs
=
True
,
flags
=
False
,
libs_dir
=
False
,
include_dir
=
False
):
"""Return a list of libraries against which an Op's object file should be
linked to benefit from a BLAS implementation.
"""Extract a list of compilation flags from config.blas.ldflags.
Depending on the options, different type of flags will be kept.
It returns a list of libraries against which an Op's object file
should be linked to benefit from a BLAS implementation.
:type libs: bool, defaults to True
:param libs: extract flags starting with "-l"
:type libs_dir: bool, defaults to False
:param libs_dir: extract flags starting with "-L"
:type include_dir: bool, defaults to False
:param include_dir: extract flags starting with "-I"
:type flags: bool, defaults to False
:param flags: extract all the other flags
:rtype: list of strings
:returns: extracted flags
"""
ldflags_str
=
theano
.
config
.
blas
.
ldflags
return
_ldflags
(
ldflags_str
=
ldflags_str
,
libs
=
libs
,
flags
=
flags
,
libs_dir
=
libs_dir
,
include_dir
=
include_dir
)
Default: ['blas'], but configuration variable config.blas.ldflags
overrides this.
@utils.memoize
def
_ldflags
(
ldflags_str
,
libs
,
flags
,
libs_dir
,
include_dir
):
"""Extract list of compilation flags from a string.
Depending on the options, different type of flags will be kept.
:type ldflags_str: string
:param ldflags_str: the string to process. Typically, this will
be the content of `theano.config.blas.ldflags`
:type libs: bool
:param libs: extract flags starting with "-l"
:type libs_dir: bool
:param libs_dir: extract flags starting with "-L"
:type include_dir: bool
:param include_dir: extract flags starting with "-I"
:type flags: bool
:param flags: extract all the other flags
:rtype: list of strings
:returns: extracted flags
"""
rval
=
[]
if
libs_dir
:
found_dyn
=
False
dirs
=
[
x
[
2
:]
for
x
in
config
.
blas
.
ldflags
.
split
()
dirs
=
[
x
[
2
:]
for
x
in
ldflags_str
.
split
()
if
x
.
startswith
(
'-L'
)]
l
=
ldflags
()
l
=
_ldflags
(
ldflags_str
=
ldflags_str
,
libs
=
True
,
flags
=
False
,
libs_dir
=
False
,
include_dir
=
False
)
for
d
in
dirs
:
for
f
in
os
.
listdir
(
d
):
if
(
f
.
endswith
(
'.so'
)
or
f
.
endswith
(
'.dylib'
)
or
...
...
@@ -554,7 +593,7 @@ def ldflags(libs=True, flags=False, libs_dir=False, include_dir=False):
"library_dir of the library we use for blas. If you use "
"ATLAS, make sure to compile it with dynamics library."
)
for
t
in
config
.
blas
.
ldflags
.
split
():
for
t
in
ldflags_str
.
split
():
# Remove extra quote.
if
t
.
startswith
(
"'"
)
or
t
.
startswith
(
'"'
):
t
=
t
[
1
:]
...
...
@@ -565,7 +604,8 @@ def ldflags(libs=True, flags=False, libs_dir=False, include_dir=False):
t0
,
t1
,
t2
=
t
[
0
:
3
]
assert
t0
==
'-'
except
Exception
:
raise
ValueError
(
'invalid token in config.blas.ldflags'
,
t
)
raise
ValueError
(
'invalid token "
%
s" in ldflags_str: "
%
s"'
%
(
t
,
ldflags_str
))
if
libs_dir
and
t1
==
'L'
:
rval
.
append
(
t
[
2
:])
elif
include_dir
and
t1
==
'I'
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论