Skip to content

Commit

Permalink
Lazy warnings about unsupported handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaOvodov committed Sep 24, 2020
1 parent 6b9e76d commit 1b79413
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions onnx_tf/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ def _onnx_node_to_tensorflow_op(cls,
if handlers:
handler = handlers[node.domain].get(node.op_type, None) if node.domain in handlers else None
if handler:
if hasattr(handler, "WARNINGS"):
common.logger.warning(handler.WARNINGS)
return handler.handle(node, tensor_dict=tensor_dict, strict=strict)

raise BackendIsNotSupposedToImplementIt("{} is not implemented.".format(node.op_type))
Expand Down
6 changes: 4 additions & 2 deletions onnx_tf/common/handler_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ def get_all_backend_handlers(opset_dict):
domain=handler.DOMAIN,
max_inclusive_version=version).since_version
except RuntimeError:
common.logger.debug("Fail to get since_version of {} in domain `{}` "
handler.WARNINGS = (((handler.WARNINGS + "\n") if hasattr(handler, "WARNINGS") else "") +
"Fail to get since_version of {} in domain `{}` "
"with max_inclusive_version={}. Set to 1.".format(
handler.ONNX_OP, handler.DOMAIN, version))
else:
common.logger.debug("Unknown op {} in domain `{}`.".format(
handler.WARNINGS = (((handler.WARNINGS + "\n") if hasattr(handler, "WARNINGS") else "") +
"Unknown op {} in domain `{}`.".format(
handler.ONNX_OP, handler.DOMAIN or "ai.onnx"))
handler.SINCE_VERSION = since_version
handlers.setdefault(domain, {})[handler.ONNX_OP] = handler
Expand Down

0 comments on commit 1b79413

Please sign in to comment.