Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
cff27c13
提交
cff27c13
authored
2月 21, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make {nvcc,gcc}_module_compile_str a class with another function compile_args…
make {nvcc,gcc}_module_compile_str a class with another function compile_args that get added in the keys.
上级
2f2b424a
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
51 行增加
和
23 行删除
+51
-23
cc.py
theano/gof/cc.py
+7
-3
cmodule.py
theano/gof/cmodule.py
+17
-10
cutils.py
theano/gof/cutils.py
+1
-1
lazylinker_c.py
theano/gof/lazylinker_c.py
+1
-1
__init__.py
theano/sandbox/cuda/__init__.py
+4
-3
nvcc_compiler.py
theano/sandbox/cuda/nvcc_compiler.py
+17
-1
type.py
theano/sandbox/cuda/type.py
+2
-2
scan_perform_ext.py
theano/scan_module/scan_perform_ext.py
+2
-2
没有找到文件。
theano/gof/cc.py
浏览文件 @
cff27c13
...
...
@@ -622,6 +622,10 @@ class CLinker(link.Linker):
for
x
in
[
y
.
type
for
y
in
self
.
variables
]
+
[
y
.
op
for
y
in
self
.
node_order
]:
try
:
ret
+=
x
.
c_compile_args
()
except
utils
.
MethodNotDefined
:
pass
c_compiler
=
self
.
c_compiler
()
ret
+=
c_compiler
.
compile_args
()
ret
=
list
(
set
(
ret
))
#to remove duplicate
for
x
in
[
y
.
type
for
y
in
self
.
variables
]
+
[
y
.
op
for
y
in
self
.
node_order
]:
try
:
...
...
@@ -661,7 +665,7 @@ class CLinker(link.Linker):
raise
Exception
(
'Nodes have requested specific different compilers'
,
(
c_compiler
,
x_compiler
))
if
(
c_compiler
is
None
):
return
cmodule
.
gcc_module_compile_st
r
return
cmodule
.
GCC_compile
r
else
:
return
c_compiler
def
header_dirs
(
self
):
...
...
@@ -1007,7 +1011,7 @@ class CLinker(link.Linker):
libs
=
self
.
libraries
()
preargs
=
self
.
compile_args
()
compiler_name
=
c_compiler
.
__name__
if
compiler_name
==
'
nvcc_module_compile_st
r'
and
config
.
lib
.
amdlibm
:
if
compiler_name
==
'
NVCC_compile
r'
and
config
.
lib
.
amdlibm
:
# This lib does not work correctly with nvcc in device code.
# and newer version of g++ as 4.5.1.
# example of errors: "/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/mmintrin.h(49): error: identifier "__builtin_ia32_emms" is undefined"
...
...
@@ -1024,7 +1028,7 @@ class CLinker(link.Linker):
try
:
_logger
.
debug
(
"LOCATION
%
s"
,
str
(
location
))
try
:
module
=
c_compiler
(
module
=
c_compiler
.
compile_str
(
module_name
=
mod
.
name
,
src_code
=
src_code
,
location
=
location
,
...
...
theano/gof/cmodule.py
浏览文件 @
cff27c13
...
...
@@ -1312,23 +1312,30 @@ def gcc_version():
return
gcc_version_str
def
gcc_module_compile_str
(
module_name
,
src_code
,
location
=
None
,
class
GCC_compiler
():
@staticmethod
def
compile_args
():
return
[]
@staticmethod
def
compile_str
(
module_name
,
src_code
,
location
=
None
,
include_dirs
=
[],
lib_dirs
=
[],
libs
=
[],
preargs
=
[]):
"""
:param module_name: string (this has been embedded in the src_code
:param src_code: a complete c or c++ source listing for the module
:param location: a pre-existing filesystem directory where the cpp file and
.so will be written
:param location: a pre-existing filesystem directory where the
cpp file and
.so will be written
:param include_dirs: a list of include directory names (each gets prefixed
with -I)
:param include_dirs: a list of include directory names (each
gets prefixed
with -I)
:param lib_dirs: a list of library search path directory names (each get
s
prefixed with -L)
:param lib_dirs: a list of library search path directory name
s
(each gets
prefixed with -L)
:param libs: a list of libraries to link with (each gets prefixed with -l)
:param libs: a list of libraries to link with (each gets
prefixed with -l)
:param preargs: a list of extra compiler arguments
...
...
@@ -1362,8 +1369,8 @@ def gcc_module_compile_str(module_name, src_code, location=None,
config
.
cmodule
.
mac_framework_link
):
preargs
.
extend
([
'-framework'
,
'Python'
])
# Figure out whether the current Python executable is 32 or 64 bit and
#
compile accordingly.
# Figure out whether the current Python executable is 32
# or 64 bit and
compile accordingly.
n_bits
=
local_bitwidth
()
preargs
.
extend
([
'-m
%
s'
%
n_bits
])
_logger
.
debug
(
"OS X: compiling for
%
s bit architecture"
,
n_bits
)
...
...
theano/gof/cutils.py
浏览文件 @
cff27c13
...
...
@@ -70,7 +70,7 @@ except ImportError:
if
not
os
.
path
.
exists
(
loc
):
os
.
mkdir
(
loc
)
cmodule
.
gcc_module_
compile_str
(
'cutils_ext'
,
code
,
location
=
loc
)
cmodule
.
GCC_compiler
.
compile_str
(
'cutils_ext'
,
code
,
location
=
loc
)
from
cutils_ext.cutils_ext
import
*
finally
:
...
...
theano/gof/lazylinker_c.py
浏览文件 @
cff27c13
...
...
@@ -53,7 +53,7 @@ except ImportError:
loc
=
os
.
path
.
join
(
config
.
compiledir
,
dirname
)
if
not
os
.
path
.
exists
(
loc
):
os
.
mkdir
(
loc
)
cmodule
.
gcc_module_
compile_str
(
dirname
,
code
,
location
=
loc
)
cmodule
.
GCC_compiler
.
compile_str
(
dirname
,
code
,
location
=
loc
)
# Save version into the __init__.py file.
init_py
=
os
.
path
.
join
(
loc
,
'__init__.py'
)
open
(
init_py
,
'w'
)
.
write
(
'_version =
%
s
\n
'
%
version
)
...
...
theano/sandbox/cuda/__init__.py
浏览文件 @
cff27c13
...
...
@@ -87,7 +87,7 @@ libcuda_ndarray_so = os.path.join(cuda_ndarray_loc,
# Add the theano cache directory's cuda_ndarray subdirectory to the
# list of places that are hard-coded into compiled modules' runtime
# library search list. This works in conjunction with
# nvcc_compiler.
nvcc_module_
compile_str which adds this folder during
# nvcc_compiler.
NVCC_compiler.
compile_str which adds this folder during
# compilation with -L and also adds -lcuda_ndarray when compiling
# modules.
nvcc_compiler
.
add_standard_rpath
(
cuda_ndarray_loc
)
...
...
@@ -117,7 +117,8 @@ try:
if
not
os
.
path
.
exists
(
cuda_ndarray_loc
):
os
.
makedirs
(
cuda_ndarray_loc
)
nvcc_compiler
.
nvcc_module_compile_str
(
compiler
=
nvcc_compiler
.
NVCC_compiler
()
compiler
.
compile_str
(
'cuda_ndarray'
,
code
,
location
=
cuda_ndarray_loc
,
...
...
@@ -130,7 +131,7 @@ except Exception, e:
if
cuda_available
:
# If necessary,
# create a symlink called libcuda_ndarray.so
# which nvcc_
module_compile_st
r uses when linking
# which nvcc_
compiler.NVCC_compile
r uses when linking
# any module except "cuda_ndarray" itself.
try
:
open
(
libcuda_ndarray_so
)
.
close
()
...
...
theano/sandbox/cuda/nvcc_compiler.py
浏览文件 @
cff27c13
...
...
@@ -72,7 +72,23 @@ rpath_defaults = []
def
add_standard_rpath
(
rpath
):
rpath_defaults
.
append
(
rpath
)
def
nvcc_module_compile_str
(
class
NVCC_compiler
():
@staticmethod
def
compile_args
():
"""
This args will be received by compile_str() in the preargs paramter.
They will also be included in the "hard" part of the key module.
"""
return
[]
# flags = [flag for flag in config.nvcc.flags.split(' ') if flag]
# cuda_ndarray_cuh_hash = hash_from_file(
# os.path.join(os.path.split(__file__)[0], 'cuda_ndarray.cuh'))
# cuda_macro = '-DCUDA_NDARRAY_CUH=' + cuda_ndarray_cuh_hash
# return [cuda_macro]
@staticmethod
def
compile_str
(
module_name
,
src_code
,
location
=
None
,
include_dirs
=
[],
lib_dirs
=
[],
libs
=
[],
preargs
=
[],
rpaths
=
rpath_defaults
):
...
...
theano/sandbox/cuda/type.py
浏览文件 @
cff27c13
...
...
@@ -12,7 +12,7 @@ try:
# We must do those import to be able to create the full doc when nvcc
# is not available
import
cuda_ndarray.cuda_ndarray
as
cuda
from
theano.sandbox.cuda.nvcc_compiler
import
nvcc_module_compile_st
r
from
theano.sandbox.cuda.nvcc_compiler
import
NVCC_compile
r
import
cuda_ndarray
except
ImportError
:
pass
...
...
@@ -370,7 +370,7 @@ class CudaNdarrayType(Type):
return
(
2
,)
# with assertion about refcounts
def
c_compiler
(
self
):
return
nvcc_module_compile_st
r
return
NVCC_compile
r
def
c_compile_args
(
self
):
ret
=
[]
...
...
theano/scan_module/scan_perform_ext.py
浏览文件 @
cff27c13
...
...
@@ -50,8 +50,8 @@ except ImportError:
loc
=
os
.
path
.
join
(
config
.
compiledir
,
dirname
)
if
not
os
.
path
.
exists
(
loc
):
os
.
mkdir
(
loc
)
cmodule
.
gcc_module_
compile_str
(
dirname
,
code
,
location
=
loc
,
preargs
=
[
'-pthread'
,
'-fwrapv'
,
cmodule
.
GCC_compiler
.
compile_str
(
dirname
,
code
,
location
=
loc
,
preargs
=
[
'-pthread'
,
'-fwrapv'
,
'-O2'
,
'-fno-strict-aliasing'
])
# Save version into the __init__.py file.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论