提交 2bf6d218 authored 作者: Frederic Bastien's avatar Frederic Bastien 提交者: Frederic

[BUG] Scan now correctly raise error when it get negative steps or 0 steps.

fix gh-1455 by making all version raise an error. (But not always the same error). This also fix the problem where test_rop where randomly returning some bad answer, but making that case return an error (0 step in scan). We still need to find why the scan save mem sometimes generated scan with 0 step.
上级 5bda83ef
...@@ -835,15 +835,14 @@ class Scan(PureOp): ...@@ -835,15 +835,14 @@ class Scan(PureOp):
n_steps = args[0] n_steps = args[0]
seqs = [] seqs = []
if n_steps < 0: if n_steps < 0:
n_steps = abs(n_steps) # History, in the past, this was used for backward
for idx, seq in enumerate(args[1:self.seqs_arg_offset]): # scan. Now we reverse the inputs outside of scan.
if seq.shape[0] < n_steps: raise IndexError(
raise ValueError(('Sequence is shorter then the required ' "Scan was asked to run for negative number of step %d" %
'number of steps : (n_steps, seq, ' n_steps)
'seq.shape):'), n_steps, elif n_steps == 0:
node.inputs[1 + idx], raise NotImplementedError(
seq.shape) "We didn't implemented yet the case where scan do 0 iteration")
seqs.append(seq[::-1])
else: else:
for idx, seq in enumerate(args[1:self.seqs_arg_offset]): for idx, seq in enumerate(args[1:self.seqs_arg_offset]):
if seq.shape[0] < n_steps: if seq.shape[0] < n_steps:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论