Skip to content
Snippets Groups Projects
Commit 97e696f8 authored by Maxence Naud's avatar Maxence Naud
Browse files

remove constructor from reference of DynamicAttr

parent b1e208ff
No related branches found
No related tags found
3 merge requests!279v0.4.0,!253v0.4.0,!163Export refactor
Pipeline #57396 failed
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
* @param attrs Attributes for the Node. * @param attrs Attributes for the Node.
*/ */
Node(std::shared_ptr<Operator> op, std::shared_ptr<DynamicAttributes> attrs); 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. * @brief Construct a new Node object associated with the input Operator.
...@@ -124,11 +124,14 @@ public: ...@@ -124,11 +124,14 @@ public:
// INNER // INNER
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
inline std::shared_ptr<DynamicAttributes> attributes() const {
return mAttrs;
}
/** /**
* @brief Name of the Node. * @brief Name of the Node.
* @return std::string * @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. * @brief Set the Node name.
...@@ -173,6 +176,7 @@ public: ...@@ -173,6 +176,7 @@ public:
* @return std::shared_ptr<Operator> * @return std::shared_ptr<Operator>
*/ */
inline std::shared_ptr<Operator> getOperator() const { return (*mOperator)(mAttrs); } inline std::shared_ptr<Operator> getOperator() const { return (*mOperator)(mAttrs); }
// inline std::shared_ptr<Operator> getOperator() const { return mOperator; }
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
// TENSOR MANAGEMENT // TENSOR MANAGEMENT
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "aidge/operator/OperatorTensor.hpp" #include "aidge/operator/OperatorTensor.hpp"
#include "aidge/operator/Producer.hpp" #include "aidge/operator/Producer.hpp"
#include "aidge/utils/Types.h" #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) Aidge::Node::Node(std::shared_ptr<Operator> op, std::shared_ptr<DynamicAttributes> attrs)
: mAttrs(attrs), : mAttrs(attrs),
...@@ -31,23 +32,18 @@ Aidge::Node::Node(std::shared_ptr<Operator> op, std::shared_ptr<DynamicAttribute ...@@ -31,23 +32,18 @@ Aidge::Node::Node(std::shared_ptr<Operator> op, std::shared_ptr<DynamicAttribute
mIdOutParents( mIdOutParents(
std::vector<IOIndex_t>(static_cast<std::size_t>(op->nbInputs()), gk_IODefaultIndex)) std::vector<IOIndex_t>(static_cast<std::size_t>(op->nbInputs()), gk_IODefaultIndex))
{ {
// ctor mForward.push_back([this](){ this->mOperator->forward(); return true; });
if (op) { // mForward.push_back(std::bind(&Operator::forward, mOperator.get()));
mForward.push_back([this](){ this->mOperator->forward(); return true; }); mBackward.push_back([this](){ this->mOperator->backward(); return true; });
mBackward.push_back([this](){ this->mOperator->backward(); return true; });
}
} }
Aidge::Node::Node(std::shared_ptr<Operator> op, const DynamicAttributes& attrs) // Aidge::Node::Node(std::shared_ptr<Operator> op, const DynamicAttributes& attrs)
: Node(op, std::make_shared<DynamicAttributes>(attrs)) {} // : Node(op, std::make_shared<DynamicAttributes>(attrs)) {}
Aidge::Node::Node(std::shared_ptr<Operator> op, const std::string& name) 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 //ctor
if (!name.empty()) {
mAttrs->setAttr<std::string>("name", name);
}
} }
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment