This is an automated email from the ASF dual-hosted git repository.
lunderberg pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 35c614303a [TVMScript] Do not throw error for duplicate definitions
(#16811)
35c614303a is described below
commit 35c614303a5914924b41a0fe26d3b6ce1c19bb79
Author: Eric Lunderberg <[email protected]>
AuthorDate: Wed Apr 3 10:12:43 2024 -0500
[TVMScript] Do not throw error for duplicate definitions (#16811)
TVM's IR dialects require single-site assignment. However, the printer
is different from most utilities, as it may neither assume that its
input is well-formed, nor may it throw an exception if the input is
ill-formed. The printer is often used for debugging, where logging
and printouts of an IRModule are essential. In these cases, throwing
an error would prevent a developer from determining why an IRModule is
ill-formed.
---
src/script/printer/ir_docsifier.cc | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/script/printer/ir_docsifier.cc
b/src/script/printer/ir_docsifier.cc
index 0c624a16b4..20448d2bc4 100644
--- a/src/script/printer/ir_docsifier.cc
+++ b/src/script/printer/ir_docsifier.cc
@@ -30,7 +30,21 @@ namespace script {
namespace printer {
IdDoc IRDocsifierNode::Define(const ObjectRef& obj, const Frame& frame, const
String& name_hint) {
- ICHECK(obj2info.find(obj) == obj2info.end()) << "Duplicated object: " << obj;
+ if (auto it = obj2info.find(obj); it != obj2info.end()) {
+ // TVM's IR dialects do not allow multiple definitions of the same
+ // variable within an IRModule. This branch can only be reached
+ // when printing ill-formed inputs.
+ //
+ // However, the printer is different from most utilities, as it
+ // may neither assume that its input is well-formed, nor may it
+ // throw an exception if the input is ill-formed. The printer is
+ // often used for debugging, where logging and printouts of an
+ // IRModule are essential. In these cases, throwing an error
+ // would prevent a developer from determining why an IRModule is
+ // ill-formed.
+ return IdDoc(it->second.name.value());
+ }
+
String name = name_hint;
if (cfg->show_object_address) {
std::stringstream stream;