diff --git a/paddle/fluid/framework/ir/node.h b/paddle/fluid/framework/ir/node.h index 6f4bb172c6ed530ff09fc8953ef5c57825efbf79..0c521270693e20b9fa8027d0759ab4ef5448a61c 100644 --- a/paddle/fluid/framework/ir/node.h +++ b/paddle/fluid/framework/ir/node.h @@ -14,6 +14,46 @@ limitations under the License. */ #pragma once +#include +#include +#include +#include "paddle/fluid/platform/macros.h" + namespace paddle { -namespace framework {} // namespace framework +namespace framework { + +class Node { + public: + enum class Type { kNone = -1, kOperation, kVariable }; + + Node() {} + virtual ~Node() {} + + template + Subclass &As() { + return *dynamic_cast(this); + } + + int64_t ID() const { return id_; } + + std::string Name() const { return name_; } + + virtual std::string ToString() const { + return Name() + "(" + std::to_string(ID()) + ")"; + } + + Type NodeType() const { return type_; } + + std::vector inputs; + std::vector outputs; + + protected: + int64_t id_ = 0; + std::string name_; + Type type_; + + DISABLE_COPY_AND_ASSIGN(Node); +}; + +} // namespace framework } // namespace paddle