提交 cae5457f authored 作者: affanv14's avatar affanv14

change metaopt.verbose to int

上级 9e7fb3b1
...@@ -1450,8 +1450,9 @@ AddConfigVar('blas.ldflags', ...@@ -1450,8 +1450,9 @@ AddConfigVar('blas.ldflags',
AddConfigVar( AddConfigVar(
'metaopt.verbose', 'metaopt.verbose',
"Enable verbose output for meta optimizers", "0 for silent, 1 for only warnings, 2 for full output with"
theano.configparser.BoolParam(False), "timings and selected implementation",
theano.configparser.IntParam(0),
in_c_key=False) in_c_key=False)
AddConfigVar('profile', AddConfigVar('profile',
......
...@@ -1134,7 +1134,7 @@ class LocalMetaOptimizer(LocalOptimizer): ...@@ -1134,7 +1134,7 @@ class LocalMetaOptimizer(LocalOptimizer):
def __init__(self, optimizers=()): def __init__(self, optimizers=()):
self._tracks = [x for o in optimizers for x in o.tracks()] self._tracks = [x for o in optimizers for x in o.tracks()]
self.optimizers = list(optimizers) self.optimizers = list(optimizers)
self.verbose = True self.verbose = config.metaopt.verbose
self.track_dict = defaultdict(lambda: []) self.track_dict = defaultdict(lambda: [])
for o in optimizers: for o in optimizers:
...@@ -1176,14 +1176,14 @@ class LocalMetaOptimizer(LocalOptimizer): ...@@ -1176,14 +1176,14 @@ class LocalMetaOptimizer(LocalOptimizer):
missing.difference_update(givens.keys()) missing.difference_update(givens.keys())
# ensure we have data for all input variables that need it # ensure we have data for all input variables that need it
if missing: if missing:
if self.verbose: if self.verbose > 0:
print(("%s cannot meta-optimize %s, " print(("%s cannot meta-optimize %s, "
"%d of %d input shapes unknown" % "%d of %d input shapes unknown" %
(self.__class__.__name__, node, len(missing), node.nin))) (self.__class__.__name__, node, len(missing), node.nin)))
return return
# now we can apply the different optimizations in turn, # now we can apply the different optimizations in turn,
# compile the resulting subgraphs and time their execution # compile the resulting subgraphs and time their execution
if self.verbose: if self.verbose > 1:
print(("%s meta-optimizing %s (%d choices):" % print(("%s meta-optimizing %s (%d choices):" %
(self.__class__.__name__, node, len(self.optimizers)))) (self.__class__.__name__, node, len(self.optimizers))))
timings = [] timings = []
...@@ -1195,20 +1195,20 @@ class LocalMetaOptimizer(LocalOptimizer): ...@@ -1195,20 +1195,20 @@ class LocalMetaOptimizer(LocalOptimizer):
on_unused_input='ignore') on_unused_input='ignore')
timing = min(self.time_call(fn) for _ in range(3)) timing = min(self.time_call(fn) for _ in range(3))
except Exception as e: except Exception as e:
if self.verbose: if self.verbose > 0:
print("* %s: exception" % opt, e) print("* %s: exception" % opt, e)
continue continue
else: else:
if self.verbose: if self.verbose > 1:
print("* %s: %.5g sec" % (opt, timing)) print("* %s: %.5g sec" % (opt, timing))
timings.append((timing, outputs, opt)) timings.append((timing, outputs, opt))
else: else:
if self.verbose: if self.verbose > 0:
print("* %s: not applicable" % opt) print("* %s: not applicable" % opt)
# finally, we choose the fastest one # finally, we choose the fastest one
if timings: if timings:
timings.sort() timings.sort()
if self.verbose: if self.verbose > 1:
print("= %s" % timings[0][2]) print("= %s" % timings[0][2])
return timings[0][1] return timings[0][1]
return return
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论