Improve error message of loading saved TS module out of support window (#74228)

Summary:
Explicitly state that users should upgrade PyTorch to mitigate issues of loading TS module that's outside of support window

Pull Request resolved: https://github.com/pytorch/pytorch/pull/74228

Reviewed By: tugsbayasgalan

Differential Revision: D34887538

Pulled By: gmagogsfm

fbshipit-source-id: 7ebeb5ee5f5b2f388f8f8bb72b8eb12eadd7a613
(cherry picked from commit c584df2fc80e70b28e9d6008c84295305e4e19b6)
This commit is contained in:
gmagogsfm
2022-03-15 23:50:52 -07:00
committed by PyTorch MergeBot
parent a2f701d4ee
commit d5744f4760

View File

@ -129,22 +129,27 @@ void PyTorchStreamReader::init() {
}
std::string version(static_cast<const char*>(version_ptr.get()), version_size);
version_ = caffe2::stoull(version);
AT_ASSERTM(
// NOLINTNEXTLINE(clang-diagnostic-sign-compare)
version_ >= kMinSupportedFileFormatVersion,
if (version_ < kMinSupportedFileFormatVersion) {
CAFFE_THROW(
"Attempted to read a PyTorch file with version ",
c10::to_string(version_),
", but the minimum supported version for reading is ",
c10::to_string(kMinSupportedFileFormatVersion),
". Your PyTorch script module file is too old. Please re-export it again.");
AT_ASSERTM(
". Your PyTorch script module file is too old. Please regenerate it",
" with latest version of PyTorch to mitigate this issue.");
}
// NOLINTNEXTLINE(clang-diagnostic-sign-compare)
version_ <= kMaxSupportedFileFormatVersion,
if (version_ > kMaxSupportedFileFormatVersion) {
CAFFE_THROW(
"Attempted to read a PyTorch file with version ",
version_,
", but the maximum supported version for reading is ",
kMaxSupportedFileFormatVersion,
". Your PyTorch installation may be too old.");
". The version of your PyTorch installation may be too old, ",
"please upgrade PyTorch to latest version to mitigate this issue.");
}
}
void PyTorchStreamReader::valid(const char* what, const char* info) {