Skip to content
Snippets Groups Projects
Commit 649254e5 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Improved fuseToMetaOps to set backend of fused meta op

parent dcdb722d
No related branches found
No related tags found
2 merge requests!212Version 0.3.0,!197Improved fuseToMetaOps to set backend of fused meta op
Pipeline #54379 failed
......@@ -79,6 +79,7 @@ public:
return false;
}
std::string backend() const noexcept override;
void setBackend(const std::string &name, DeviceIdx_t device = 0) override;
......
......@@ -124,7 +124,7 @@ public:
///////////////////////////////////////////////////////
// IMPLEMENTATION
///////////////////////////////////////////////////////
std::string backend() const noexcept {
virtual std::string backend() const noexcept {
return mImpl ? mImpl->backend() : "";
}
......
......@@ -69,6 +69,12 @@ void Aidge::MetaOperator_Op::setInput(const Aidge::IOIndex_t inputIdx, const std
mInputs[inputIdx] = std::dynamic_pointer_cast<Tensor>(inputOp.first->getOperator()->getRawInput(inputOp.second));
}
std::string Aidge::MetaOperator_Op::backend() const noexcept {
return (mImpl)
? mImpl->backend()
: mGraph->rootNode()->getOperator()->backend();
}
void Aidge::MetaOperator_Op::setBackend(const std::string &name, Aidge::DeviceIdx_t device) {
if (Registrar<MetaOperator_Op>::exists({name, type()})) {
// A custom implementation exists for this meta operator
......
......@@ -24,6 +24,12 @@ size_t Aidge::fuseToMetaOps(std::shared_ptr<GraphView> graphView, const std::str
size_t nbReplaced = 0;
for (const auto& match : matches) {
auto metaOp = MetaOperator(metaType.c_str(), match.graph->clone());
// Clone does not clone implementation, which is therefore empty.
// Use the root node backend for the meta op backend, even though some
// matching nodes might be on a different backend, as nodes in the meta
// op are required to share the same backend!
metaOp->getOperator()->setBackend(match.graph->rootNode()->getOperator()->backend());
auto metaOpGraph = std::make_shared<GraphView>();
metaOpGraph->add(metaOp, false);
const auto success = GraphView::replace(match.graph, metaOpGraph);
......
......@@ -612,6 +612,9 @@ void Aidge::Scheduler::saveStaticSchedulingDiagram(const std::string& fileName)
}
std::vector<std::shared_ptr<Aidge::Node>> Aidge::Scheduler::getStaticScheduling(std::size_t step) const {
AIDGE_ASSERT(!mStaticSchedule.empty(), "Scheduler::getStaticScheduling(): static scheduling is empty, did you generate scheduling first?");
AIDGE_ASSERT(step < mStaticSchedule.size(), "Scheduler::getStaticScheduling(): no static scheduling at step {} (available steps: {})", mStaticSchedule.size(), step);
const auto& staticSchedule = mStaticSchedule.at(step);
std::vector<std::shared_ptr<Node>> schedule;
std::transform(staticSchedule.begin(), staticSchedule.end(), std::back_inserter(schedule), [](const auto& v) { return v->node; });
......
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