提交 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):
n_steps = args[0]
seqs = []
if n_steps < 0:
n_steps = abs(n_steps)
for idx, seq in enumerate(args[1:self.seqs_arg_offset]):
if seq.shape[0] < n_steps:
raise ValueError(('Sequence is shorter then the required '
'number of steps : (n_steps, seq, '
'seq.shape):'), n_steps,
node.inputs[1 + idx],
seq.shape)
seqs.append(seq[::-1])
# History, in the past, this was used for backward
# scan. Now we reverse the inputs outside of scan.
raise IndexError(
"Scan was asked to run for negative number of step %d" %
n_steps)
elif n_steps == 0:
raise NotImplementedError(
"We didn't implemented yet the case where scan do 0 iteration")
else:
for idx, seq in enumerate(args[1:self.seqs_arg_offset]):
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论