(2/2) Make TorchScript Preserve Fully Qualified Class Name for Python Exceptions: frontend change (#70471)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/70471

Reland D33282878 (911d527b87). This is the frontend change.
ghstack-source-id: 149114933

Test Plan: Refer to D33282878 (911d527b87). Also check CI

Reviewed By: gmagogsfm

Differential Revision: D33342569

fbshipit-source-id: 57984ac67ae2c56c38f72d3b1fb69105901fb472
(cherry picked from commit b47cc935ee1fd7aa63aa453a323a637bc2c22f3c)
This commit is contained in:
Shunting Zhang
2022-02-14 23:16:14 -08:00
committed by PyTorch MergeBot
parent 511ec7f366
commit 856157fcee
9 changed files with 385 additions and 159 deletions

View File

@ -914,8 +914,11 @@ std::shared_ptr<SugaredValue> PythonExceptionValue::call(
->insertNode(caller.graph()->createTuple(message_values))
->output();
}
Value* qualified_class_name =
insertConstant(*caller.graph(), exception_class_qualified_name_, loc);
return std::make_shared<ExceptionMessageValue>(error_message);
return std::make_shared<ExceptionMessageValue>(
error_message, qualified_class_name);
}
bool isNamedTupleClass(const py::object& obj) {