Skip to content
Snippets Groups Projects
Commit c1e2ad93 authored by Cyril Moineau's avatar Cyril Moineau
Browse files

Update Aidge export to take a graph view has an argument instead of a...

Update Aidge export to take a graph view has an argument instead of a Scheduler has we do not need scheduled graph.
parent 0ed2e8b5
No related branches found
No related tags found
2 merge requests!152Update Aidge export to take a graph view has an argument instead of a...,!115Aidge export
Pipeline #48533 canceled
...@@ -11,7 +11,7 @@ from aidge_core import ExportNode, generate_file ...@@ -11,7 +11,7 @@ from aidge_core import ExportNode, generate_file
def export(export_folder: str, def export(export_folder: str,
scheduler: aidge_core.Scheduler, graph_view: aidge_core.GraphView,
enable_python_binding: bool = True, enable_python_binding: bool = True,
): ):
export_folder_path = Path(export_folder) export_folder_path = Path(export_folder)
...@@ -52,12 +52,35 @@ def export(export_folder: str, ...@@ -52,12 +52,35 @@ def export(export_folder: str,
# TODO: Add a main.py file ? # TODO: Add a main.py file ?
### Generating an export for each nodes and dnn file ### ### Generating an export for each nodes and dnn file ###
ordered_nodes = scheduler.get_static_scheduling()
list_configs = [] # List of headers to include in dnn.cpp to access attribute and parameters list_configs = [] # List of headers to include in dnn.cpp to access attribute and parameters
list_actions = [] # List of string to construct graph list_actions = [] # List of string to construct graph
set_operator = set() set_operator = set()
for node in ordered_nodes: # Queue of Aidge nodes to explore, guarantee a topological exploration of the graph
open_nodes = list(graph_view.get_input_nodes())
# List of Aidge nodes already explored
closed_nodes = []
while open_nodes:
node = open_nodes.pop(0)
if node in closed_nodes:
continue # Node already converted, moving on ...
parents_not_converted = False
# Check all parents have been converted
for parent in node.get_parents():
if parent is not None and \
parent not in closed_nodes:
# If parents have not been converted, push back current node
if not parents_not_converted:
open_nodes.insert(0, node)
parents_not_converted = True
# Add to the stack the not converted parent as next node to convert
open_nodes.insert(0, parent)
if parents_not_converted:
continue
# Next nodes to treat are children of current node
open_nodes += list(node.get_children())
if node.type() in supported_operators(): if node.type() in supported_operators():
set_operator.add(node.type()) set_operator.add(node.type())
op = OPERATORS_REGISTRY[node.type()](node) op = OPERATORS_REGISTRY[node.type()](node)
...@@ -70,7 +93,7 @@ def export(export_folder: str, ...@@ -70,7 +93,7 @@ def export(export_folder: str,
list_actions = op.forward(list_actions) list_actions = op.forward(list_actions)
else: else:
raise RuntimeError(f"Operator: {node.type()} is not supported") raise RuntimeError(f"Operator: {node.type()} is not supported")
closed_nodes.append(node)
# Generate full dnn.cpp # Generate full dnn.cpp
aidge_core.generate_file( aidge_core.generate_file(
export_folder_path / "src/dnn.cpp", export_folder_path / "src/dnn.cpp",
......
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