From 7781297c701d3c8d72d8d252e079a5f3fe5ecde3 Mon Sep 17 00:00:00 2001 From: Xin Pan Date: Tue, 10 Jul 2018 21:12:10 +0800 Subject: [PATCH] variants --- paddle/fluid/framework/details/var_handle.h | 1 + paddle/fluid/framework/ir/graph.h | 21 ++++++++++++++++++++- paddle/fluid/framework/ir/node.h | 10 +++++----- paddle/fluid/platform/variant.h | 1 + 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/paddle/fluid/framework/details/var_handle.h b/paddle/fluid/framework/details/var_handle.h index cae9af721..c62f9a9d0 100644 --- a/paddle/fluid/framework/details/var_handle.h +++ b/paddle/fluid/framework/details/var_handle.h @@ -18,6 +18,7 @@ #include #include +#include "paddle/fluid/framework/ir/node.h" #include "paddle/fluid/platform/place.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/graph.h b/paddle/fluid/framework/ir/graph.h index 6f4bb172c..d1805d743 100644 --- a/paddle/fluid/framework/ir/graph.h +++ b/paddle/fluid/framework/ir/graph.h @@ -14,6 +14,25 @@ limitations under the License. */ #pragma once +#include +#include +#include +#include + +#include "paddle/fluid/framework/ir/node.h" +#include "paddle/fluid/platform/variant.h" + namespace paddle { -namespace framework {} // namespace framework +namespace framework { + +class Graph { + public: + std::map> attrs; + + std::vector inputs; + std::vector outputs; + std::vector> nodes; +}; + +} // namespace framework } // namespace paddle diff --git a/paddle/fluid/framework/ir/node.h b/paddle/fluid/framework/ir/node.h index 0c5212706..9a280afb3 100644 --- a/paddle/fluid/framework/ir/node.h +++ b/paddle/fluid/framework/ir/node.h @@ -15,9 +15,11 @@ limitations under the License. */ #pragma once #include +#include #include #include #include "paddle/fluid/platform/macros.h" +#include "paddle/fluid/platform/variant.h" namespace paddle { namespace framework { @@ -29,11 +31,6 @@ class Node { Node() {} virtual ~Node() {} - template - Subclass &As() { - return *dynamic_cast(this); - } - int64_t ID() const { return id_; } std::string Name() const { return name_; } @@ -42,12 +39,15 @@ class Node { return Name() + "(" + std::to_string(ID()) + ")"; } + virtual std::string DebugString() const = 0; + Type NodeType() const { return type_; } std::vector inputs; std::vector outputs; protected: + std::map> attrs_; int64_t id_ = 0; std::string name_; Type type_; diff --git a/paddle/fluid/platform/variant.h b/paddle/fluid/platform/variant.h index 45f60fc9d..dc9fad29f 100644 --- a/paddle/fluid/platform/variant.h +++ b/paddle/fluid/platform/variant.h @@ -38,6 +38,7 @@ limitations under the License. */ #endif #endif +#include #include #include #include -- GitLab