diff --git a/src/PTQ/PTQ.cpp b/src/PTQ/PTQ.cpp index f4396f057f5e807c95848f0c77b6a7837f54c4b9..42bac4051eadef07aa46e153bb3de654b6f4ea31 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;