diff --git a/paddle/fluid/framework/ir/node.h b/paddle/fluid/framework/ir/node.h index 1b7364858dcbbbcfbfcb906723c0045aa0af6ab8..b8764e256c15d54ada4d1c8c33b485f7b3279087 100644 --- a/paddle/fluid/framework/ir/node.h +++ b/paddle/fluid/framework/ir/node.h @@ -15,7 +15,10 @@ limitations under the License. */ #pragma once #include +#include +#include #include + #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/framework/var_desc.h" #include "paddle/fluid/platform/macros.h" @@ -57,6 +60,7 @@ class Node { } wrapper_ = wrapper; wrapper_deleter_ = [wrapper]() { delete wrapper; }; + wrapper_type_ = std::type_index(typeid(T)); } template @@ -64,6 +68,11 @@ class Node { return *boost::any_cast(wrapper_); } + template + bool IsWrappedBy() { + return std::type_index(typeid(T)) == wrapper_type_; + } + // Please don't use this API! int id() const { return id_; } @@ -118,6 +127,7 @@ class Node { boost::any wrapper_; std::function wrapper_deleter_; + std::type_index wrapper_type_ = std::type_index(typeid(void)); DISABLE_COPY_AND_ASSIGN(Node); };