Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ec2dab80
提交
ec2dab80
authored
11月 11, 2016
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix issue in local_subtensor_incsubtensor
The replacement was not correct when there were explicitly broadcastable dimensions, or if the dtype changed.
上级
ecfc65ec
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
6 行删除
+14
-6
opt.py
theano/tensor/opt.py
+14
-6
没有找到文件。
theano/tensor/opt.py
浏览文件 @
ec2dab80
...
...
@@ -1910,14 +1910,22 @@ def local_subtensor_inc_subtensor(node):
if
not
x
.
owner
.
op
.
set_instead_of_inc
:
return
if
x
.
owner
.
inputs
[
2
:]
==
node
.
inputs
[
1
:]
and
tuple
(
x
.
owner
.
op
.
idx_list
)
==
tuple
(
node
.
op
.
idx_list
):
# if x[idx] and y have the same ndim (and shape), directly return y
if
x
.
owner
.
inputs
[
0
]
.
ndim
-
(
len
(
node
.
op
.
idx_list
)
-
sum
([
isinstance
(
idx
,
slice
)
for
idx
in
node
.
op
.
idx_list
]))
==
x
.
owner
.
inputs
[
1
]
.
ndim
:
return
[
x
.
owner
.
inputs
[
1
]]
# else y is broadcastable, return alloc of broadcastable y
if
(
x
.
owner
.
inputs
[
2
:]
==
node
.
inputs
[
1
:]
and
tuple
(
x
.
owner
.
op
.
idx_list
)
==
tuple
(
node
.
op
.
idx_list
)):
out
=
node
.
outputs
[
0
]
y
=
x
.
owner
.
inputs
[
1
]
# If the dtypes differ, cast y into x.dtype
if
x
.
dtype
!=
y
.
dtype
:
y
=
y
.
astype
(
x
.
dtype
)
if
out
.
type
==
y
.
type
:
# if x[idx] and y have the same type, directly return y
return
[
y
]
else
:
# The difference is related to broadcasting pattern
assert
out
.
broadcastable
!=
y
.
broadcastable
# We have to alloc y to the shape of x[idx]
x_subtensor
=
node
.
op
(
x
.
owner
.
inputs
[
0
],
*
x
.
owner
.
inputs
[
2
:])
return
[
T
.
alloc
(
x
.
owner
.
inputs
[
1
]
,
*
x_subtensor
.
shape
)]
return
[
T
.
alloc
(
y
,
*
x_subtensor
.
shape
)]
else
:
return
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论