提交 26330e79 authored 作者: Frederic Bastien's avatar Frederic Bastien

white space/indentation fix.

上级 a800d64a
...@@ -380,9 +380,9 @@ class Function(object): ...@@ -380,9 +380,9 @@ class Function(object):
finder[i] = c finder[i] = c
finder[input.variable] = c finder[input.variable] = c
if input.name not in finder: if input.name not in finder:
finder[input.name] = c finder[input.name] = c
else: else:
finder[input.name] = DUPLICATE finder[input.name] = DUPLICATE
if input.name is None: if input.name is None:
n_unnamed_inputs += 1 n_unnamed_inputs += 1
else: else:
...@@ -408,9 +408,9 @@ class Function(object): ...@@ -408,9 +408,9 @@ class Function(object):
finder[i] = f finder[i] = f
finder[input] = f finder[input] = f
if input.name not in finder: if input.name not in finder:
finder[input.name] = f finder[input.name] = f
else: else:
finder[input.name] = DUPLICATE finder[input.name] = DUPLICATE
#backport #backport
#finder[input.name] = f if input.name not in finder else DUPLICATE #finder[input.name] = f if input.name not in finder else DUPLICATE
#setters.append(f) #setters.append(f)
...@@ -421,9 +421,9 @@ class Function(object): ...@@ -421,9 +421,9 @@ class Function(object):
finder[sin.variable] = c finder[sin.variable] = c
finder[sin.name] = c finder[sin.name] = c
if sin.name not in finder: if sin.name not in finder:
finder[sin.name] = c finder[sin.name] = c
else: else:
finder[sin.name] = DUPLICATE finder[sin.name] = DUPLICATE
#backport #backport
#finder[sin.name] = c if sin.name not in finder else DUPLICATE #finder[sin.name] = c if sin.name not in finder else DUPLICATE
inv_finder[c] = input inv_finder[c] = input
...@@ -626,8 +626,8 @@ class Function(object): ...@@ -626,8 +626,8 @@ class Function(object):
dt_call=time.time()-t0 dt_call=time.time()-t0
if hasattr(self.maker.mode,'fct_call_time'): if hasattr(self.maker.mode,'fct_call_time'):
self.maker.mode.fct_call_time[self] += dt_call self.maker.mode.fct_call_time[self] += dt_call
self.maker.mode.fct_call[self] += 1 self.maker.mode.fct_call[self] += 1
self.maker.mode.call_time += dt_call self.maker.mode.call_time += dt_call
self.maker.mode.fn_time += dt_fn self.maker.mode.fn_time += dt_fn
...@@ -732,9 +732,9 @@ class SanityCheckFunction(Function): ...@@ -732,9 +732,9 @@ class SanityCheckFunction(Function):
if not self.check_equal(c1.value, c2.value): if not self.check_equal(c1.value, c2.value):
name = c2.name name = c2.name
if name: if name:
the_name = name the_name = name
else: else:
the_name = "" the_name = ""
raise ValueError("Input #%i%s using %s and %s differs." raise ValueError("Input #%i%s using %s and %s differs."
% (i, % (i,
#backport #backport
...@@ -751,9 +751,9 @@ class SanityCheckFunction(Function): ...@@ -751,9 +751,9 @@ class SanityCheckFunction(Function):
if not self.check_equal(r1, r2): if not self.check_equal(r1, r2):
name = c2.name name = c2.name
if name: if name:
the_name = name the_name = name
else: else:
the_name = "" the_name = ""
raise ValueError("Variable #%i%s using %s and %s differs." raise ValueError("Variable #%i%s using %s and %s differs."
% (i, % (i,
#backport #backport
...@@ -987,12 +987,12 @@ class FunctionMaker(object): ...@@ -987,12 +987,12 @@ class FunctionMaker(object):
def _pickle_FunctionMaker(fm): def _pickle_FunctionMaker(fm):
if fm.return_none: if fm.return_none:
outputs = None outputs = None
else: else:
if fm.unpack_single: if fm.unpack_single:
outputs = fm.outputs[0] outputs = fm.outputs[0]
else: else:
outputs = fm.outputs outputs = fm.outputs
#backport #backport
#outputs = None if fm.return_none else (fm.outputs[0] if fm.unpack_single else fm.outputs) #outputs = None if fm.return_none else (fm.outputs[0] if fm.unpack_single else fm.outputs)
...@@ -1086,10 +1086,10 @@ def orig_function(inputs, outputs, mode=None, accept_inplace = False, name=None) ...@@ -1086,10 +1086,10 @@ def orig_function(inputs, outputs, mode=None, accept_inplace = False, name=None)
# TODO This may need to be changed to use containers as defaults. # TODO This may need to be changed to use containers as defaults.
retval = [] retval = []
for default in defaults: for default in defaults:
if isinstance(default, gof.Container): if isinstance(default, gof.Container):
retval +=[copy.copy(default.value)] retval +=[copy.copy(default.value)]
else: else:
retval +=[copy.copy(default)] retval +=[copy.copy(default)]
return retval return retval
#backport #backport
#return [copy.copy(default.value) if isinstance(default, gof.Container) else #return [copy.copy(default.value) if isinstance(default, gof.Container) else
...@@ -1111,9 +1111,9 @@ def orig_function(inputs, outputs, mode=None, accept_inplace = False, name=None) ...@@ -1111,9 +1111,9 @@ def orig_function(inputs, outputs, mode=None, accept_inplace = False, name=None)
fn.name = name fn.name = name
if hasattr(mode,'fct_call_time'): if hasattr(mode,'fct_call_time'):
mode.fct_call_time.setdefault(fn,0) mode.fct_call_time.setdefault(fn,0)
if hasattr(mode,'fct_call'): if hasattr(mode,'fct_call'):
mode.fct_call.setdefault(fn,0) mode.fct_call.setdefault(fn,0)
return fn return fn
...@@ -1226,4 +1226,3 @@ def get_info_on_inputs(named_inputs, n_unnamed_inputs): ...@@ -1226,4 +1226,3 @@ def get_info_on_inputs(named_inputs, n_unnamed_inputs):
get_plural(n_unnamed_inputs), get_plural(n_unnamed_inputs),
get_plural(n_unnamed_inputs))) get_plural(n_unnamed_inputs)))
return msg return msg
...@@ -26,7 +26,7 @@ def check_equal(x, y): ...@@ -26,7 +26,7 @@ def check_equal(x, y):
#I put the import here to allow using theano without scipy. #I put the import here to allow using theano without scipy.
import scipy.sparse as sp import scipy.sparse as sp
x, y = x[0], y[0] x, y = x[0], y[0]
# TODO: bug in current scipy, two sparse matrices are never equal, remove when moving to 0.7 # TODO: bug in current scipy, two sparse matrices are never equal, remove when moving to 0.7
if sp.issparse(x): if sp.issparse(x):
x = x.todense() x = x.todense()
...@@ -152,7 +152,7 @@ class PrintCurrentEnv(gof.Optimizer): ...@@ -152,7 +152,7 @@ class PrintCurrentEnv(gof.Optimizer):
theano.printing.debugprint(env.outputs) theano.printing.debugprint(env.outputs)
optdb = gof.SequenceDB() optdb = gof.SequenceDB()
optdb.register('merge1', gof.MergeOptimizer(), optdb.register('merge1', gof.MergeOptimizer(),
0, 'fast_run', 'fast_compile') 0, 'fast_run', 'fast_compile')
optdb.register('canonicalize', gof.EquilibriumDB(), # rearranges elemwise expressions optdb.register('canonicalize', gof.EquilibriumDB(), # rearranges elemwise expressions
1, 'fast_run', 'fast_compile') 1, 'fast_run', 'fast_compile')
...@@ -162,7 +162,7 @@ optdb.register('Print1.21', PrintCurrentEnv('Post-canonicalize'), ...@@ -162,7 +162,7 @@ optdb.register('Print1.21', PrintCurrentEnv('Post-canonicalize'),
1.21,)# 'fast_run', 'fast_compile') 1.21,)# 'fast_run', 'fast_compile')
optdb.register('stabilize', gof.EquilibriumDB(), # replace unstable subgraphs optdb.register('stabilize', gof.EquilibriumDB(), # replace unstable subgraphs
1.5, 'fast_run') 1.5, 'fast_run')
optdb.register('Print1.51', PrintCurrentEnv('Post-stabilize'), optdb.register('Print1.51', PrintCurrentEnv('Post-stabilize'),
1.51,) #'fast_run', 'fast_compile') 1.51,) #'fast_run', 'fast_compile')
optdb.register('specialize', gof.EquilibriumDB(), # misc special cases for speed optdb.register('specialize', gof.EquilibriumDB(), # misc special cases for speed
...@@ -175,7 +175,7 @@ optdb.register('specialize_device', gof.EquilibriumDB(), # misc specia ...@@ -175,7 +175,7 @@ optdb.register('specialize_device', gof.EquilibriumDB(), # misc specia
48.6, 'fast_run')#must be after gpu stuff at 48.5 48.6, 'fast_run')#must be after gpu stuff at 48.5
optdb.register('merge2', gof.MergeOptimizer(), # especially constant merge optdb.register('merge2', gof.MergeOptimizer(), # especially constant merge
49, 'fast_run') 49, 'fast_run')
optdb.register('add_destroy_handler', AddDestroyHandler(), optdb.register('add_destroy_handler', AddDestroyHandler(),
49.5, 'fast_run', 'inplace') 49.5, 'fast_run', 'inplace')
optdb.register('merge3', gof.MergeOptimizer(), # final pass just to make sure optdb.register('merge3', gof.MergeOptimizer(), # final pass just to make sure
100, 'fast_run') 100, 'fast_run')
...@@ -196,7 +196,7 @@ class Mode(object): ...@@ -196,7 +196,7 @@ class Mode(object):
See predefined_linkers, predefined_optimizers and also See predefined_linkers, predefined_optimizers and also
predefined_modes. predefined_modes.
""" """
def __init__(self, linker = config.linker, optimizer = config.optimizer): def __init__(self, linker = config.linker, optimizer = config.optimizer):
self.__setstate__((linker, optimizer)) self.__setstate__((linker, optimizer))
#self.provided_optimizer - typically the `optimizer` arg. But if the `optimizer` arg is #self.provided_optimizer - typically the `optimizer` arg. But if the `optimizer` arg is
...@@ -239,8 +239,8 @@ class Mode(object): ...@@ -239,8 +239,8 @@ class Mode(object):
linker = predefined_linkers[linker] linker = predefined_linkers[linker]
if isinstance(optimizer, str) or optimizer is None: if isinstance(optimizer, str) or optimizer is None:
optimizer = predefined_optimizers[optimizer] optimizer = predefined_optimizers[optimizer]
return (linker, optimizer) return (linker, optimizer)
def including(self, *tags): def including(self, *tags):
link, opt = self.get_linker_optimizer(self.provided_linker, self.provided_optimizer) link, opt = self.get_linker_optimizer(self.provided_linker, self.provided_optimizer)
#N.B. opt might be a Query instance, not sure what else it might be... #N.B. opt might be a Query instance, not sure what else it might be...
...@@ -285,7 +285,7 @@ def get_mode(orig_string): ...@@ -285,7 +285,7 @@ def get_mode(orig_string):
#need to import later to break circular dependency. #need to import later to break circular dependency.
from profilemode import ProfileMode,prof_mode_instance_to_print from profilemode import ProfileMode,prof_mode_instance_to_print
from debugmode import DebugMode from debugmode import DebugMode
ret = eval(string+'(linker=config.linker, optimizer=config.optimizer)') ret = eval(string+'(linker=config.linker, optimizer=config.optimizer)')
elif not predefined_modes.has_key(string): elif not predefined_modes.has_key(string):
...@@ -318,4 +318,3 @@ def register_mode(name, mode): ...@@ -318,4 +318,3 @@ def register_mode(name, mode):
if name in predefined_modes: if name in predefined_modes:
raise ValueError('Mode name already taken: %s' % name) raise ValueError('Mode name already taken: %s' % name)
predefined_modes[name] = mode predefined_modes[name] = mode
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论