From 6868742099c64d4a79dfe6d48054720ccd398bea Mon Sep 17 00:00:00 2001 From: SigureMo Date: Sun, 14 Apr 2024 01:48:46 +0800 Subject: [PATCH] [PIR] Allow get callstack from python without `op_callstack` attr --- paddle/fluid/pybind/pir.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/paddle/fluid/pybind/pir.cc b/paddle/fluid/pybind/pir.cc index 93dd4ba992068..909374d5d2ace 100644 --- a/paddle/fluid/pybind/pir.cc +++ b/paddle/fluid/pybind/pir.cc @@ -646,6 +646,10 @@ void BindOperation(py::module *m) { "callstack", [](Operation &self) -> py::list { py::list callstack_list; + if (!self.HasAttribute(paddle::framework::OpProtoAndCheckerMaker:: + OpCreationCallstackAttrName())) { + return callstack_list; + } pir::Attribute op_callstack = self.attribute( paddle::framework::OpProtoAndCheckerMaker:: OpCreationCallstackAttrName());