提交 1c9430e2 编写于 作者: M Megvii Engine Team

fix(mge/imperative): clear log message

GitOrigin-RevId: 051264cac3eabfdb3d6ccc0a46586b9a4f258bb5
上级 a226f02e
...@@ -52,6 +52,7 @@ class Context: ...@@ -52,6 +52,7 @@ class Context:
self.indent = 0 self.indent = 0
self.generated = [] self.generated = []
self.skipped = [] self.skipped = []
self.generated_signature = set()
def write(self, text, *fmt, indent=0): def write(self, text, *fmt, indent=0):
text = textwrap.dedent(text) text = textwrap.dedent(text)
...@@ -184,6 +185,13 @@ class Context: ...@@ -184,6 +185,13 @@ class Context:
self.skipped.append(name) self.skipped.append(name)
return return
signature = (name, params if isinstance(params, str) else frozenset(params), has_out_dtype, version)
if signature in self.generated_signature:
self.skipped.append(name)
return
else:
self.generated_signature.add(signature)
body = body or [] body = body or []
if isinstance(params, str): if isinstance(params, str):
params = [('param', params)] params = [('param', params)]
......
...@@ -87,12 +87,14 @@ OpTraitRegistry& OpTraitRegistry::finalize() { ...@@ -87,12 +87,14 @@ OpTraitRegistry& OpTraitRegistry::finalize() {
CHECK(infer_output_attrs); CHECK(infer_output_attrs);
CHECK(make_backward_graph); CHECK(make_backward_graph);
#undef CHECK #undef CHECK
#ifdef DEBUG
if (msg.tellp() > 0) { if (msg.tellp() > 0) {
mgb_log_warn( mgb_log_warn(
"%s op trait missing: %s", "%s op trait missing: %s",
trait->name ? trait->name : "(anonymous)", trait->name ? trait->name : "(anonymous)",
msg.str().c_str() + 2 /* skip first ", " */); msg.str().c_str() + 2 /* skip first ", " */);
} }
#endif
return *this; return *this;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册