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