Skip to content
Snippets Groups Projects
Commit 42b9cbab authored by Maxence Naud's avatar Maxence Naud Committed by Maxence Naud
Browse files

improve GraphView Mermaid visualization

parent b1067ec7
No related branches found
No related tags found
2 merge requests!279v0.4.0,!269[upd] GraphView Mermaid visualization
Pipeline #60515 passed
......@@ -157,15 +157,15 @@ void Aidge::GraphView::save(const std::string& path, bool verbose, bool showProd
const auto op = std::dynamic_pointer_cast<OperatorTensor>(node_ptr->getOperator());
if (op && !op->getOutput(outputIdx)->undefined()) {
dims += " " + fmt::format("{}", op->getOutput(outputIdx)->dims());
dtype += "\n" + fmt::format("{}", op->getOutput(outputIdx)->dataType());
dtype += " " + fmt::format("{}", op->getOutput(outputIdx)->dataType());
}
if (mNodes.find(child) != mNodes.end()) {
fmt::print(fp.get(), "{}_{}-->|\"{}{}{}&rarr;{}\"|{}_{}\n", node_ptr->type(), namePtrTable.at(node_ptr),
fmt::print(fp.get(), "{}_{}-->|\"{}{}{}<br/>&darr;<br/>{}\"|{}_{}\n", node_ptr->type(), namePtrTable.at(node_ptr),
outputIdx, dims, dtype, inputIdx, child->type(), namePtrTable.at(child));
}
else if (verbose) {
fmt::print(fp.get(), "{}_{}-->|\"{}{}{}&rarr;{}\"|{}:::externalCls\n", node_ptr->type(), namePtrTable.at(node_ptr),
fmt::print(fp.get(), "{}_{}-->|\"{}{}{}<br/>&darr;<br/>{}\"|{}:::externalCls\n", node_ptr->type(), namePtrTable.at(node_ptr),
outputIdx, dims, dtype, inputIdx, static_cast<void*>(child.get()));
}
// Do no break here because the same child can be connected to several inputs
......@@ -182,11 +182,13 @@ void Aidge::GraphView::save(const std::string& path, bool verbose, bool showProd
for (const auto& input : mInputNodes) {
if (input.first != nullptr) {
const auto& op_ = std::dynamic_pointer_cast<OperatorTensor>(input.first->getOperator());
if (op_->getInput(input.second) && (!op_->getInput(input.second)->empty())) {
fmt::print(fp.get(), "input{}((in#{})):::inputCls--->|\"&rarr;{}{}\"|{}_{}\n", inputIdx, inputIdx,
input.second, op_->getInput(input.second)->dims(), input.first->type(), namePtrTable.at(input.first));
if (op_->getInput(input.second) && (!op_->getInput(input.second)->undefined())) {
std::string dims = " " + fmt::format("{}", op_->getInput(input.second)->dims());
std::string dtype = " " + fmt::format("{}", op_->getInput(input.second)->dataType());
fmt::print(fp.get(), "input{}((in#{})):::inputCls--->|\"{}{}<br/>&darr;<br/>{}\"|{}_{}\n", inputIdx, inputIdx,
dims, dtype, input.second, input.first->type(), namePtrTable.at(input.first));
} else {
fmt::print(fp.get(), "input{}((in#{})):::inputCls--->|\"&rarr;{}\"|{}_{}\n", inputIdx, inputIdx,
fmt::print(fp.get(), "input{}((in#{})):::inputCls--->|\"&darr;<br/>{}\"|{}_{}\n", inputIdx, inputIdx,
input.second, input.first->type(), namePtrTable.at(input.first));
}
}
......@@ -201,14 +203,16 @@ void Aidge::GraphView::save(const std::string& path, bool verbose, bool showProd
if (output.first != nullptr) {
// Add-on to display the operator's output dimensions
std::string dims = "";
std::string dtype = "";
const auto op = std::dynamic_pointer_cast<OperatorTensor>(output.first->getOperator());
if (op && op->getOutput(output.second) && !op->getOutput(output.second)->undefined()) {
dims += " " + fmt::format("{}", op->getOutput(output.second)->dims());
dtype += " " + fmt::format("{}", op->getOutput(output.second)->dataType());
}
fmt::print(fp.get(), "{}_{}--->|\"{}{}&rarr;\"|output{}((out#{})):::outputCls\n",
fmt::print(fp.get(), "{}_{}--->|\"{}{}{}<br/>&darr;\"|output{}((out#{})):::outputCls\n",
output.first->type(), namePtrTable.at(output.first), output.second,
dims, outputIdx, outputIdx);
dims, dtype, outputIdx, outputIdx);
}
else {
fmt::print(fp.get(), "output{}((out#{})):::outputCls\n", outputIdx, outputIdx);
......@@ -1236,7 +1240,6 @@ bool Aidge::GraphView::replace(const std::shared_ptr<GraphView>& oldGraph, const
if (removeFromGraphs) {
for (const auto& g : commonGraphViews) {
g -> remove(nodePtr, false);
g -> updateInputsOutputsDelete(nodePtr);
}
nodePtr -> resetConnections(true);
}
......
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