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

Generate files with a modular project name

parent fd956788
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
......@@ -6,27 +6,63 @@ from .utils import supported_operators, OPERATORS_REGISTRY
from . import ROOT_EXPORT
from aidge_core import ExportNode, generate_file
def export(export_folder: str,
graphview: aidge_core.GraphView,
scheduler: aidge_core.Scheduler):
scheduler: aidge_core.Scheduler,
enable_python_binding: bool = True,
):
export_folder_path = Path(export_folder)
export_name = export_folder_path.name
### Creating export folder ###
# Create export directory
os.makedirs(export_folder, exist_ok=True)
# Cpy static files
shutil.copytree(ROOT_EXPORT / "static/", export_folder_path, dirs_exist_ok=True)
### Cpy static files ###
shutil.copytree(ROOT_EXPORT / "static/include",
export_folder_path / "include", dirs_exist_ok=True)
shutil.copytree(ROOT_EXPORT / "static/cmake",
export_folder_path / "cmake", dirs_exist_ok=True)
shutil.copyfile(ROOT_EXPORT / "static/CMakeLists.txt",
export_folder_path / "CMakeLists.txt")
shutil.copyfile(ROOT_EXPORT / "static/version.txt",
export_folder_path / "version.txt")
shutil.copyfile(ROOT_EXPORT / "static/README.md",
export_folder_path / "README.md")
shutil.copyfile(ROOT_EXPORT / "static/main.cpp",
export_folder_path / "main.cpp")
shutil.copyfile(ROOT_EXPORT / "static/export-config.cmake.in",
export_folder_path / f"{export_name}-config.cmake.in")
# Create project_name file
with open(export_folder_path / "project_name.txt", "w") as f:
f.write(export_name)
# Add files related to python binding if
if enable_python_binding:
os.makedirs(export_folder_path / "python_binding", exist_ok=True)
generate_file(
export_folder_path / "python_binding/pybind.cpp",
ROOT_EXPORT / "templates/pybind.jinja",
name=export_name,
)
# TODO: Add a main.py 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_actions = [] # List of string to construct graph
list_configs = [] # List of headers to include in dnn.cpp to access attribute and parameters
list_actions = [] # List of string to construct graph
set_operator = set()
for node in ordered_nodes:
if node.type() in supported_operators():
set_operator.add(node.type())
op = OPERATORS_REGISTRY[node.type()](node)
# TODO: list_configs and list_actions don't need to be passed by argument
# Export the configuration
list_configs = op.export(export_folder_path, list_configs)
......@@ -43,4 +79,3 @@ def export(export_folder: str,
operators=set_operator,
actions=list_actions,
)
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