Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ac06a2c4
提交
ac06a2c4
authored
6月 25, 2015
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3063 from lamblin/fix_win32_anaconda
Fixes for detection of mkl for win32 with anaconda
上级
f9214591
90f9614b
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
66 行增加
和
59 行删除
+66
-59
configparser.py
theano/configparser.py
+1
-6
blas.py
theano/tensor/blas.py
+65
-53
没有找到文件。
theano/configparser.py
浏览文件 @
ac06a2c4
...
@@ -3,7 +3,6 @@ from __future__ import print_function
...
@@ -3,7 +3,6 @@ from __future__ import print_function
# as False, and the string s'True', 'true', '1' as True.
# as False, and the string s'True', 'true', '1' as True.
# We also accept the bool type as its corresponding value!
# We also accept the bool type as its corresponding value!
import
inspect
import
logging
import
logging
import
os
import
os
import
shlex
import
shlex
...
@@ -306,11 +305,7 @@ class ConfigParam(object):
...
@@ -306,11 +305,7 @@ class ConfigParam(object):
try
:
try
:
val_str
=
fetch_val_for_key
(
self
.
fullname
)
val_str
=
fetch_val_for_key
(
self
.
fullname
)
except
KeyError
:
except
KeyError
:
if
inspect
.
isgeneratorfunction
(
self
.
default
):
if
callable
(
self
.
default
):
for
v
in
self
.
default
():
val_str
=
v
self
.
__set__
(
None
,
val_str
)
elif
callable
(
self
.
default
):
val_str
=
self
.
default
()
val_str
=
self
.
default
()
else
:
else
:
val_str
=
self
.
default
val_str
=
self
.
default
...
...
theano/tensor/blas.py
浏览文件 @
ac06a2c4
...
@@ -162,37 +162,6 @@ _logger = logging.getLogger('theano.tensor.blas')
...
@@ -162,37 +162,6 @@ _logger = logging.getLogger('theano.tensor.blas')
# We need to define blas.ldflag before we try to import scipy.
# We need to define blas.ldflag before we try to import scipy.
# Otherwise, we give an optimization warning for no reason in some cases.
# Otherwise, we give an optimization warning for no reason in some cases.
def
default_blas_ldflags
():
def
default_blas_ldflags
():
"""This is a generator. It work in 2 step. The first we guess a
default blas, then we test it. If it fail, we return an empty
blas.
This is needed for Anaconda on Windows. I wasn't able to find how
to detect if the mkl from Anaconda can be reused or not. I was not
able to find a way to test it with try_flags correctly. Also, this
will test the real code, so we do not need to update the test in
case the software change. This also enables the test for all
cases.
"""
flags
=
static_default_blas_flags
()
yield
flags
# Now test it!
try
:
old
=
config
.
compute_test_value
config
.
compute_test_value
=
'off'
x
=
theano
.
tensor
.
fmatrix
()
try
:
theano
.
function
([
x
],
theano
.
tensor
.
blas
.
_dot22
(
x
,
x
),
profile
=
False
)
except
Exception
as
e
:
print
(
e
)
yield
""
finally
:
config
.
compute_test_value
=
old
def
static_default_blas_flags
():
try
:
try
:
if
(
hasattr
(
numpy
.
distutils
,
'__config__'
)
and
if
(
hasattr
(
numpy
.
distutils
,
'__config__'
)
and
numpy
.
distutils
.
__config__
):
numpy
.
distutils
.
__config__
):
...
@@ -291,20 +260,27 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in
...
@@ -291,20 +260,27 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in
"mk2_rt"
]])
"mk2_rt"
]])
# Anaconda
# Anaconda
if
"Anaconda"
in
sys
.
version
and
sys
.
platform
==
"win32"
:
if
"Anaconda"
in
sys
.
version
and
sys
.
platform
==
"win32"
:
lib_path
=
os
.
path
.
join
(
sys
.
prefix
,
'pkgs'
)
# If the "mkl-service" conda package (available through Python
for
dir
in
os
.
listdir
(
lib_path
):
# package "mkl") is installed and importable, then the libraries
if
dir
.
startswith
(
"mkl-rt-"
):
# (installed by conda package "mkl-rt") are actually available.
lib_path
=
os
.
path
.
join
(
lib_path
,
dir
,
"DLLs"
)
# Using "conda install mkl" will install both, as well as
break
# optimized versions of numpy and scipy.
if
os
.
path
.
exists
(
lib_path
):
try
:
#-LC:\\Users\\*\\Anaconda\\libs
import
mkl
except
ImportError
as
e
:
_logger
.
info
(
'Conda mkl is not available:
%
s'
,
e
)
else
:
# This branch is executed if no exception was raised
lib_path
=
os
.
path
.
join
(
sys
.
prefix
,
'DLLs'
)
flags
=
[
'-L
%
s'
%
lib_path
]
flags
=
[
'-L
%
s'
%
lib_path
]
flags
+=
[
'-l
%
s'
%
l
for
l
in
[
"mkl_core"
,
flags
+=
[
'-l
%
s'
%
l
for
l
in
[
"mkl_core"
,
"mkl_intel_thread"
,
"mkl_intel_thread"
,
"mkl_rt"
]]
"mkl_rt"
]]
return
' '
.
join
(
flags
)
if
GCC_compiler
.
try_flags
(
flags
):
return
' '
.
join
(
flags
)
# if numpy was linked with library that are not installed, we
# If numpy was linked with library that are not installed or
# the dev version of the package is not currently available, we
# can't reuse them.
# can't reuse them.
if
any
(
os
.
path
.
exists
(
dir
)
for
dir
in
blas_info
[
'library_dirs'
]):
if
any
(
os
.
path
.
exists
(
dir
)
for
dir
in
blas_info
[
'library_dirs'
]):
ret
=
(
ret
=
(
...
@@ -316,10 +292,6 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in
...
@@ -316,10 +292,6 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in
[
'-L
%
s'
%
l
for
l
in
blas_info
[
'library_dirs'
]]
+
[
'-L
%
s'
%
l
for
l
in
blas_info
[
'library_dirs'
]]
+
[
'-l
%
s'
%
l
for
l
in
blas_info
[
'libraries'
]]
+
[
'-l
%
s'
%
l
for
l
in
blas_info
[
'libraries'
]]
+
[])
[])
# ['-I%s' % l for l in blas_info['include_dirs']])
# if numpy was linked with library that are not installed or
# the dev version of the package is not currently available, we
# can't reuse them.
if
GCC_compiler
.
try_flags
(
ret
):
if
GCC_compiler
.
try_flags
(
ret
):
return
' '
.
join
(
ret
)
return
' '
.
join
(
ret
)
...
@@ -529,20 +501,59 @@ ger = Ger(destructive=False)
...
@@ -529,20 +501,59 @@ ger = Ger(destructive=False)
ger_destructive
=
Ger
(
destructive
=
True
)
ger_destructive
=
Ger
(
destructive
=
True
)
@utils.memoize
def
ldflags
(
libs
=
True
,
flags
=
False
,
libs_dir
=
False
,
include_dir
=
False
):
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
"""Extract a list of compilation flags from config.blas.ldflags.
linked to benefit from a BLAS implementation.
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
@utils.memoize
overrides this.
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
=
[]
rval
=
[]
if
libs_dir
:
if
libs_dir
:
found_dyn
=
False
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'
)]
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
d
in
dirs
:
for
f
in
os
.
listdir
(
d
):
for
f
in
os
.
listdir
(
d
):
if
(
f
.
endswith
(
'.so'
)
or
f
.
endswith
(
'.dylib'
)
or
if
(
f
.
endswith
(
'.so'
)
or
f
.
endswith
(
'.dylib'
)
or
...
@@ -554,7 +565,7 @@ def ldflags(libs=True, flags=False, libs_dir=False, include_dir=False):
...
@@ -554,7 +565,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 "
"library_dir of the library we use for blas. If you use "
"ATLAS, make sure to compile it with dynamics library."
)
"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.
# Remove extra quote.
if
t
.
startswith
(
"'"
)
or
t
.
startswith
(
'"'
):
if
t
.
startswith
(
"'"
)
or
t
.
startswith
(
'"'
):
t
=
t
[
1
:]
t
=
t
[
1
:]
...
@@ -565,7 +576,8 @@ def ldflags(libs=True, flags=False, libs_dir=False, include_dir=False):
...
@@ -565,7 +576,8 @@ def ldflags(libs=True, flags=False, libs_dir=False, include_dir=False):
t0
,
t1
,
t2
=
t
[
0
:
3
]
t0
,
t1
,
t2
=
t
[
0
:
3
]
assert
t0
==
'-'
assert
t0
==
'-'
except
Exception
:
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'
:
if
libs_dir
and
t1
==
'L'
:
rval
.
append
(
t
[
2
:])
rval
.
append
(
t
[
2
:])
elif
include_dir
and
t1
==
'I'
:
elif
include_dir
and
t1
==
'I'
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论