Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
73495127
提交
73495127
authored
5月 26, 2011
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed id(self) from C code of elemwise GPU ops, to avoid non constant C code
上级
7f3f632c
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
10 行增加
和
13 行删除
+10
-13
elemwise.py
theano/sandbox/cuda/elemwise.py
+10
-13
没有找到文件。
theano/sandbox/cuda/elemwise.py
浏览文件 @
73495127
...
...
@@ -37,7 +37,7 @@ def get_str_list_logical_scalar(node, value_str='ii_i%i_value', data_str='ii_i%i
class
NaiveAlgo
(
object
):
verbose
=
0
# 1, 2 or 3 for more verbose output.
cache_version
=
()
cache_version
=
(
'debug'
,
14
,
verbose
)
cache_version
=
(
15
,
verbose
)
def
__init__
(
self
,
scalar_op
,
sync
=
True
,
inplace_pattern
=
{}):
"""
...
...
@@ -56,7 +56,7 @@ class NaiveAlgo(object):
print
>>
sio
,
"// Input "
,
ipos
,
str
(
i
.
type
)
for
ipos
,
i
in
enumerate
(
node
.
outputs
):
print
>>
sio
,
"// Output "
,
ipos
,
str
(
i
.
type
)
print
>>
sio
,
"static __global__ void kernel_
%
s_
%
s_
%
s
_
%
s(unsigned int numEls"
%
(
self
.
scalar_op
.
__class__
.
__name__
,
nodename
,
id
(
self
)
,
nd
)
print
>>
sio
,
"static __global__ void kernel_
%
s_
%
s_
%
s
(unsigned int numEls"
%
(
self
.
scalar_op
.
__class__
.
__name__
,
nodename
,
nd
)
if
(
nd
):
print
>>
sio
,
"
\t
,"
,
", "
.
join
(
"const int dim
%
i"
%
i
for
i
in
xrange
(
nd
))
#declare inputs
...
...
@@ -159,10 +159,9 @@ class NaiveAlgo(object):
print
>>
sio
,
"// Input "
,
ipos
,
str
(
i
.
type
)
for
ipos
,
i
in
enumerate
(
node
.
outputs
):
print
>>
sio
,
"// Output "
,
ipos
,
str
(
i
.
type
)
print
>>
sio
,
"static __global__ void kernel_
%
s_
%
s_
%
s
_
%
s
(unsigned int numEls"
%
(
print
>>
sio
,
"static __global__ void kernel_
%
s_
%
s_
%
s(unsigned int numEls"
%
(
self
.
scalar_op
.
__class__
.
__name__
,
nodename
,
id
(
self
),
'tiling
%
i'
%
nd
)
if
(
nd
):
print
>>
sio
,
"
\t
,"
,
", "
.
join
(
"const int dim
%
i"
%
i
for
i
in
xrange
(
nd
))
...
...
@@ -262,10 +261,9 @@ class NaiveAlgo(object):
print
>>
sio
,
"// Input "
,
ipos
,
str
(
i
.
type
)
for
ipos
,
i
in
enumerate
(
node
.
outputs
):
print
>>
sio
,
"// Output "
,
ipos
,
str
(
i
.
type
)
print
>>
sio
,
"static __global__ void kernel_
%
s_
%
s_
%
s
_
%
s
(unsigned int numEls"
%
(
print
>>
sio
,
"static __global__ void kernel_
%
s_
%
s_
%
s(unsigned int numEls"
%
(
self
.
scalar_op
.
__class__
.
__name__
,
nodename
,
id
(
self
),
'tiling
%
i_less_registers'
%
nd
)
if
(
nd
):
print
>>
sio
,
"
\t
,"
,
", "
.
join
(
"const int dim
%
i"
%
i
for
i
in
xrange
(
nd
))
...
...
@@ -472,7 +470,6 @@ class NaiveAlgo(object):
nd
=
node
.
outputs
[
0
]
.
type
.
ndim
nb_inputs
=
len
(
node
.
inputs
)
nb_outputs
=
len
(
node
.
outputs
)
id_self
=
id
(
self
)
d
=
dict
()
#input_params and output_params go into the function declaration/definition
input_params
=
", "
.
join
(
"const float * i
%
i_data, const int * i
%
i_str"
%
(
ipos
,
ipos
)
...
...
@@ -512,7 +509,7 @@ class NaiveAlgo(object):
"""
%
locals
()
if
self
.
verbose
:
print
>>
sio
,
"""
std::cerr << "calling kernel_
%(scalar_op)
s_
%(nodename)
s
_
%(id_self)
s
w numEls" << numEls << " dims"<< d << "
\\
n";
std::cerr << "calling kernel_
%(scalar_op)
s_
%(nodename)
s w numEls" << numEls << " dims"<< d << "
\\
n";
"""
%
locals
()
print
>>
sio
,
'std::cerr << '
+
" << ' ' << "
.
join
([
'" "'
]
+
list
(
"dims[
%
i]"
%
di
for
di
in
xrange
(
nd
))
+
[
"'
\\
n';"
])
...
...
@@ -693,7 +690,7 @@ nd_collapse_[i]=0;
print
>>
sio
,
'std::cerr << " local_ostr
%(ipos)
s: " <<'
%
locals
()
+
' << " " << '
.
join
([
"local_ostr[
%(ipos)
s][
%(x)
s]"
%
locals
()
for
x
in
range
(
nd
)])
+
'<<"
\\
n";'
def
launch_Ccontiguous
(
nodename
,
id_self
,
scalar_op
,
sync
=
True
):
def
launch_Ccontiguous
(
nodename
,
scalar_op
,
sync
=
True
):
kernel_call_args
=
[
"numEls"
]
for
ipos
in
xrange
(
len
(
node
.
inputs
)):
kernel_call_args
.
append
(
"i
%
i_data"
%
ipos
)
...
...
@@ -736,7 +733,7 @@ nd_collapse_[i]=0;
else
:
print
>>
sio
,
" return 0; "
%
locals
()
def
launch_General
(
nodename
,
id_self
,
scalar_op
,
force_nd
,
sync
=
True
):
def
launch_General
(
nodename
,
scalar_op
,
force_nd
,
sync
=
True
):
# kernel_call_args are used to invoke the cuda kernel
local
=
"local_"
kernel_call_args
=
[
"numEls"
]
...
...
@@ -769,7 +766,7 @@ nd_collapse_[i]=0;
if (threads_per_block * n_blocks < numEls)
threads_per_block = std::min(numEls/n_blocks, (unsigned int)NUM_VECTOR_OP_THREADS_PER_BLOCK);
kernel_
%(scalar_op)
s_
%(nodename)
s_
%(
id_self)
s_
%(
force_nd)
s<<<n_blocks, threads_per_block>>>(
%(kernel_call_args)
s);
kernel_
%(scalar_op)
s_
%(nodename)
s_
%(force_nd)
s<<<n_blocks, threads_per_block>>>(
%(kernel_call_args)
s);
"""
%
locals
()
if
sync
:
print
>>
sio
,
"""
...
...
@@ -791,11 +788,11 @@ nd_collapse_[i]=0;
print
>>
sio
,
"if(numEls==0) return 0;"
print
>>
sio
,
"switch (nd_collapse==0?0:min(
%(nd)
s,nd_collapse)) {"
%
locals
()
print
>>
sio
,
"case 0: {"
launch_Ccontiguous
(
nodename
,
id_self
,
scalar_op
,
self
.
sync
)
launch_Ccontiguous
(
nodename
,
scalar_op
,
self
.
sync
)
print
>>
sio
,
" } break;"
for
i
in
range
(
1
,
nd
+
1
):
print
>>
sio
,
"case "
+
str
(
i
)
+
": {"
launch_General
(
nodename
,
id_self
,
scalar_op
,
i
,
self
.
sync
)
launch_General
(
nodename
,
scalar_op
,
i
,
self
.
sync
)
print
>>
sio
,
" } break;"
print
>>
sio
,
"}"
#end case
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论