From e98f9c20722549ca3ef3d5cf07c4a2fd80d02633 Mon Sep 17 00:00:00 2001 From: bhalimi <benjamin.halimi@cea.fr> Date: Tue, 11 Feb 2025 13:44:03 +0000 Subject: [PATCH] add a backward pass for the metaoperators --- include/aidge/operator/MetaOperator.hpp | 7 +------ src/operator/MetaOperator.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/aidge/operator/MetaOperator.hpp b/include/aidge/operator/MetaOperator.hpp index c6ab45290..63ca56d0b 100644 --- a/include/aidge/operator/MetaOperator.hpp +++ b/include/aidge/operator/MetaOperator.hpp @@ -203,13 +203,8 @@ public: /** * @brief Perform the backward pass for the operator. - * - * @note Currently not implemented. */ - void backward() override { - AIDGE_THROW_OR_ABORT(std::runtime_error, "backward() not implemented yet for a MetaOperator"); - } - + void backward() override; /** * @brief Check if the operator is atomic. * diff --git a/src/operator/MetaOperator.cpp b/src/operator/MetaOperator.cpp index 96c5b219a..a7d2a1da8 100644 --- a/src/operator/MetaOperator.cpp +++ b/src/operator/MetaOperator.cpp @@ -273,6 +273,21 @@ void Aidge::MetaOperator_Op::forward() { } } +void Aidge::MetaOperator_Op::backward() { + if (mImpl) { + // A custom implementation exists for this meta operator + mImpl->backward(); + } + else { + // No custom implementation, use the individual operators implementations + if (!mScheduler) { + mScheduler = std::make_shared<SequentialScheduler>(mGraph, mUpperNode.lock()); + mScheduler->generateScheduling(); + } + mScheduler->backward(); + } +} + ///////////////////////////////////////////////// std::shared_ptr<Aidge::Node> Aidge::MetaOperator(const char *type, -- GitLab