Skip to content

Add possibility to register custom attributes and metadata

Cyril Moineau requested to merge custom_attr into dev

Fix #4 (closed)

  • [dev] Remove coerage job in accordance with gitlab_shared_files#11
  • [feat] Allow to pass a config on how to convert aidge_core.Node (to add attributes or output metadata).

Usage example:

import aidge_onnx
import aidge_model_explorer
import model_explorer


model = aidge_onnx.load_onnx("aidge_mobilenetV2.onnx")

conv_config = aidge_model_explorer.ConverterConfig()
# Will set an attribute isConv to every Conv2D adn ConvDepthWise2D
# Allowing to later colorize node woth this attribute.
conv_config.add_attribute("isConv",
                          lambda node: "" if (node.type() == "Conv2D" or node.type() == "ConvDepthWise2D") else None)

# Compute tensor mean and set it as a metadata
conv_config.add_output_metadata("mean",
                          lambda _, tensor: str(tensor.mean()))

config = aidge_model_explorer.config()
config.add_graphview(model, "model1", conv_config)

model_explorer.visualize_from_config(config)
Edited by Cyril Moineau

Merge request reports

Loading