diff --git a/aidge_core/static_analysis.py b/aidge_core/static_analysis.py index ddc494efc8e6c0f114a30660b146a80d46f58ab4..92922becb023aa51378dd5ac09cffb4fe05c7c0b 100644 --- a/aidge_core/static_analysis.py +++ b/aidge_core/static_analysis.py @@ -1,3 +1,4 @@ +import matplotlib import matplotlib.pyplot as plt from functools import partial import aidge_core @@ -54,20 +55,46 @@ class StaticAnalysisExt(aidge_core.StaticAnalysis): continue stats = self.get_op_stats(node) - series.append([namePtrTable[node], partial(callback, stats)()]) + name = namePtrTable[node] + attr = {} + if type(node.get_operator()) is aidge_core.GenericOperatorOp: + # Display Generic Op in orange + attr = {'color': 'orange'} + elif not node.get_operator().is_atomic(): + # Display Meta Op in bold + attr = {'fontweight': 'bold'} + elif node.type() not in aidge_core.get_keys_OperatorStats(): + # Display unsupported operator in red labels + attr = {'color': 'red'} + if attr: + name = (name, attr) + series.append([name, partial(callback, stats)()]) if title is None: title = str(callback) self._log_bar(series, filename, title, log_scale) def _log_bar(self, series, filename, title=None, log_scale=False): names, values = zip(*series) + names_only = [item[0] if isinstance(item, tuple) else item for item in names] fig, ax = plt.subplots(figsize=(max(5, len(names)/4), 5)) plt.xlim(-0.5, len(names) - 0.5) - plt.bar(names, values) + plt.bar(names_only, values) ax.yaxis.minorticks_on() plt.grid(axis='y', which='major', linestyle='--', color='gray') plt.grid(axis='y', which='minor', linestyle=':', color='lightgray') + formatter0 = matplotlib.ticker.EngFormatter(unit='') + ax.yaxis.set_major_formatter(formatter0) plt.gca().set_axisbelow(True) + + labels = plt.gca().get_xticks() + tick_labels = plt.gca().get_xticklabels() + for i, label in enumerate(labels): + if isinstance(names[i], tuple): + if 'color' in names[i][1]: + tick_labels[i].set_color(names[i][1]['color']) + elif 'fontweight' in names[i][1]: + tick_labels[i].set_fontweight(names[i][1]['fontweight']) + plt.xticks(rotation='vertical') if log_scale: plt.yscale('log') if title is not None: plt.title(title) diff --git a/python_binding/operator/pybind_Operator.cpp b/python_binding/operator/pybind_Operator.cpp index e22f88687eff6856ce57fab6621781ffc86873b4..a1d1889c9a1881d3aa7b6eb9ccb4c23c5314cc80 100644 --- a/python_binding/operator/pybind_Operator.cpp +++ b/python_binding/operator/pybind_Operator.cpp @@ -63,6 +63,7 @@ void init_Operator(py::module& m){ .def_property_readonly("attr", &Operator::attributes) .def("set_back_edges", &Operator::setBackEdges, py::arg("input_indexes")) .def("is_back_edge", &Operator::isBackEdge, py::arg("input_index")) + .def("is_atomic", &Operator::isAtomic) ; } }