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

[Add] clone function to Scaling

parent cae06e01
No related branches found
No related tags found
No related merge requests found
...@@ -55,6 +55,27 @@ public: ...@@ -55,6 +55,27 @@ public:
setDatatype(DataType::Float32); setDatatype(DataType::Float32);
} }
/**
* @brief Copy-constructor. Copy the operator parameters and its output tensor(s), but not its input tensors (the new operator has no input associated).
* @param op Operator to copy.
*/
Scaling_Op(const Scaling_Op& op)
: Operator(Type),
Parameterizable_(op),
mOutput(std::make_shared<Tensor>(*op.mOutput))
{
// cpy-ctor
setDatatype(op.mOutput->dataType());
}
/**
* @brief Clone the operator using its copy-constructor.
* @see Operator::Scaling_Op
*/
std::shared_ptr<Operator> clone() const override {
return std::make_shared<Scaling_Op>(*this);
}
void associateInput(const IOIndex_t inputIdx, std::shared_ptr<Data> data) override final { void associateInput(const IOIndex_t inputIdx, std::shared_ptr<Data> data) override final {
assert(inputIdx == 0 && "operator supports only 1 input"); assert(inputIdx == 0 && "operator supports only 1 input");
assert(strcmp(data->type(), Tensor::Type)==0 && "input data must be of Tensor type"); assert(strcmp(data->type(), Tensor::Type)==0 && "input data must be of Tensor type");
...@@ -84,7 +105,7 @@ public: ...@@ -84,7 +105,7 @@ public:
} }
inline std::shared_ptr<Tensor> getInput(const IOIndex_t inputIdx) const override final { inline std::shared_ptr<Tensor> getInput(const IOIndex_t inputIdx) const override final {
assert((inputIdx == 0) && "Scaling Operator has only 1 input"); assert((inputIdx == 0) && "Scaling Operator has only 1 input");
(void) inputIdx; // avoid unused warning (void) inputIdx; // avoid unused warning
return mInput; return mInput;
......
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