Skip to content

Commit 6835315

Browse files
committed
Lazy warnings about unsupported handlers
Signed-off-by: IlyaOvodov <[email protected]>
1 parent 6b9e76d commit 6835315

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

onnx_tf/backend.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ def _onnx_node_to_tensorflow_op(cls,
250250
if handlers:
251251
handler = handlers[node.domain].get(node.op_type, None) if node.domain in handlers else None
252252
if handler:
253+
if hasattr(handler, "WARNINGS"):
254+
common.logger.warning(handler.WARNINGS)
253255
return handler.handle(node, tensor_dict=tensor_dict, strict=strict)
254256

255257
raise BackendIsNotSupposedToImplementIt("{} is not implemented.".format(node.op_type))

onnx_tf/common/handler_helper.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ def get_all_backend_handlers(opset_dict):
2929
domain=handler.DOMAIN,
3030
max_inclusive_version=version).since_version
3131
except RuntimeError:
32-
common.logger.debug("Fail to get since_version of {} in domain `{}` "
32+
handler.WARNINGS = (((handler.WARNINGS + "\n") if hasattr(handler, "WARNINGS") else "") +
33+
"Fail to get since_version of {} in domain `{}` "
3334
"with max_inclusive_version={}. Set to 1.".format(
3435
handler.ONNX_OP, handler.DOMAIN, version))
3536
else:
36-
common.logger.debug("Unknown op {} in domain `{}`.".format(
37+
handler.WARNINGS = (((handler.WARNINGS + "\n") if hasattr(handler, "WARNINGS") else "") +
38+
"Unknown op {} in domain `{}`.".format(
3739
handler.ONNX_OP, handler.DOMAIN or "ai.onnx"))
3840
handler.SINCE_VERSION = since_version
3941
handlers.setdefault(domain, {})[handler.ONNX_OP] = handler

0 commit comments

Comments
 (0)