Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4a1fc766
提交
4a1fc766
authored
12月 23, 2016
作者:
Iulian Vlad Serban
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implemented Pascals comments. Improved test for local_elemwise_sub_zeros.
上级
ac601d00
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
8 行增加
和
15 行删除
+8
-15
opt.py
theano/tensor/opt.py
+0
-9
test_opt.py
theano/tensor/tests/test_opt.py
+8
-6
没有找到文件。
theano/tensor/opt.py
浏览文件 @
4a1fc766
...
@@ -4299,9 +4299,6 @@ def local_useless_reshape(node):
...
@@ -4299,9 +4299,6 @@ def local_useless_reshape(node):
# This could hide errors if the user provides inconsistent shapes.
# This could hide errors if the user provides inconsistent shapes.
if
(
input
.
ndim
==
1
and
output
.
ndim
==
1
and
if
(
input
.
ndim
==
1
and
output
.
ndim
==
1
and
input
.
broadcastable
==
output
.
broadcastable
):
input
.
broadcastable
==
output
.
broadcastable
):
# Copy over stack trace
copy_stack_trace
(
node
.
outputs
[
0
],
input
)
return
[
input
]
return
[
input
]
# Second case: all the shapes match the input shape
# Second case: all the shapes match the input shape
...
@@ -4309,9 +4306,6 @@ def local_useless_reshape(node):
...
@@ -4309,9 +4306,6 @@ def local_useless_reshape(node):
if
output_shape
.
owner
and
isinstance
(
output_shape
.
owner
.
op
,
Shape
):
if
output_shape
.
owner
and
isinstance
(
output_shape
.
owner
.
op
,
Shape
):
shape_input
=
output_shape
.
owner
.
inputs
[
0
]
shape_input
=
output_shape
.
owner
.
inputs
[
0
]
if
shape_input
==
input
:
if
shape_input
==
input
:
# Copy over stack trace
copy_stack_trace
(
node
.
outputs
[
0
],
input
)
return
[
input
]
return
[
input
]
# Match Reshape(x, [x.shape[0], ..., x.shape[-1]]), accounting for
# Match Reshape(x, [x.shape[0], ..., x.shape[-1]]), accounting for
...
@@ -4362,9 +4356,6 @@ def local_useless_reshape(node):
...
@@ -4362,9 +4356,6 @@ def local_useless_reshape(node):
continue
continue
if
all
(
shape_match
):
if
all
(
shape_match
):
# Copy over stack trace
copy_stack_trace
(
node
.
outputs
[
0
],
input
)
return
[
input
]
return
[
input
]
# TODO later: if all the shapes except one match, we may want to
# TODO later: if all the shapes except one match, we may want to
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
4a1fc766
...
@@ -3502,6 +3502,8 @@ def test_local_elemwise_sub_zeros():
...
@@ -3502,6 +3502,8 @@ def test_local_elemwise_sub_zeros():
f
=
function
([
scalar
],
scalar
-
scalar
,
mode
=
mode
)
f
=
function
([
scalar
],
scalar
-
scalar
,
mode
=
mode
)
# Check optimized graph is correct
# Check optimized graph is correct
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
op
,
T
.
Elemwise
)
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
op
,
T
.
Elemwise
)
assert
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
op
.
name
\
==
'Elemwise{second,no_inplace}'
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
inputs
[
1
],
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
inputs
[
1
],
T
.
TensorConstant
)
or
\
T
.
TensorConstant
)
or
\
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
inputs
[
1
],
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
inputs
[
1
],
...
@@ -3514,6 +3516,8 @@ def test_local_elemwise_sub_zeros():
...
@@ -3514,6 +3516,8 @@ def test_local_elemwise_sub_zeros():
f
=
function
([
vect
],
vect
-
vect
,
mode
=
mode
)
f
=
function
([
vect
],
vect
-
vect
,
mode
=
mode
)
# Check optimized graph is correct
# Check optimized graph is correct
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
op
,
T
.
Elemwise
)
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
op
,
T
.
Elemwise
)
assert
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
op
.
name
\
==
'Elemwise{second,no_inplace}'
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
inputs
[
1
],
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
inputs
[
1
],
T
.
TensorConstant
)
or
\
T
.
TensorConstant
)
or
\
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
inputs
[
1
],
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
inputs
[
1
],
...
@@ -3526,6 +3530,8 @@ def test_local_elemwise_sub_zeros():
...
@@ -3526,6 +3530,8 @@ def test_local_elemwise_sub_zeros():
f
=
function
([
mat
],
mat
-
mat
,
mode
=
mode
)
f
=
function
([
mat
],
mat
-
mat
,
mode
=
mode
)
# Check optimized graph is correct
# Check optimized graph is correct
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
op
,
T
.
Elemwise
)
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
op
,
T
.
Elemwise
)
assert
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
op
.
name
\
==
'Elemwise{second,no_inplace}'
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
inputs
[
1
],
assert
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
inputs
[
1
],
T
.
TensorConstant
)
or
\
T
.
TensorConstant
)
or
\
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
inputs
[
1
],
isinstance
(
f
.
maker
.
fgraph
.
toposort
()[
0
]
.
inputs
[
1
],
...
@@ -5416,8 +5422,6 @@ class T_local_sum_prod(unittest.TestCase):
...
@@ -5416,8 +5422,6 @@ class T_local_sum_prod(unittest.TestCase):
(
s1_val
*
s2_val
*
v_val
*
m_val
)
.
prod
(),
2
)
(
s1_val
*
s2_val
*
v_val
*
m_val
)
.
prod
(),
2
)
def
test_local_sum_prod_all_to_none
(
self
):
def
test_local_sum_prod_all_to_none
(
self
):
# Julian: It appears that the opt local_sum_prod_mul_by_scalar
# is never used in any of these tests...
a
=
T
.
tensor3
()
a
=
T
.
tensor3
()
input
=
numpy
.
arange
(
3
*
4
*
5
,
dtype
=
config
.
floatX
)
.
reshape
(
3
,
4
,
5
)
input
=
numpy
.
arange
(
3
*
4
*
5
,
dtype
=
config
.
floatX
)
.
reshape
(
3
,
4
,
5
)
# test sum
# test sum
...
@@ -5652,10 +5656,8 @@ class T_local_sum_prod(unittest.TestCase):
...
@@ -5652,10 +5656,8 @@ class T_local_sum_prod(unittest.TestCase):
finally
:
finally
:
config
.
on_opt_error
=
backup
config
.
on_opt_error
=
backup
def
test_stack_trace
(
self
):
def
test_local_sum_prod_mul_by_scalar_stack_trace
(
self
):
"""
# Test that stack trace is copied over correctly for local_sum_prod_mul_by_scalar.
Test that stack trace is copied over correctly.
"""
m0
=
theano
.
compile
.
get_default_mode
()
\
m0
=
theano
.
compile
.
get_default_mode
()
\
.
excluding
(
'inplace_elemwise_opt'
)
\
.
excluding
(
'inplace_elemwise_opt'
)
\
.
including
(
'canonicalize'
,
'specialize'
)
.
including
(
'canonicalize'
,
'specialize'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论