Skip to content
Snippets Groups Projects
Commit 515ef7d5 authored by Cyril Moineau's avatar Cyril Moineau Committed by Olivier BICHLER
Browse files

Applied proposed change in...

Applied proposed change in !189 (comment 2814405).
parent 7f304045
No related branches found
No related tags found
2 merge requests!212Version 0.3.0,!189Improve Remove Flatten
Pipeline #53907 passed
......@@ -22,28 +22,15 @@
namespace Aidge {
void removeFlatten(const std::set<NodePtr>& solution){
std::set<NodePtr> flattenNodes {};
for (const auto& node : solution) {
if (node->type() == "Flatten"){
printf("Flatten found.\n");
flattenNodes.insert(node);
}
else if (! (node->type() == "MatMul" || node->type() == "FC")){
AIDGE_THROW_OR_ABORT(std::runtime_error, "Node of type {} is not MatMul nor FC, an error during GraphMatching occured !", node->type());
}
}
GraphView::replace(flattenNodes, {});
}
void removeFlatten(std::shared_ptr<GraphView> graphView){
const auto matches = SinglePassGraphMatching(graphView).match(
"(FC|MatMul)<-(Flatten)+"
);
for (const auto& solution : matches) {
removeFlatten(solution.graph->getNodes());
auto flattenNodes(solution.graph->getNodes());
flattenNodes.erase(solution.graph->rootNode());
GraphView::replace(flattenNodes, {});
}
}
}
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