Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c318153c
提交
c318153c
authored
7月 08, 2015
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Expand test
上级
a1530fe2
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
48 行增加
和
12 行删除
+48
-12
test_cc.py
theano/gof/tests/test_cc.py
+48
-12
没有找到文件。
theano/gof/tests/test_cc.py
浏览文件 @
c318153c
...
...
@@ -5,6 +5,8 @@ import unittest
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.attrib
import
attr
import
numpy
import
theano
from
theano.gof.link
import
PerformLinker
from
theano.gof.cc
import
CLinker
,
DualLinker
,
OpWiseCLinker
...
...
@@ -364,28 +366,62 @@ def test_c_fail_error():
assert
0
# test failed
# Test bug reported on the mailing list by Alberto Orlandi
# https://groups.google.com/d/topic/theano-users/6dLaEqc2R6g/discussion
def
test_shared_input_output
():
#
Not sure yet why this case is special.
#
It may be that a shared variable is both an implicit input
#
and an output
.
#
Test bug reported on the mailing list by Alberto Orlandi
#
https://groups.google.com/d/topic/theano-users/6dLaEqc2R6g/discussion
#
The shared variable is both an input and an output of the function
.
inc
=
theano
.
tensor
.
iscalar
(
'inc'
)
state
=
theano
.
shared
(
0
)
state
.
name
=
'state'
linker
=
theano
.
gof
.
CLinker
()
mode
=
theano
.
Mode
(
linker
=
linker
)
f
=
theano
.
function
([
inc
],
state
,
updates
=
[(
state
,
state
+
inc
)],
mode
=
mode
)
g
=
theano
.
function
([
inc
],
state
,
updates
=
[(
state
,
state
+
inc
)])
theano
.
printing
.
debugprint
(
f
)
theano
.
printing
.
debugprint
(
g
)
assert
f
(
0
)
==
g
(
0
)
==
0
import
numpy
# Initial value
f0
=
f
(
0
)
g0
=
g
(
0
)
assert
f0
==
g0
==
0
,
(
f0
,
g0
)
# Increment state via f, returns the previous value.
f2
=
f
(
2
)
assert
f2
==
f0
,
(
f2
,
f0
)
f0
=
f
(
0
)
g0
=
g
(
0
)
assert
f0
==
g0
==
2
,
(
f0
,
g0
)
# Increment state via g, returns the previous value
g3
=
g
(
3
)
assert
g3
==
g0
,
(
g3
,
g0
)
f0
=
f
(
0
)
g0
=
g
(
0
)
assert
f0
==
g0
==
5
,
(
f0
,
g0
)
vstate
=
theano
.
shared
(
numpy
.
zeros
(
3
,
dtype
=
'int32'
))
vstate
.
name
=
'vstate'
fv
=
theano
.
function
([
inc
],
vstate
,
updates
=
[(
vstate
,
vstate
+
inc
)],
mode
=
mode
)
gv
=
theano
.
function
([
inc
],
vstate
,
updates
=
[(
vstate
,
vstate
+
inc
)])
theano
.
printing
.
debugprint
(
fv
)
theano
.
printing
.
debugprint
(
gv
)
assert
numpy
.
all
(
fv
(
0
)
==
gv
(
0
)
==
0
),
(
fv
(
0
),
gv
(
0
))
# Initial value
fv0
=
fv
(
0
)
gv0
=
gv
(
0
)
assert
numpy
.
all
(
fv0
==
0
),
fv0
assert
numpy
.
all
(
gv0
==
0
),
gv0
# Increment state via f, returns the previous value.
fv2
=
fv
(
2
)
assert
numpy
.
all
(
fv2
==
fv0
),
(
fv2
,
fv0
)
fv0
=
fv
(
0
)
gv0
=
gv
(
0
)
assert
numpy
.
all
(
fv0
==
2
),
fv0
assert
numpy
.
all
(
gv0
==
2
),
gv0
# Increment state via g, returns the previous value
gv3
=
gv
(
3
)
assert
numpy
.
all
(
gv3
==
gv0
),
(
gv3
,
gv0
)
fv0
=
fv
(
0
)
gv0
=
gv
(
0
)
assert
numpy
.
all
(
fv0
==
5
),
fv0
assert
numpy
.
all
(
gv0
==
5
),
gv0
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论