Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9bcf61fa
提交
9bcf61fa
authored
4月 29, 2016
作者:
Vincent Michalski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added test case to test_local_subtensor_make_vector, where the opt inserts a node
上级
2a9da88c
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
27 行增加
和
10 行删除
+27
-10
test_opt.py
theano/tensor/tests/test_opt.py
+27
-10
没有找到文件。
theano/tensor/tests/test_opt.py
浏览文件 @
9bcf61fa
...
...
@@ -1950,12 +1950,15 @@ class test_local_subtensor_make_vector(unittest.TestCase):
x
,
y
,
z
=
tensor
.
lscalars
(
'xyz'
)
v
=
make_vector
(
x
,
y
,
z
)
# FIXME: remove the two test cases with v[0]? they are creating graphs
# without apply nodes, which don't require check_stack_trace.
# Compile function using only the 'local_subtensor_make_vector' optimization,
# which requires us to add the 'canonicalize' phase.
mode
=
theano
.
compile
.
mode
.
Mode
(
optimizer
=
None
)
.
including
(
'canonicalize_db'
)
.
including
(
"local_subtensor_make_vector"
)
f
=
function
([
x
,
y
,
z
],
v
[
0
],
mode
=
mode
)
# Compile function using all optimizations in fast_compile mode,
# Compile function using all optimizations in fast_compile mode,
# including the 'local_subtensor_make_vector' optimization
mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_COMPILE'
)
.
including
(
"local_subtensor_make_vector"
)
f
=
function
([
x
,
y
,
z
],
v
[
0
],
mode
=
mode
)
...
...
@@ -1963,7 +1966,21 @@ class test_local_subtensor_make_vector(unittest.TestCase):
# The two cases in this test do not check the case where
# local_subtensor_make_vector inserts a Subtensor node (See issue #4421)
# self.assertTrue(check_stack_trace(f, ops_to_check='all'))
# Cases, in which local_subtensor_make_vector adds a new MakeVector
# node
# Compile function using only the 'local_subtensor_make_vector' optimization,
# which requires us to add the 'canonicalize' phase.
mode
=
theano
.
compile
.
mode
.
Mode
(
optimizer
=
None
)
.
including
(
'canonicalize_db'
)
.
including
(
"local_subtensor_make_vector"
)
f
=
function
([
x
,
y
,
z
],
v
[::
2
],
mode
=
mode
)
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
'all'
))
# Compile function using all optimizations in fast_compile mode,
# including the 'local_subtensor_make_vector' optimization
mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_COMPILE'
)
.
including
(
"local_subtensor_make_vector"
)
f
=
function
([
x
,
y
,
z
],
v
[::
2
],
mode
=
mode
)
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
'all'
))
class
test_local_subtensor_lift
(
unittest
.
TestCase
):
def
test0
(
self
):
...
...
@@ -2805,7 +2822,7 @@ class test_local_adv_sub1_adv_inc_sub1(unittest.TestCase):
f
=
theano
.
function
([
x
,
y
,
idx
],
o
,
self
.
mode
)
# The opt only removes nodes in this case, no check_stack_trace needed
# Compile function using all optimizations in fast_compile mode,
# Compile function using all optimizations in fast_compile mode,
# including the 'local_subtensor_make_vector' optimization
mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_COMPILE'
)
.
including
(
"local_adv_sub1_adv_inc_sub1"
)
f
=
theano
.
function
([
x
,
y
,
idx
],
o
,
self
.
mode
)
...
...
@@ -3020,7 +3037,7 @@ def test_local_IncSubtensor_serialize():
assert
check_stack_trace
(
f
,
ops_to_check
=
[
tensor
.
IncSubtensor
,
tensor
.
AdvancedIncSubtensor
,
tensor
.
AdvancedIncSubtensor1
])
def
test_local_set_to_inc_subtensor
():
v
=
theano
.
tensor
.
fmatrix
()
s
=
v
[[
2
,
1
]]
...
...
@@ -3053,8 +3070,8 @@ def test_local_set_to_inc_subtensor():
# before and after optimization.
assert
check_stack_trace
(
f1
,
ops_to_check
=
tensor
.
AdvancedIncSubtensor1
)
assert
check_stack_trace
(
f2
,
ops_to_check
=
'all'
)
def
test_local_subtensor_of_dot
():
m1
=
theano
.
tensor
.
matrix
()
m2
=
theano
.
tensor
.
matrix
()
...
...
@@ -3724,11 +3741,11 @@ class Test_local_useless_inc_subtensor_alloc(unittest.TestCase):
r2
=
f2
(
x_value
,
i_value
,
y_value
)
utt
.
assert_allclose
(
r1
,
r2
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f1
,
ops_to_check
=
tensor
.
AdvancedIncSubtensor
))
self
.
assertTrue
(
check_stack_trace
(
f2
,
ops_to_check
=
tensor
.
AdvancedIncSubtensor
))
def
test_advanced_inc_subtensor1
(
self
):
if
tensor
.
inplace_increment
is
None
:
...
...
@@ -3758,7 +3775,7 @@ class Test_local_useless_inc_subtensor_alloc(unittest.TestCase):
r2
=
f2
(
x_value
,
i_value
,
y_value
)
utt
.
assert_allclose
(
r1
,
r2
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f1
,
ops_to_check
=
tensor
.
AdvancedIncSubtensor1
))
...
...
@@ -3789,7 +3806,7 @@ class Test_local_useless_inc_subtensor_alloc(unittest.TestCase):
r2
=
f2
(
x_value
,
i_value
,
y_value
)
utt
.
assert_allclose
(
r1
,
r2
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f1
,
ops_to_check
=
'last'
))
self
.
assertTrue
(
check_stack_trace
(
f2
,
ops_to_check
=
'last'
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论