提交 74ee0d01 authored 作者: Mohammad Pezeshki's avatar Mohammad Pezeshki

profile_list is now a list of profiles

上级 1bc83396
...@@ -8,7 +8,7 @@ W = T.matrix('W') ...@@ -8,7 +8,7 @@ W = T.matrix('W')
Y = T.dot(X, W) Y = T.dot(X, W)
Z = X - W Z = X - W
f = theano.function(inputs=[X, W], outputs=[Y, Z], profile=False) f = theano.function(inputs=[X, W], outputs=[Y, Z], profile=True)
for i in xrange(10): for i in xrange(10):
f(numpy.random.uniform(size=(2, 2)), f(numpy.random.uniform(size=(2, 2)),
numpy.random.uniform(size=(2, 2))) numpy.random.uniform(size=(2, 2)))
......
...@@ -81,6 +81,7 @@ def debugprint(obj, depth=-1, print_type=False, ...@@ -81,6 +81,7 @@ def debugprint(obj, depth=-1, print_type=False,
_file = file _file = file
done = dict() done = dict()
results_to_print = [] results_to_print = []
profile_list = []
order = [] order = []
if isinstance(obj, (list, tuple)): if isinstance(obj, (list, tuple)):
lobj = obj lobj = obj
...@@ -89,18 +90,26 @@ def debugprint(obj, depth=-1, print_type=False, ...@@ -89,18 +90,26 @@ def debugprint(obj, depth=-1, print_type=False,
for obj in lobj: for obj in lobj:
if isinstance(obj, gof.Variable): if isinstance(obj, gof.Variable):
results_to_print.append(obj) results_to_print.append(obj)
profile_list.append(None)
elif isinstance(obj, gof.Apply): elif isinstance(obj, gof.Apply):
results_to_print.extend(obj.outputs) results_to_print.extend(obj.outputs)
for item in obj.outputs:
profile_list.append(obj.profile)
elif isinstance(obj, Function): elif isinstance(obj, Function):
results_to_print.extend(obj.maker.fgraph.outputs) results_to_print.extend(obj.maker.fgraph.outputs)
for item in obj.maker.fgraph.outputs:
profile_list.append(obj.profile)
order = obj.maker.fgraph.toposort() order = obj.maker.fgraph.toposort()
elif isinstance(obj, gof.FunctionGraph): elif isinstance(obj, gof.FunctionGraph):
results_to_print.extend(obj.outputs) results_to_print.extend(obj.outputs)
for item in obj.outputs:
profile_list.append(obj.profile)
order = obj.toposort() order = obj.toposort()
elif isinstance(obj, (int, long, float, numpy.ndarray)): elif isinstance(obj, (int, long, float, numpy.ndarray)):
print obj print obj
elif isinstance(obj, (theano.In, theano.Out)): elif isinstance(obj, (theano.In, theano.Out)):
results_to_print.append(obj.variable) results_to_print.append(obj.variable)
profile_list.append(None)
else: else:
raise TypeError("debugprint cannot print an object of this type", raise TypeError("debugprint cannot print an object of this type",
obj) obj)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论