Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
bde718ca
提交
bde718ca
authored
12月 19, 2016
作者:
Iulian Vlad Serban
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tried implementing tests for local_useless_reshape, but could not.
上级
ffd31201
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
20 行增加
和
18 行删除
+20
-18
opt.py
theano/tensor/opt.py
+12
-8
test_opt.py
theano/tensor/tests/test_opt.py
+8
-10
没有找到文件。
theano/tensor/opt.py
浏览文件 @
bde718ca
...
...
@@ -4226,7 +4226,7 @@ def local_flatten_lift(node):
# Copy over stacktrace from previous output node and from unary
# elementwise output node since if there was an error, it would
# probably have come from that operation.
copy_stack_trace
(
node
.
outputs
+
node
.
inputs
,
e
)
copy_stack_trace
(
node
.
outputs
+
node
.
inputs
[
0
]
,
e
)
return
[
e
]
...
...
@@ -4289,6 +4289,10 @@ def local_useless_reshape(node):
return
False
input
=
node
.
inputs
[
0
]
# Copy over stack trace
copy_stack_trace
(
node
.
outputs
[
0
],
input
)
output
=
node
.
outputs
[
0
]
output_shape
=
node
.
inputs
[
1
]
...
...
@@ -4598,6 +4602,7 @@ def local_fill_cut(node):
# from the removed fill op, it must come from the elemntwise op.
copy_stack_trace
(
node
.
outputs
,
rval
)
if
isinstance
(
rval
,
gof
.
Variable
):
return
rval
.
owner
.
outputs
else
:
...
...
@@ -5157,10 +5162,9 @@ def local_sum_prod_mul_by_scalar(node):
new_op_input_nb_elements
=
new_op_input
.
size
new_op_output
=
node
.
op
(
new_op_input
)
if
not
len
(
non_scalars
)
==
0
:
# Copy over stacktrace from previous output to new mul op,
# for same reason as above.
copy_stack_trace
(
node
.
outputs
,
new_op_output
)
# Copy over stacktrace from previous output to new mul op,
# for same reason as above.
copy_stack_trace
(
node
.
outputs
,
new_op_output
)
# If node.op is a T.elemwise.Prod, then the scalars need to be
# raised to the power of the number of elements in the input
...
...
@@ -5186,7 +5190,7 @@ def local_sum_prod_mul_by_scalar(node):
ret
=
T
.
mul
(
*
mul_inputs
)
# Copy over stacktrace from previous output to new mul op,
# for same reason as above.
copy_stack_trace
(
node
.
outputs
,
[
ret
]
+
mul_inputs
)
copy_stack_trace
(
node
.
outputs
,
ret
+
mul_inputs
)
return
[
ret
]
...
...
@@ -5196,7 +5200,7 @@ def local_sum_prod_mul_by_scalar(node):
# There are never errors in the negative op, thus
# we need only to copy over stacktrace from previous output node to
# the two new ops.
copy_stack_trace
(
node
.
outputs
,
[
s
,
ret
]
)
copy_stack_trace
(
node
.
outputs
,
s
+
ret
)
return
[
ret
]
...
...
@@ -5212,8 +5216,8 @@ def local_elemwise_sub_zeros(node):
node
.
op
.
scalar_op
==
scalar
.
sub
and
node
.
inputs
[
0
]
==
node
.
inputs
[
1
]):
res
=
T
.
zeros_like
(
node
.
inputs
[
0
])
# Copy over stacktrace from previous output.
# Julian: Pascal, is this really necessary? Is there anyway zeros_like can ever fail?
copy_stack_trace
(
node
.
outputs
,
res
)
return
[
res
]
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
bde718ca
...
...
@@ -6294,17 +6294,17 @@ class Test_local_useless_reshape(unittest.TestCase):
topo
=
f1
.
maker
.
fgraph
.
toposort
()
assert
not
any
(
isinstance
(
n
.
op
,
tensor
.
basic
.
Reshape
)
for
n
in
topo
)
# Check stacktrace was copied over correctly after opt was applied
assert
check_stack_trace
(
f1
,
ops_to_check
=
'all'
)
# TODO: Check that stack trace is maintained.
# Currently, stack trace gets removed by some other opt.
#assert check_stack_trace(f1, ops_to_check='all')
m2
=
m0
.
excluding
(
'local_useless_reshape'
)
m2
=
m1
.
excluding
(
'ShapeOpt'
)
f2
=
theano
.
function
([
x
],
r
,
mode
=
m2
)
topo
=
f2
.
maker
.
fgraph
.
toposort
()
assert
not
any
(
isinstance
(
n
.
op
,
tensor
.
basic
.
Reshape
)
for
n
in
topo
)
# Check stacktrace was copied over correctly after opt was applied
assert
check_stack_trace
(
f2
,
ops_to_check
=
'all'
)
def
test_2
(
self
):
x
=
theano
.
tensor
.
matrix
(
'x'
)
r
=
x
.
reshape
([
Shape_i
(
i
)(
x
)
for
i
in
xrange
(
x
.
ndim
)])
...
...
@@ -6315,17 +6315,15 @@ class Test_local_useless_reshape(unittest.TestCase):
topo
=
f1
.
maker
.
fgraph
.
toposort
()
assert
not
any
(
isinstance
(
n
.
op
,
tensor
.
basic
.
Reshape
)
for
n
in
topo
)
# Check stacktrace was copied over correctly after opt was applied
assert
check_stack_trace
(
f1
,
ops_to_check
=
'all'
)
# TODO: Check that stack trace is maintained.
# Currently, stack trace gets removed by some other opt.
#assert check_stack_trace(f1, ops_to_check='all')
m2
=
m1
.
excluding
(
'ShapeOpt'
)
f2
=
theano
.
function
([
x
],
r
,
mode
=
m2
)
topo
=
f2
.
maker
.
fgraph
.
toposort
()
assert
not
any
(
isinstance
(
n
.
op
,
tensor
.
basic
.
Reshape
)
for
n
in
topo
)
# Check stacktrace was copied over correctly after opt was applied
assert
check_stack_trace
(
f2
,
ops_to_check
=
'all'
)
class
Test_local_reshape_to_dimshuffle
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论