diff --git a/include/aidge/operator/DepthToSpace.hpp b/include/aidge/operator/DepthToSpace.hpp index bca88db7e188e0aef93b3650a71ccd28f8803bb6..72ff83834962c1860b135a4187e72199b04361db 100644 --- a/include/aidge/operator/DepthToSpace.hpp +++ b/include/aidge/operator/DepthToSpace.hpp @@ -50,11 +50,7 @@ public: DepthToSpace_Op() = delete; - DepthToSpace_Op(const std::uint32_t blockSize, const Mode mode = Mode::CRD) - : OperatorTensor(Type, {InputCategory::Data}, 1), - mAttributes(std::make_shared<Attributes_>( - attr<DepthToSpaceAttr::BlockSize>(blockSize), - attr<DepthToSpaceAttr::Mode>(mode))) {} + DepthToSpace_Op(const std::uint32_t blockSize, const Mode mode = Mode::CRD); /** * @brief Copy-constructor. Copy the operator attributes and its output tensor(s), @@ -67,19 +63,7 @@ public: * @brief Clone the operator using its copy-constructor. * @see Operator::DepthToSpace_Op */ - std::shared_ptr<Operator> clone() const override { - return std::make_shared<DepthToSpace_Op>(*this); - } - - // Data operator[](const char* inputName) override final { - // std::shared_ptr<Tensor> in = (strcmp(inputName, "data")) ? mInputs[0] : - // (strcmp(inputName, "weight") ? mInputs[1] : - // (strcmp(inputName, "bias") ? mInputs[2] : - // nullptr)); - // assert((in!=nullptr) && "No such parameter"); - // return *in; - // } - + std::shared_ptr<Operator> clone() const override; bool forwardDims(bool /*allowDataDependency*/ = false) override final; @@ -97,11 +81,9 @@ public: } }; -inline std::shared_ptr<Node> DepthToSpace(const std::uint32_t blockSize, +std::shared_ptr<Node> DepthToSpace(const std::uint32_t blockSize, const DepthToSpace_Op::Mode mode = DepthToSpace_Op::Mode::CRD, - const std::string& name = "") { - return std::make_shared<Node>(std::make_shared<DepthToSpace_Op>(blockSize, mode), name); -} + const std::string& name = ""); } // namespace Aidge diff --git a/src/operator/DepthToSpace.cpp b/src/operator/DepthToSpace.cpp index fa3d53fd3d2c09094bfec859e51e145cda468f3f..0c858548ec484c34a651efa4adec1cde7ccb9e54 100644 --- a/src/operator/DepthToSpace.cpp +++ b/src/operator/DepthToSpace.cpp @@ -55,9 +55,20 @@ void Aidge::DepthToSpace_OpImpl::forward() { op.getOutput(0)->resize(final_dims); } +////////////////////////////////////////////////////// + const std::string Aidge::DepthToSpace_Op::Type = "DepthToSpace"; -Aidge::DepthToSpace_Op::DepthToSpace_Op(const DepthToSpace_Op& op) +Aidge::DepthToSpace_Op::DepthToSpace_Op(const std::uint32_t blockSize, const Aidge::DepthToSpace_Op::Mode mode) + : OperatorTensor(Type, {InputCategory::Data}, 1), + mAttributes(std::make_shared<Attributes_>( + attr<DepthToSpaceAttr::BlockSize>(blockSize), + attr<DepthToSpaceAttr::Mode>(mode))) +{ + // ctor +} + +Aidge::DepthToSpace_Op::DepthToSpace_Op(const Aidge::DepthToSpace_Op& op) : OperatorTensor(op), mAttributes(op.mAttributes) { @@ -68,6 +79,9 @@ Aidge::DepthToSpace_Op::DepthToSpace_Op(const DepthToSpace_Op& op) } } +std::shared_ptr<Aidge::Operator> Aidge::DepthToSpace_Op::clone() const { + return std::make_shared<DepthToSpace_Op>(*this); +} bool Aidge::DepthToSpace_Op::forwardDims(bool /*allowDataDependency*/) { if (inputsAssociated()) { @@ -98,3 +112,11 @@ void Aidge::DepthToSpace_Op::setBackend(const std::string& name, Aidge::DeviceId } mOutputs[0]->setBackend(name, device); } + +////////////////////////////////////////////////////////// + +std::shared_ptr<Aidge::Node> Aidge::DepthToSpace(const std::uint32_t blockSize, + const Aidge::DepthToSpace_Op::Mode mode, + const std::string& name) { + return std::make_shared<Node>(std::make_shared<DepthToSpace_Op>(blockSize, mode), name); +} \ No newline at end of file