Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ddafc3e2
提交
ddafc3e2
authored
5月 02, 2017
作者:
Pascal Lamblin
提交者:
GitHub
5月 02, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5903 from lamblin/fix_5898
[BUG,CRASH] Fix crash in GPU advanced indexing with no arrays
上级
d6dbce90
437ef28d
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
23 行增加
和
3 行删除
+23
-3
subtensor.py
theano/gpuarray/subtensor.py
+7
-0
subtensor.py
theano/tensor/subtensor.py
+8
-3
test_subtensor.py
theano/tensor/tests/test_subtensor.py
+8
-0
没有找到文件。
theano/gpuarray/subtensor.py
浏览文件 @
ddafc3e2
...
...
@@ -544,6 +544,13 @@ class GpuAdvancedSubtensor(HideC, tensor.AdvancedSubtensor):
idx_
=
([
slice
(
None
)]
*
p
+
nidx
[
p
:])
x
=
x
.
__getitem__
(
idx_
)
if
p
==
0
:
# The only indexing was through slices and indices.
# This can happen with symbolic slices for instance.
# Since no view_map is set, we need to copy the returned value
out
[
0
]
=
x
.
copy
()
return
# flatten the array-indexed dimensions
shape
=
((
np
.
prod
(
x
.
shape
[
0
:
p
]),)
+
x
.
shape
[
p
:])
...
...
theano/tensor/subtensor.py
浏览文件 @
ddafc3e2
...
...
@@ -2169,9 +2169,14 @@ class AdvancedSubtensor(Op):
def
perform
(
self
,
node
,
inputs
,
out_
):
out
,
=
out_
# TODO: in general, we need to re-pack the inputs into a valid
# index, just like subtensor
out
[
0
]
=
inputs
[
0
]
.
__getitem__
(
inputs
[
1
:])
rval
=
inputs
[
0
]
.
__getitem__
(
inputs
[
1
:])
# When there are no arrays, we are not actually doing advanced
# indexing, so __getitem__ will not return a copy.
# Since no view_map is set, we need to copy the returned value
if
not
any
(
isinstance
(
v
.
type
,
TensorType
)
and
v
.
ndim
>
0
for
v
in
node
.
inputs
[
1
:]):
rval
=
rval
.
copy
()
out
[
0
]
=
rval
def
connection_pattern
(
self
,
node
):
rval
=
[[
True
]]
...
...
theano/tensor/tests/test_subtensor.py
浏览文件 @
ddafc3e2
...
...
@@ -1623,6 +1623,14 @@ class TestAdvancedSubtensor(unittest.TestCase):
out
=
X
[
b_idx
,
r_idx
,
c_idx
]
.
eval
({
X
:
xx
})
utt
.
assert_allclose
(
out
,
xx
[
b_idx
,
r_idx
,
c_idx
])
def
test_adv_sub_slice
(
self
):
# Reported in https://github.com/Theano/Theano/issues/5898
var
=
self
.
shared
(
np
.
zeros
([
3
,
3
],
dtype
=
config
.
floatX
))
slc
=
tensor
.
slicetype
()
f
=
theano
.
function
([
slc
],
var
[
slc
])
s
=
slice
(
1
,
3
)
f
(
s
)
def
test_grad
(
self
):
ones
=
np
.
ones
((
1
,
3
),
dtype
=
self
.
dtype
)
n
=
self
.
shared
(
ones
*
5
,
broadcastable
=
(
True
,
False
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论