From fcda23a3e4a336a4d69376af240f0a6bd3d0d546 Mon Sep 17 00:00:00 2001 From: Xin Pan Date: Tue, 10 Jul 2018 19:45:27 +0800 Subject: [PATCH] simple node --- paddle/fluid/framework/ir/node.h | 42 +++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/framework/ir/node.h b/paddle/fluid/framework/ir/node.h index 6f4bb172c6..0c52127069 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 -- GitLab