提交 1d53a4aa authored 作者: carriepl's avatar carriepl

Rearrange numbering of the steps in the Scan backends

上级 9a281ed6
...@@ -1297,7 +1297,7 @@ class Scan(PureOp): ...@@ -1297,7 +1297,7 @@ class Scan(PureOp):
else: else:
old_input_data[idx] = None old_input_data[idx] = None
# 5.0.1 compute outputs # 5.1 compute outputs
t0_fn = time.time() t0_fn = time.time()
try: try:
...@@ -1326,7 +1326,7 @@ class Scan(PureOp): ...@@ -1326,7 +1326,7 @@ class Scan(PureOp):
pdx = offset + self.n_shared_outs pdx = offset + self.n_shared_outs
cond = output_storage[pdx].storage[0] == 0 cond = output_storage[pdx].storage[0] == 0
# 5.0.2. By calling fn() directly instead of calling the theano # 5.2. By calling fn() directly instead of calling the theano
# function, it is possible that the updates have not been # function, it is possible that the updates have not been
# performed. Perform the updates if needed. # performed. Perform the updates if needed.
offset_out = len(output_storage) - 1 offset_out = len(output_storage) - 1
...@@ -1338,7 +1338,7 @@ class Scan(PureOp): ...@@ -1338,7 +1338,7 @@ class Scan(PureOp):
storage.data = output_storage[offset_out].data storage.data = output_storage[offset_out].data
offset_out -= 1 offset_out -= 1
# 5.0.3. Check which of the pre-allocated outputs (if applicable) # 5.3. Check which of the pre-allocated outputs (if applicable)
# have been reused by the inner function # have been reused by the inner function
for idx in xrange(len(output_storage)): for idx in xrange(len(output_storage)):
# If the storage map does not contain the same object, then # If the storage map does not contain the same object, then
...@@ -1361,7 +1361,7 @@ class Scan(PureOp): ...@@ -1361,7 +1361,7 @@ class Scan(PureOp):
else: else:
output_reused[idx] = False output_reused[idx] = False
# 5.0.4 Check which of the input storage have been modified by the # 5.4 Check which of the input storage have been modified by the
# inner function # inner function
for idx in xrange(len(input_storage)): for idx in xrange(len(input_storage)):
# If the storage map does not contain the same object, then # If the storage map does not contain the same object, then
...@@ -1388,7 +1388,7 @@ class Scan(PureOp): ...@@ -1388,7 +1388,7 @@ class Scan(PureOp):
t_fn += dt_fn t_fn += dt_fn
offset_out = 0 offset_out = 0
# 5.1 Copy over the values for mit_mot outputs # 5.5 Copy over the values for mit_mot outputs
mitmot_inp_offset = self.n_seqs mitmot_inp_offset = self.n_seqs
mitmot_out_idx = 0 mitmot_out_idx = 0
for j in xrange(self.n_mit_mot): for j in xrange(self.n_mit_mot):
...@@ -1415,7 +1415,7 @@ class Scan(PureOp): ...@@ -1415,7 +1415,7 @@ class Scan(PureOp):
mitmot_inp_offset += len(self.tap_array[j]) mitmot_inp_offset += len(self.tap_array[j])
# 5.2 Copy over the values for mit_sot/sit_sot outputs # 5.6 Copy over the values for mit_sot/sit_sot outputs
begin = self.n_mit_mot begin = self.n_mit_mot
end = self.n_outs end = self.n_outs
offset_out -= self.n_mit_mot offset_out -= self.n_mit_mot
...@@ -1426,7 +1426,7 @@ class Scan(PureOp): ...@@ -1426,7 +1426,7 @@ class Scan(PureOp):
outs[j][0][pos[j]] = \ outs[j][0][pos[j]] = \
output_storage[offset_out + j].storage[0] output_storage[offset_out + j].storage[0]
# 5.3 Copy over the values for nit_sot outputs # 5.7 Copy over the values for nit_sot outputs
begin = end begin = end
end += self.n_nit_sot end += self.n_nit_sot
for j in xrange(begin, end): for j in xrange(begin, end):
...@@ -1450,7 +1450,7 @@ class Scan(PureOp): ...@@ -1450,7 +1450,7 @@ class Scan(PureOp):
outs[j][0][pos[j]] = \ outs[j][0][pos[j]] = \
output_storage[j + offset_out].storage[0] output_storage[j + offset_out].storage[0]
# 5.4 Copy over the values for outputs corresponding to shared # 5.8 Copy over the values for outputs corresponding to shared
# variables # variables
begin = end begin = end
end += self.n_shared_outs end += self.n_shared_outs
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -382,7 +382,7 @@ def perform( ...@@ -382,7 +382,7 @@ def perform(
else: else:
old_input_data[idx] = None old_input_data[idx] = None
# 5.0.1 compute outputs # 5.1 compute outputs
t0_fn = time.time() t0_fn = time.time()
try: try:
...@@ -403,7 +403,7 @@ def perform( ...@@ -403,7 +403,7 @@ def perform(
pdx = offset + n_shared_outs pdx = offset + n_shared_outs
cond = output_storage[pdx].storage[0] == 0 cond = output_storage[pdx].storage[0] == 0
# 5.0.2. By calling fn() directly instead of calling the theano # 5.2. By calling fn() directly instead of calling the theano
# function, it is possible that the updates have not been # function, it is possible that the updates have not been
# performed. Perform the updates if needed. # performed. Perform the updates if needed.
offset_out = len(output_storage) - 1 offset_out = len(output_storage) - 1
...@@ -415,7 +415,7 @@ def perform( ...@@ -415,7 +415,7 @@ def perform(
storage.data = output_storage[offset_out].data storage.data = output_storage[offset_out].data
offset_out -= 1 offset_out -= 1
# 5.0.3. Check which of the pre-allocated outputs (if applicable) # 5.3. Check which of the pre-allocated outputs (if applicable)
# have been reused by the inner function # have been reused by the inner function
for idx in range(len_output_storage): for idx in range(len_output_storage):
# If the storage map does not contain the same object, then # If the storage map does not contain the same object, then
...@@ -438,7 +438,7 @@ def perform( ...@@ -438,7 +438,7 @@ def perform(
else: else:
output_reused[idx] = False output_reused[idx] = False
# 5.0.4. Check which of the input storage have been modified by the # 5.4. Check which of the input storage have been modified by the
# inner function # inner function
for idx in xrange(len(input_storage)): for idx in xrange(len(input_storage)):
# If the storage map does not contain the same object, then # If the storage map does not contain the same object, then
...@@ -461,9 +461,8 @@ def perform( ...@@ -461,9 +461,8 @@ def perform(
else: else:
input_reused[idx] = False input_reused[idx] = False
offset_out = 0 offset_out = 0
# 5.1 Copy over the values for mit_mot outputs # 5.5 Copy over the values for mit_mot outputs
mitmot_inp_offset = self.n_seqs mitmot_inp_offset = self.n_seqs
mitmot_out_idx = 0 mitmot_out_idx = 0
for j in xrange(self.n_mit_mot): for j in xrange(self.n_mit_mot):
...@@ -490,7 +489,7 @@ def perform( ...@@ -490,7 +489,7 @@ def perform(
mitmot_inp_offset += len(self.tap_array[j]) mitmot_inp_offset += len(self.tap_array[j])
# 5.2 Copy over the values for mit_sot/sit_sot outputs # 5.6 Copy over the values for mit_sot/sit_sot outputs
begin = n_mit_mot begin = n_mit_mot
end = n_outs end = n_outs
offset_out -= n_mit_mot offset_out -= n_mit_mot
...@@ -501,7 +500,7 @@ def perform( ...@@ -501,7 +500,7 @@ def perform(
outs[j][0][pos[j]] = output_storage[<unsigned int>(offset_out+j)].storage[0] outs[j][0][pos[j]] = output_storage[<unsigned int>(offset_out+j)].storage[0]
# 5.3 Copy over the values for nit_sot outputs # 5.7 Copy over the values for nit_sot outputs
begin = end begin = end
end += n_nit_sot end += n_nit_sot
for j in range(begin,end): for j in range(begin,end):
...@@ -523,8 +522,7 @@ def perform( ...@@ -523,8 +522,7 @@ def perform(
not output_reused[<unsigned int>(offset_out+j)]): not output_reused[<unsigned int>(offset_out+j)]):
outs[j][0][pos[j]] = output_storage[j+offset_out].storage[0] outs[j][0][pos[j]] = output_storage[j+offset_out].storage[0]
# 5.8 Copy over the values for outputs corresponding to shared
# 5.4 Copy over the values for outputs corresponding to shared
# variables # variables
begin = end begin = end
end += n_shared_outs end += n_shared_outs
...@@ -536,8 +534,6 @@ def perform( ...@@ -536,8 +534,6 @@ def perform(
pos[idx] = (pos[idx]+1)%store_steps[idx] pos[idx] = (pos[idx]+1)%store_steps[idx]
i = i + 1 i = i + 1
# 6. Check if you need to re-order output buffers # 6. Check if you need to re-order output buffers
begin = n_mit_mot begin = n_mit_mot
end = n_outs + n_nit_sot end = n_outs + n_nit_sot
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论