diff --git a/include/aidge/graph/Node.hpp b/include/aidge/graph/Node.hpp index e014b041fdad94f5f17d636a2da92180de59e152..51cc9c444edf03febf4416149e9160df0bbfca9c 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 c19eab12ae34418386b1481702f64e4a82e9f771..da6d833f3aa933cd5e707814c279142de5bc4a23 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 } ///////////////////////////////////////////////////////