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

[JIT] Make InsertInstruction overflow check a warning instead of fatal #46369

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions torch/csrc/jit/runtime/interpreter.cpp
Expand Up @@ -433,7 +433,9 @@ Ttarget safe_narrow_cast(Tsource v) {
Ttarget res = static_cast<Ttarget>(v);
// Casting it back to check whether it overflew.
if (static_cast<Tsource>(res) != v) {
throw std::runtime_error("safe_narrow_cast<>() failed due to overflow");
TORCH_WARN(
"ATTENTION: your model computation is overflowing, safe_narrow_cast<>() failed");
return v;
}
return res;
}
Expand Down Expand Up @@ -548,7 +550,7 @@ struct CodeImpl {
instructions_.emplace_back(
op,
safe_narrow_cast<int32_t, int64_t>(X),
safe_narrow_cast<int16_t, int64_t>(N));
safe_narrow_cast<uint16_t, uint64_t>(N));
instructions_source_.emplace_back(current_node_);

// check that we didn't accidentally emit nodes out of topological order
Expand Down