MCPcopy Create free account
hub / github.com/pytorch/pytorch / GetGraphPngSafe

Function GetGraphPngSafe

caffe2/python/net_drawer.py:330–342  ·  view source on GitHub ↗

Invokes `func` (e.g. GetPydotGraph) with args. If anything fails - returns and empty image instead of throwing Exception

(func, *args, **kwargs)

Source from the content-addressed store, hash-verified

328
329
330def GetGraphPngSafe(func, *args, **kwargs):
331 """
332 Invokes `func` (e.g. GetPydotGraph) with args. If anything fails - returns
333 and empty image instead of throwing Exception
334 """
335 try:
336 graph = func(*args, **kwargs)
337 if not isinstance(graph, pydot.Dot):
338 raise ValueError("func is expected to return pydot.Dot")
339 return graph.create_png()
340 except Exception as e:
341 logger.error("Failed to draw graph: {}".format(e))
342 return _DummyPngImage
343
344
345def main():

Callers

nothing calls this directly

Calls 4

isinstanceFunction · 0.85
funcFunction · 0.70
errorMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…