Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c056820d
提交
c056820d
authored
9月 20, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make sure it work with non scalar tensor and test it.
上级
a9e821f5
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
1 行删除
+24
-1
opt.py
theano/sandbox/cuda/opt.py
+2
-1
test_opt.py
theano/sandbox/cuda/tests/test_opt.py
+22
-0
没有找到文件。
theano/sandbox/cuda/opt.py
浏览文件 @
c056820d
...
...
@@ -1345,7 +1345,8 @@ def local_gpualloc_memset_0(node):
if
isinstance
(
node
.
op
,
GpuAlloc
)
and
not
node
.
op
.
memset_0
:
inp
=
node
.
inputs
[
0
]
if
(
isinstance
(
inp
,
CudaNdarrayConstant
)
and
numpy
.
asarray
(
inp
.
data
)
==
0
and
inp
.
data
.
size
==
1
):
inp
.
data
.
size
==
1
and
(
numpy
.
asarray
(
inp
.
data
)
==
0
)
.
all
()):
new_out
=
GpuAlloc
(
memset_0
=
True
)(
*
node
.
inputs
)
return
[
new_out
]
...
...
theano/sandbox/cuda/tests/test_opt.py
浏览文件 @
c056820d
...
...
@@ -73,6 +73,10 @@ def test_gpualloc():
def
test_alloc_memset_0
():
i
=
tensor
.
iscalar
()
z
=
numpy
.
zeros
((
1
,),
dtype
=
'float32'
)
o
=
numpy
.
ones
((
1
,),
dtype
=
'float32'
)
ones
=
numpy
.
ones
((
2
,),
dtype
=
'float32'
)
# Test with 0
a
=
basic_ops
.
gpu_alloc
(
cuda
.
gpu_from_host
(
tensor
.
constant
(
z
)),
i
)
f
=
theano
.
function
([
i
],
a
,
mode
=
mode_with_gpu
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
...
...
@@ -80,6 +84,24 @@ def test_alloc_memset_0():
assert
isinstance
(
topo
[
0
]
.
op
,
basic_ops
.
GpuAlloc
)
and
topo
[
0
]
.
op
.
memset_0
assert
(
numpy
.
asarray
(
f
(
6
))
==
0
)
.
all
()
# Test with 1
a
=
basic_ops
.
gpu_alloc
(
cuda
.
gpu_from_host
(
tensor
.
constant
(
o
)),
i
)
f
=
theano
.
function
([
i
],
a
,
mode
=
mode_with_gpu
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
len
(
topo
)
==
1
assert
isinstance
(
topo
[
0
]
.
op
,
basic_ops
.
GpuAlloc
)
assert
not
topo
[
0
]
.
op
.
memset_0
assert
(
numpy
.
asarray
(
f
(
6
))
==
1
)
.
all
()
# Test with 1, 1
a
=
basic_ops
.
gpu_alloc
(
cuda
.
gpu_from_host
(
tensor
.
constant
(
ones
)),
i
)
f
=
theano
.
function
([
i
],
a
,
mode
=
mode_with_gpu
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
len
(
topo
)
==
1
assert
isinstance
(
topo
[
0
]
.
op
,
basic_ops
.
GpuAlloc
)
assert
not
topo
[
0
]
.
op
.
memset_0
assert
(
numpy
.
asarray
(
f
(
2
))
==
1
)
.
all
()
def
test_gpuspecifyshape
():
x
=
cuda
.
shared_constructor
(
numpy
.
ones
(
3
,
dtype
=
'float32'
),
'x'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论