From 302ebd0373c8bb4e9965a0cfdfd0090895b4852c Mon Sep 17 00:00:00 2001 From: bhalimi <benjamin.halimi@cea.fr> Date: Wed, 12 Mar 2025 10:12:52 +0000 Subject: [PATCH] draft the determineBackend() routine --- src/PTQ/PTQ.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/PTQ/PTQ.cpp b/src/PTQ/PTQ.cpp index f4396f0..42bac40 100644 --- a/src/PTQ/PTQ.cpp +++ b/src/PTQ/PTQ.cpp @@ -111,6 +111,35 @@ static std::shared_ptr<Aidge::Node> getUniqueChildren(std::shared_ptr<Aidge::Nod return *(childrenSet.begin()); } +static std::string determineBackend(std::shared_ptr<Aidge::Node> node) +{ + std::string backend = node->getOperator()->backend(); + + if (backend != "") + return backend; + else + { + // gather the parent backends + + std::set<std::string> parentBackends; + for (auto parent : node->getParents()) + parentBackends.insert(determineBackend(parent)); // it always answers a non empty value ! + + // check if we have two or more different backends gathered + + if (parentBackends.size() > 1) + { + Log::warn(" Unable to determine backend of node {} due to conflicting parent ones !", node->name()); + return (*parentBackends.begin()); + } + + // if all parents have the same backend return it + + if (parentBackends.size() == 1) + return (*parentBackends.begin()); + } +} + static int getInputIndex(std::shared_ptr<Node> node, std::shared_ptr<Node> parentNode) { int index = 0; -- GitLab