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

Move clone member function, constructors and creation funciton of DetphToSpace to src file

parent 12105cbe
No related branches found
No related tags found
2 merge requests!212Version 0.3.0,!165[Add] DepthToSpace Operator
Pipeline #53443 passed
...@@ -50,11 +50,7 @@ public: ...@@ -50,11 +50,7 @@ public:
DepthToSpace_Op() = delete; DepthToSpace_Op() = delete;
DepthToSpace_Op(const std::uint32_t blockSize, const Mode mode = Mode::CRD) 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))) {}
/** /**
* @brief Copy-constructor. Copy the operator attributes and its output tensor(s), * @brief Copy-constructor. Copy the operator attributes and its output tensor(s),
...@@ -67,19 +63,7 @@ public: ...@@ -67,19 +63,7 @@ public:
* @brief Clone the operator using its copy-constructor. * @brief Clone the operator using its copy-constructor.
* @see Operator::DepthToSpace_Op * @see Operator::DepthToSpace_Op
*/ */
std::shared_ptr<Operator> clone() const override { 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;
// }
bool forwardDims(bool /*allowDataDependency*/ = false) override final; bool forwardDims(bool /*allowDataDependency*/ = false) override final;
...@@ -97,11 +81,9 @@ public: ...@@ -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 DepthToSpace_Op::Mode mode = DepthToSpace_Op::Mode::CRD,
const std::string& name = "") { const std::string& name = "");
return std::make_shared<Node>(std::make_shared<DepthToSpace_Op>(blockSize, mode), name);
}
} // namespace Aidge } // namespace Aidge
......
...@@ -55,9 +55,20 @@ void Aidge::DepthToSpace_OpImpl::forward() { ...@@ -55,9 +55,20 @@ void Aidge::DepthToSpace_OpImpl::forward() {
op.getOutput(0)->resize(final_dims); op.getOutput(0)->resize(final_dims);
} }
//////////////////////////////////////////////////////
const std::string Aidge::DepthToSpace_Op::Type = "DepthToSpace"; 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), : OperatorTensor(op),
mAttributes(op.mAttributes) mAttributes(op.mAttributes)
{ {
...@@ -68,6 +79,9 @@ Aidge::DepthToSpace_Op::DepthToSpace_Op(const DepthToSpace_Op& op) ...@@ -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*/) { bool Aidge::DepthToSpace_Op::forwardDims(bool /*allowDataDependency*/) {
if (inputsAssociated()) { if (inputsAssociated()) {
...@@ -98,3 +112,11 @@ void Aidge::DepthToSpace_Op::setBackend(const std::string& name, Aidge::DeviceId ...@@ -98,3 +112,11 @@ void Aidge::DepthToSpace_Op::setBackend(const std::string& name, Aidge::DeviceId
} }
mOutputs[0]->setBackend(name, device); 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
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