Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
22105f78
提交
22105f78
authored
3月 07, 2016
作者:
Frederic Bastien
提交者:
Caglar
6月 08, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Repair some opt that need some digging for constant
上级
6f1afdb7
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
18 行增加
和
21 行删除
+18
-21
opt.py
theano/tensor/opt.py
+18
-21
没有找到文件。
theano/tensor/opt.py
浏览文件 @
22105f78
...
...
@@ -3206,17 +3206,14 @@ def local_incsubtensor_of_zeros(node):
y
=
node
.
inputs
[
1
]
replace
=
False
try
:
if
get_scalar_constant_value
(
y
,
only_process_constants
=
True
)
==
0
:
replace
=
True
except
NotScalarConstantError
:
pass
if
replace
:
# No need to copy over the stacktrace,
# because x should already have a stacktrace
return
[
x
]
else
:
return
False
# Don't use only_process_constants=True. We need to
# investigate Alloc of 0s but with non constant shape.
if
get_scalar_constant_value
(
y
,
elemwise
=
False
)
==
0
:
# No need to copy over the stacktrace,
# because x should already have a stacktrace
return
[
x
]
except
NotScalarConstantError
,
e
:
return
@register_canonicalize
(
'local_setsubtensor_of_allocs'
)
...
...
@@ -3232,22 +3229,20 @@ def local_setsubtensor_of_constants(node):
if
isinstance
(
node
.
op
,
IncSubtensor
)
and
node
.
op
.
set_instead_of_inc
:
x
=
node
.
inputs
[
0
]
y
=
node
.
inputs
[
1
]
replace_x
=
None
replace_y
=
None
# Don't use only_process_constants=True. We need to
# investigate Alloc of 0s but with non constant shape.
try
:
replace_x
=
get_scalar_constant_value
(
x
,
only_process_constants
=
Tru
e
)
replace_x
=
get_scalar_constant_value
(
x
,
elemwise
=
Fals
e
)
except
NotScalarConstantError
:
pass
return
try
:
replace_y
=
get_scalar_constant_value
(
y
,
only_process_constants
=
Tru
e
)
replace_y
=
get_scalar_constant_value
(
y
,
elemwise
=
Fals
e
)
except
NotScalarConstantError
:
pass
return
if
(
replace_x
is
not
None
and
replace_y
is
not
None
and
replace_x
==
replace_y
):
if
replace_x
==
replace_y
:
# No need to copy over the stacktrace,
# because x should already have a stacktrace
...
...
@@ -3285,7 +3280,9 @@ def local_adv_sub1_adv_inc_sub1(node):
if
idx
is
not
idx2
:
return
if
(
not
inp
.
owner
.
op
.
set_instead_of_inc
and
T
.
extract_constant
(
x
,
only_process_constants
=
True
)
!=
0
):
# Don't use only_process_constants=True. We need to
# investigate Alloc of 0s but with non constant shape.
T
.
extract_constant
(
x
,
elemwise
=
False
)
!=
0
):
return
cond
=
[
T
.
all
(
T
.
and_
(
T
.
lt
(
idx
,
x
.
shape
[
0
]),
T
.
ge
(
idx
,
-
x
.
shape
[
0
])))]
if
not
node
.
fgraph
.
shape_feature
.
same_shape
(
idx
,
y
,
0
,
0
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论