提交 aa13f74f authored 作者: nouiz's avatar nouiz

Merge pull request #634 from pascanur/fix_scan_debugmode

Fix scan debugmode
......@@ -949,7 +949,6 @@ def scan(fn,
info['truncate_gradient'] = truncate_gradient
info['name'] = name
info['mode'] = mode
info['inplace'] = -1
info['destroy_map'] = {}
info['gpu'] = False
info['as_while'] = as_while
......
......@@ -528,6 +528,10 @@ class Scan(PureOp):
dtype='int32')
cython_vector_outs = numpy.asarray(self.vector_outs,
dtype='int32')
cython_destroy_map = [x in self.destroy_map
for x in xrange(len(node.outputs))]
cython_destroy_map = numpy.asarray(cython_destroy_map,
dtype='int32')
import scan_perform_ext
p = lambda node, args, outs:\
scan_perform_ext.perform(
......@@ -549,7 +553,7 @@ class Scan(PureOp):
cython_mit_mot_out_nslices,
self.fn.fn,
self.fn,
self.inplace,
cython_destroy_map,
args,
outs,
self)
......@@ -782,7 +786,7 @@ class Scan(PureOp):
in xrange(self.n_outs + self.n_nit_sot)]
# 2.1 Create storage space for outputs
for idx in xrange(self.n_outs):
if self.inplace:
if idx in self.destroy_map:
# ^ Case 1. Outputs should be computed inplace of their
# initial state
outs[idx][0] = args[self.seqs_arg_offset + idx]
......@@ -1451,7 +1455,6 @@ class Scan(PureOp):
else:
info['name'] = None
info['mode'] = self.mode
info['inplace'] = False
n_mit_sot = 0
n_sit_sot = 0
......@@ -1552,7 +1555,6 @@ class Scan(PureOp):
else:
info['name'] = None
info['mode'] = self.mode
info['inplace'] = False
info['mit_mot_out_slices'] = self.mit_mot_out_slices * 2
new_tap_array = []
b = 0
......
......@@ -867,7 +867,6 @@ class ScanMerge(gof.Optimizer):
info['truncate_gradient'] = nodes[0].op.truncate_gradient
info['name'] = '&'.join([nd.op.name for nd in nodes])
info['mode'] = nodes[0].op.mode
info['inplace'] = False
info['gpu'] = False
info['as_while'] = as_while
info['profile'] = nodes[0].op.profile
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -63,7 +63,7 @@ from theano.sandbox import cuda
def get_version():
return 0.266
return 0.276
@cython.boundscheck(False)
def perform(
......@@ -85,7 +85,7 @@ def perform(
numpy.ndarray[numpy.int32_t,ndim=1] mit_mot_out_nslices,
fn,
fnct,
bint inplace,
numpy.ndarray[numpy.int32_t,ndim=1] destroy_map,
args,
outs,
self):
......@@ -145,9 +145,8 @@ def perform(
fnct: python object
Only used to attach some timings for the profile mode ( can be
skiped if we don't care about Theano's profile mode)
inplace
Boolean that says if things should be computed inplace or if they
should not.
destroy_map
Array of boolean saying if an output is computed inplace
args: list of ndarrays (and random states)
The inputs of scan in a given order ( n_steps, sequences, mit_mot,
mit_sot, sit_sot, nit_sot, shared_outs, other_args)
......@@ -230,7 +229,7 @@ def perform(
# 2.1 Create storage space for outputs
for idx in range(n_outs):
if inplace:
if destroy_map[idx] != 0:
# ^ Case 1. Outputs should be computed inplace of their
# initial state
outs[idx][0] = args[ <unsigned int>(1+ n_seqs + idx)]
......
......@@ -14,7 +14,7 @@ logging.basicConfig(level=logging.DEBUG)
if config.compiledir not in sys.path:
sys.path.append(config.compiledir)
version = 0.266 # must match constant returned in function get_version()
version = 0.276 # must match constant returned in function get_version()
need_reload = False
try:
......
......@@ -592,7 +592,6 @@ def compress_outs(op, not_required, inputs):
info['n_nit_sot'] = 0
info['truncate_gradient'] = op.info['truncate_gradient']
info['name'] = op.info['name']
info['inplace'] = op.info['inplace']
info['gpu'] = op.info['gpu']
info['mode'] = op.info['mode']
info['as_while'] = op.info['as_while']
......@@ -857,8 +856,9 @@ class scan_args(object):
q += n_shared_outs
self.other_info = dict()
for k in ('truncate_gradient', 'name', 'mode', 'inplace',
for k in ('truncate_gradient', 'name', 'mode', 'destroy_map',
'gpu', 'as_while', 'profile'):
if k in info:
self.other_info[k] = info[k]
inner_inputs = property(lambda self: (self.inner_in_seqs +
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论