From 97e696f8b498508b58fe6ee3af3c5fd71188e0ca Mon Sep 17 00:00:00 2001 From: NAUD Maxence <maxence.naud@cea.fr> Date: Sat, 19 Oct 2024 22:41:59 +0000 Subject: [PATCH] remove constructor from reference of DynamicAttr --- include/aidge/graph/Node.hpp | 8 ++++++-- src/graph/Node.cpp | 20 ++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/aidge/graph/Node.hpp b/include/aidge/graph/Node.hpp index e014b041f..51cc9c444 100644 --- a/include/aidge/graph/Node.hpp +++ b/include/aidge/graph/Node.hpp @@ -76,7 +76,7 @@ public: * @param attrs Attributes for the Node. */ Node(std::shared_ptr<Operator> op, std::shared_ptr<DynamicAttributes> attrs); - Node(std::shared_ptr<Operator> op, const DynamicAttributes& attrs); +// Node(std::shared_ptr<Operator> op, const DynamicAttributes& attrs); /** * @brief Construct a new Node object associated with the input Operator. @@ -124,11 +124,14 @@ public: // INNER /////////////////////////////////////////////////////// + inline std::shared_ptr<DynamicAttributes> attributes() const { + return mAttrs; + } /** * @brief Name of the Node. * @return std::string */ - inline std::string name() const noexcept { return (mAttrs->hasAttr("name")) ? mAttrs->getAttr<std::string>("name") : ""; } + inline std::string name() const noexcept { return mAttrs->getAttr<std::string>("name"); } /** * @brief Set the Node name. @@ -173,6 +176,7 @@ public: * @return std::shared_ptr<Operator> */ inline std::shared_ptr<Operator> getOperator() const { return (*mOperator)(mAttrs); } +// inline std::shared_ptr<Operator> getOperator() const { return mOperator; } /////////////////////////////////////////////////////// // TENSOR MANAGEMENT diff --git a/src/graph/Node.cpp b/src/graph/Node.cpp index c19eab12a..da6d833f3 100644 --- a/src/graph/Node.cpp +++ b/src/graph/Node.cpp @@ -18,6 +18,7 @@ #include "aidge/operator/OperatorTensor.hpp" #include "aidge/operator/Producer.hpp" #include "aidge/utils/Types.h" +#include "aidge/utils/future_std/any.hpp" Aidge::Node::Node(std::shared_ptr<Operator> op, std::shared_ptr<DynamicAttributes> attrs) : mAttrs(attrs), @@ -31,23 +32,18 @@ Aidge::Node::Node(std::shared_ptr<Operator> op, std::shared_ptr<DynamicAttribute mIdOutParents( std::vector<IOIndex_t>(static_cast<std::size_t>(op->nbInputs()), gk_IODefaultIndex)) { - // ctor - if (op) { - mForward.push_back([this](){ this->mOperator->forward(); return true; }); - mBackward.push_back([this](){ this->mOperator->backward(); return true; }); - } + mForward.push_back([this](){ this->mOperator->forward(); return true; }); + // mForward.push_back(std::bind(&Operator::forward, mOperator.get())); + mBackward.push_back([this](){ this->mOperator->backward(); return true; }); } -Aidge::Node::Node(std::shared_ptr<Operator> op, const DynamicAttributes& attrs) - : Node(op, std::make_shared<DynamicAttributes>(attrs)) {} +// Aidge::Node::Node(std::shared_ptr<Operator> op, const DynamicAttributes& attrs) +// : Node(op, std::make_shared<DynamicAttributes>(attrs)) {} Aidge::Node::Node(std::shared_ptr<Operator> op, const std::string& name) - : Node(op, DynamicAttributes()) + : Node(op, std::make_shared<DynamicAttributes>(std::map<std::string, future_std::any>({std::make_pair("name", future_std::any(name))}))) { - // ctor - if (!name.empty()) { - mAttrs->setAttr<std::string>("name", name); - } + //ctor } /////////////////////////////////////////////////////// -- GitLab