提交 4d943bea authored 作者: nouiz's avatar nouiz

Merge pull request #608 from lamblin/fix_constant_advindex

Fix advanced indexing with constants (not variables)
......@@ -118,6 +118,8 @@ Crash Fix
* Fixed crash when concatenating some arrays with specific broadcasting
patterns (Olivier D.)
* Work around a known issue with nvcc 4.1 on MacOS X. (Graham Taylon)
* In advanced indexing, if some inputs are constant, no need to call constant(...)
on their value any more. (Pascal L., reported by John Salvatier)
=============
Release Notes
......
......@@ -5753,7 +5753,7 @@ class AdvancedSubtensor(Op):
if ind1.ndim == 1 and ind2.ndim == 1:
return gof.Apply(self,
(x,) + inputs,
(x, ind1, ind2),
[tensor(dtype=x.type.dtype,
broadcastable=[False])])
raise NotImplementedError(
......
......@@ -2885,6 +2885,19 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
# you enable the debug code above.
assert numpy.allclose(f_out, output_num)
def test_adv_constant_arg(self):
# Test case provided (and bug detected, gh-607) by John Salvatier
m = matrix('m')
gv = numpy.array([0, 1, 3])
g = constant(gv)
i = lvector('i')
# s1 used to fail
s1 = m[gv, i]
s2 = m[g, i]
assert gof.graph.is_same_graph(s1, s2)
class TestIncSubtensor1(unittest.TestCase):
# test inc_subtensor
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论