提交 4f035b41 authored 作者: Ziye Fan's avatar Ziye Fan

make Validator.validate_(fgraph) print out information itself

上级 d7e46776
......@@ -2,6 +2,7 @@ from __future__ import print_function
from functools import partial
import sys
import time
import inspect
import theano
from theano import config
......@@ -200,7 +201,26 @@ class Validator(Feature):
def validate_(self, fgraph):
t0 = time.time()
ret = fgraph.execute_callbacks('validate')
try:
ret = fgraph.execute_callbacks('validate')
except Exception as e:
cf = inspect.currentframe()
uf = cf.f_back
uf_info = inspect.getframeinfo(uf)
# If the caller is replace_all_validate, just raise the
# exception. replace_all_validate will print out the
# verbose output.
# Or it has to be done here before raise.
if uf_info.function == 'replace_all_validate':
raise
else:
verbose = uf.f_locals['verbose']
r = uf.f_locals['r']
reason = uf_info.function
if verbose:
print("validate failed on node %s.\n Reason: %s, %s" % (r, reason, e))
raise
t1 = time.time()
if fgraph.profile:
fgraph.profile.validate_time += t1 - t0
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论