From 355863bb41139418ff6f9f6f5038b1040ac1427f Mon Sep 17 00:00:00 2001 From: Olivier BICHLER <olivier.bichler@cea.fr> Date: Sun, 16 Mar 2025 16:00:22 +0100 Subject: [PATCH] Specify in-place operators --- include/aidge/operator/Flatten.hpp | 4 ++++ include/aidge/operator/Identity.hpp | 5 +++++ include/aidge/operator/Reshape.hpp | 4 ++++ include/aidge/operator/Squeeze.hpp | 5 +++++ include/aidge/operator/Unsqueeze.hpp | 5 +++++ 5 files changed, 23 insertions(+) diff --git a/include/aidge/operator/Flatten.hpp b/include/aidge/operator/Flatten.hpp index 0ccc54eb7..7493b25d7 100644 --- a/include/aidge/operator/Flatten.hpp +++ b/include/aidge/operator/Flatten.hpp @@ -38,6 +38,10 @@ public: */ Flatten_OpImpl(const Operator& op, const std::string& backend = ""): OperatorImpl(op, backend) {} + std::shared_ptr<ProdConso> getProdConso() const override { + return std::make_shared<ProdConso>(mOp, true); // Flatten is an in-place operation! + } + /** * @brief Compute the forward pass of the Flatten operation. */ diff --git a/include/aidge/operator/Identity.hpp b/include/aidge/operator/Identity.hpp index 24476f231..b1849cbc5 100644 --- a/include/aidge/operator/Identity.hpp +++ b/include/aidge/operator/Identity.hpp @@ -29,6 +29,11 @@ namespace Aidge { class Identity_OpImpl : public OperatorImpl { public: Identity_OpImpl(const Operator& op, const std::string& backend = ""): OperatorImpl(op, backend) {} + + std::shared_ptr<ProdConso> getProdConso() const override { + return std::make_shared<ProdConso>(mOp, true); // Identity is an in-place operation! + } + void forward() override; }; diff --git a/include/aidge/operator/Reshape.hpp b/include/aidge/operator/Reshape.hpp index f02dae45e..c8ac87b6f 100644 --- a/include/aidge/operator/Reshape.hpp +++ b/include/aidge/operator/Reshape.hpp @@ -37,6 +37,10 @@ public: Reshape_OpImpl(const Operator& op, const std::string& backend = "") : OperatorImpl(op, backend) {} + std::shared_ptr<ProdConso> getProdConso() const override { + return std::make_shared<ProdConso>(mOp, true); // Reshape is an in-place operation! + } + /** * @brief Perform the forward operation for the reshape. */ diff --git a/include/aidge/operator/Squeeze.hpp b/include/aidge/operator/Squeeze.hpp index 987f1e6af..ed0f6d366 100644 --- a/include/aidge/operator/Squeeze.hpp +++ b/include/aidge/operator/Squeeze.hpp @@ -38,6 +38,11 @@ class Squeeze_OpImpl : public OperatorImpl { public: Squeeze_OpImpl(const Operator &op, const std::string &backend = "") : OperatorImpl(op, backend) {} + + std::shared_ptr<ProdConso> getProdConso() const override { + return std::make_shared<ProdConso>(mOp, true); // Squeeze is an in-place operation! + } + void forward() override; }; } // namespace Aidge diff --git a/include/aidge/operator/Unsqueeze.hpp b/include/aidge/operator/Unsqueeze.hpp index 5975ff057..8d95f5cdd 100644 --- a/include/aidge/operator/Unsqueeze.hpp +++ b/include/aidge/operator/Unsqueeze.hpp @@ -35,6 +35,11 @@ class Unsqueeze_OpImpl : public OperatorImpl { public: Unsqueeze_OpImpl(const Operator &op, const std::string &backend = "") : OperatorImpl(op, backend) {} + + std::shared_ptr<ProdConso> getProdConso() const override { + return std::make_shared<ProdConso>(mOp, true); // Unsqueeze is an in-place operation! + } + void forward() override; }; } // namespace Aidge -- GitLab