提交 e4685794 authored 作者: carriepl's avatar carriepl

Give default update to In variables (warning in debugmode)

上级 8ae84a3c
...@@ -762,6 +762,7 @@ class Scan(PureOp): ...@@ -762,6 +762,7 @@ class Scan(PureOp):
for mitmot_idx in range(self.n_mit_mot): for mitmot_idx in range(self.n_mit_mot):
for inp_tap in self.tap_array[mitmot_idx]: for inp_tap in self.tap_array[mitmot_idx]:
if inp_tap in self.mit_mot_out_slices[mitmot_idx]: if inp_tap in self.mit_mot_out_slices[mitmot_idx]:
inp = self.inputs[input_idx]
# Figure out the index of the corresponding output # Figure out the index of the corresponding output
output_idx = sum([len(m) for m in output_idx = sum([len(m) for m in
...@@ -770,8 +771,12 @@ class Scan(PureOp): ...@@ -770,8 +771,12 @@ class Scan(PureOp):
# Make it so the input is automatically updated to the # Make it so the input is automatically updated to the
# output value, possibly inplace, at the end of the # output value, possibly inplace, at the end of the
# function exectution # function exectution. Also, since an update is
wrapped_inp = In(variable=self.inputs[input_idx], # defined, a default value must also be. Use an array
# of size 0 but the right ndim and dtype.
default_val = numpy.zeros([0] * inp.ndim,
dtype=inp.dtype)
wrapped_inp = In(variable=inp, value=default_val,
update=self.outputs[output_idx]) update=self.outputs[output_idx])
wrapped_inputs.append(wrapped_inp) wrapped_inputs.append(wrapped_inp)
preallocated_mitmot_outs.append(output_idx) preallocated_mitmot_outs.append(output_idx)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论