提交 437ef28d authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Copy output in advanced indexing Op if aliased to input

上级 6f249902
...@@ -547,7 +547,8 @@ class GpuAdvancedSubtensor(HideC, tensor.AdvancedSubtensor): ...@@ -547,7 +547,8 @@ class GpuAdvancedSubtensor(HideC, tensor.AdvancedSubtensor):
if p == 0: if p == 0:
# The only indexing was through slices and indices. # The only indexing was through slices and indices.
# This can happen with symbolic slices for instance. # This can happen with symbolic slices for instance.
out[0] = x # Since no view_map is set, we need to copy the returned value
out[0] = x.copy()
return return
# flatten the array-indexed dimensions # flatten the array-indexed dimensions
......
...@@ -2169,9 +2169,14 @@ class AdvancedSubtensor(Op): ...@@ -2169,9 +2169,14 @@ class AdvancedSubtensor(Op):
def perform(self, node, inputs, out_): def perform(self, node, inputs, out_):
out, = out_ out, = out_
# TODO: in general, we need to re-pack the inputs into a valid rval = inputs[0].__getitem__(inputs[1:])
# index, just like subtensor # When there are no arrays, we are not actually doing advanced
out[0] = inputs[0].__getitem__(inputs[1:]) # 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): def connection_pattern(self, node):
rval = [[True]] rval = [[True]]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论