Skip to content

Commit 1435845

Browse files
committed
fix: Renable backtrace and make it less repetitive
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
1 parent 3967fb0 commit 1435845

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

core/conversion/conversion.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,24 +526,37 @@ bool VerifyConverterSupportForBlock(const torch::jit::Block* b, bool suppress_er
526526
unsupported_msg << "https://www.github.com/nvidia/Torch-TensorRT/issues" << std::endl;
527527
unsupported_msg << std::endl << "In Module:" << std::endl;
528528

529-
if (suppress_errors) {
529+
if (!suppress_errors) {
530530
LOG_ERROR(unsupported_msg.str());
531531
}
532532

533+
std::unordered_map<std::string, std::unordered_set<std::string>> unsupported_node_locations;
533534
for (const auto n : b->nodes()) {
534535
auto schema = n->maybeSchema();
535536
if (schema) {
536537
for (const auto& x : unsupported_ops) {
537538
if (x.first == schema->operator_name()) {
538-
if (suppress_errors) {
539-
LOG_ERROR(
540-
"Unsupported operator: " << *schema << std::endl
541-
<< torch_tensorrt::core::util::GetPyTorchSourceCode(n) << std::endl);
539+
auto loc = unsupported_node_locations.find(x.second);
540+
if (loc == unsupported_node_locations.end()) {
541+
unsupported_node_locations.insert({x.second, {torch_tensorrt::core::util::GetPyTorchSourceCode(n)}});
542+
} else {
543+
loc->second.insert(torch_tensorrt::core::util::GetPyTorchSourceCode(n));
542544
}
543545
}
544546
}
545547
}
546548
}
549+
550+
for (const auto& type : unsupported_node_locations) {
551+
std::stringstream traceback;
552+
traceback << "Unsupported operator: " << type.first << std::endl;
553+
for (const auto& str : type.second) {
554+
traceback << str;
555+
}
556+
auto tb_str = traceback.str();
557+
LOG_ERROR(tb_str);
558+
}
559+
547560
return false;
548561
}
549562

@@ -555,7 +568,7 @@ bool VerifyConverterSupportForBlock(const torch::jit::Block* b, bool suppress_er
555568
unsupported_msg
556569
<< "This may be because there are no operators that can be added to the TensorRT graph or all operators have a resolved compile time value."
557570
<< std::endl;
558-
if (suppress_errors) {
571+
if (!suppress_errors) {
559572
LOG_ERROR(unsupported_msg.str());
560573
}
561574
return false;

0 commit comments

Comments
 (0)