Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
af691e3c
提交
af691e3c
authored
11月 27, 2011
作者:
Sebastian Urban
提交者:
Olivier Delalleau
11月 29, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed some arrays of length 0 in generated CUDA code
Arrays of length 0 are forbidden by C standard and treated as errors by the Visual C++ compiler.
上级
10f5a853
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
30 行增加
和
7 行删除
+30
-7
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+3
-0
elemwise.py
theano/sandbox/cuda/elemwise.py
+27
-7
没有找到文件。
theano/sandbox/cuda/basic_ops.py
浏览文件 @
af691e3c
...
@@ -471,7 +471,10 @@ class GpuSum(Op):
...
@@ -471,7 +471,10 @@ class GpuSum(Op):
)
)
{
{
"""
%
locals
()
"""
%
locals
()
if
nd_out
>
0
:
print
>>
sio
,
"int new_dims[
%(nd_out)
s]; "
%
locals
()
print
>>
sio
,
"int new_dims[
%(nd_out)
s]; "
%
locals
()
else
:
print
>>
sio
,
"int *new_dims=NULL; "
j
=
0
j
=
0
for
i
in
xrange
(
nd_in
):
for
i
in
xrange
(
nd_in
):
...
...
theano/sandbox/cuda/elemwise.py
浏览文件 @
af691e3c
...
@@ -534,10 +534,21 @@ class NaiveAlgo(object):
...
@@ -534,10 +534,21 @@ class NaiveAlgo(object):
# collapse dimension that are broadcast in all inputs.
# collapse dimension that are broadcast in all inputs.
# need to be done before contiguous collapse as it will break it.
# need to be done before contiguous collapse as it will break it.
# do the dimensions and the strides
# do the dimensions and the strides
if
nd
>
0
:
print
>>
sio
,
"int local_dims[
%(nd)
s];"
%
locals
()
else
:
print
>>
sio
,
"int *local_dims=NULL;"
if
nb_inputs
>
0
and
nd
>
0
:
print
>>
sio
,
"""
print
>>
sio
,
"""
int local_dims[
%(nd)
s];
int local_str[
%(nb_inputs)
s][
%(nd)
s];
int local_str[
%(nb_inputs)
s][
%(nd)
s];
int local_ostr[
%(nb_inputs)
s][
%(nd)
s];
int local_ostr[
%(nb_inputs)
s][
%(nd)
s];
"""
%
locals
()
else
:
print
>>
sio
,
"""
int local_str[1][1];
int local_ostr[1][1];
"""
print
>>
sio
,
"""
int nd_collapse =
%(nd)
s;
int nd_collapse =
%(nd)
s;
for(int i=0;i<
%(nd)
s;i++){//init new dim
for(int i=0;i<
%(nd)
s;i++){//init new dim
local_dims[i]=dims[i];
local_dims[i]=dims[i];
...
@@ -611,11 +622,18 @@ class NaiveAlgo(object):
...
@@ -611,11 +622,18 @@ class NaiveAlgo(object):
# collapse contiguous dimensions (ignoring scalars, generic version(collapse any dimensions, right, left, middle))
# collapse contiguous dimensions (ignoring scalars, generic version(collapse any dimensions, right, left, middle))
# this is a good idea because we make less index calculation in the gpu.
# this is a good idea because we make less index calculation in the gpu.
if
nd
>
0
:
print
>>
sio
,
"int nd_collapse_[
%(nd)
s] = {"
%
locals
()
+
','
.
join
([
'1'
for
x
in
xrange
(
nd
)])
+
"};"
print
>>
sio
,
"int nd_collapse_[
%(nd)
s] = {"
%
locals
()
+
','
.
join
([
'1'
for
x
in
xrange
(
nd
)])
+
"};"
else
:
print
>>
sio
,
"int *nd_collapse_ = NULL;"
for
ipos
in
xrange
(
len
(
node
.
inputs
)):
for
ipos
in
xrange
(
len
(
node
.
inputs
)):
if
not
_logical_scalar
(
node
.
inputs
[
ipos
]):
if
not
_logical_scalar
(
node
.
inputs
[
ipos
]):
if
nd
>
0
:
print
>>
sio
,
"""
print
>>
sio
,
"""
int nd_collapse_
%(ipos)
s[
%(nd)
s] = {"""
%
locals
()
+
','
.
join
([
'1'
for
x
in
xrange
(
nd
)])
+
"};"
int nd_collapse_
%(ipos)
s[
%(nd)
s] = {"""
%
locals
()
+
','
.
join
([
'1'
for
x
in
xrange
(
nd
)])
+
"};"
else
:
print
>>
sio
,
"""
int *nd_collapse_
%(ipos)
s = NULL;"""
%
locals
()
print
>>
sio
,
"""
print
>>
sio
,
"""
can_collapse_
%(nodename)
s(nd_collapse, local_dims, local_str[
%(ipos)
s], nd_collapse_
%(ipos)
s);
can_collapse_
%(nodename)
s(nd_collapse, local_dims, local_str[
%(ipos)
s], nd_collapse_
%(ipos)
s);
for(int i=0;i<nd_collapse;i++){
for(int i=0;i<nd_collapse;i++){
...
@@ -839,9 +857,10 @@ nd_collapse_[i]=0;
...
@@ -839,9 +857,10 @@ nd_collapse_[i]=0;
//std::cerr << "C_CODE
%(opname)
s START
\\
n";
//std::cerr << "C_CODE
%(opname)
s START
\\
n";
//standard elemwise size checks
//standard elemwise size checks
"""
%
locals
()
"""
%
locals
()
print
>>
sio
,
"""
if
nd
>
0
:
int dims[
%(nd)
s] = {
%(initial_dims)
s};
print
>>
sio
,
"""int dims[
%(nd)
s] = {
%(initial_dims)
s};"""
%
locals
()
"""
%
locals
()
else
:
print
>>
sio
,
"""int *dims = NULL;"""
#check that all inputs have valid dimensions
#check that all inputs have valid dimensions
emitted_inames
=
{}
emitted_inames
=
{}
...
@@ -851,9 +870,10 @@ nd_collapse_[i]=0;
...
@@ -851,9 +870,10 @@ nd_collapse_[i]=0;
continue
continue
broadcasts
=
', '
.
join
(
map
(
str
,
map
(
int
,
node
.
inputs
[
id
]
.
broadcastable
)))
broadcasts
=
', '
.
join
(
map
(
str
,
map
(
int
,
node
.
inputs
[
id
]
.
broadcastable
)))
nd
=
node
.
inputs
[
id
]
.
ndim
nd
=
node
.
inputs
[
id
]
.
ndim
print
>>
sio
,
"""
if
nd
>
0
:
int broadcasts_
%(iname)
s[
%(nd)
s] = {
%(broadcasts)
s};
print
>>
sio
,
"""int broadcasts_
%(iname)
s[
%(nd)
s] = {
%(broadcasts)
s};"""
%
locals
()
"""
%
locals
()
else
:
print
>>
sio
,
"""int *broadcasts_
%(iname)
s = NULL;"""
%
locals
()
emitted_inames
[
iname
]
=
node
.
inputs
[
id
]
emitted_inames
[
iname
]
=
node
.
inputs
[
id
]
#check that all inputs have valid dimensions
#check that all inputs have valid dimensions
emitted_inames
=
{}
emitted_inames
=
{}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论