Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better errmsg upon getScalarTypeForType failure #3734

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion lib/Dialect/Torch/Utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,28 @@ torch_upstream::ScalarType Torch::getScalarTypeForType(Type type) {
return torch_upstream::ScalarType::Float8_e5m2fnuz;
if (isa<Float8E4M3FNUZType>(type))
return torch_upstream::ScalarType::Float8_e4m3fnuz;
llvm::report_fatal_error("unhandled type for getScalarTypeForType");
std::string errorMsg = "Unhandled type in getScalarTypeForType: ";
llvm::raw_string_ostream os(errorMsg);
type.print(os);
// os << "\nType ID: " << type.getTypeID();
os << "\nType properties:";
os << "\n Is integer: " << (type.isInteger() ? "yes" : "no");
os << "\n Is float: "
<< (type.isIntOrFloat() && !type.isInteger() ? "yes" : "no");
os << "\n Is index: " << (type.isIndex() ? "yes" : "no");
os << "\n Bit width: "
<< (type.isIntOrFloat() ? std::to_string(type.getIntOrFloatBitWidth())
: "N/A");
os << "\n Is signless: " << (type.isSignlessInteger() ? "yes" : "no");
os << "\n Is signed: " << (type.isSignedInteger() ? "yes" : "no");
// special error message for unsigned integer
if (type.isUnsignedInteger()) {
os << "\n Is unsigned: yes";
os << "\nUnsigned integer support is currently spotty. Please seeheck "
"https://github.com/llvm/torch-mlir/issues/3720 "
"for more details.";
}
llvm::report_fatal_error(llvm::StringRef(errorMsg));
}
Type Torch::getTypeForTorchType(
MLIRContext *context, Type type,
Expand Down
Loading