Skip to content

Aidge export

Cyril Moineau requested to merge AidgeExport into dev

The goal of this MR is to add the possibility to export a neural network to a C++ code described with the Aidge API.

Usage Example

import aidge_core
import aidge_backend_cpu
import aidge_onnx

import numpy as np


graph = aidge_onnx.load_onnx("model.onnx")
aidge_core.remove_flatten(graph)
graph.compile('cpu', aidge_core.DataType.Float32, dims=[[1,3,32,32]])

in_tensor = aidge_core.Producer(aidge_core.Tensor(np.ones((1,3,32,32))), name="data")
in_tensor.get_operator().set_datatype(aidge_core.DataType.Float32)
in_tensor.get_operator().set_backend("cpu")
in_tensor.add_child(graph)
graph.add(in_tensor)
scheduler = aidge_core.SequentialScheduler(graph)

scheduler.generate_scheduling()

aidge_core.export("export_aidge", graph, scheduler)

This will generate the follwoing export:

.
+--- python_binding
|   +--- pybind.cpp
+--- main.cpp
+--- version.txt
+--- CMakeLists.txt
+--- export-config.cmake.in
+--- project_name.txt
+--- cmake
|   +--- PybindModuleCreation.cmake
|   +--- CodeCoverage.cmake
+--- include
|   +--- parameters
|   |   +--- _fc1_Gemm_output_0_2.hpp
|   |   +--- _fc2_Gemm_output_0_1.hpp
|   |   +--- _fc1_Gemm_output_0_1.hpp
|   |   +--- _conv1_Conv_output_0_1.hpp
|   |   +--- _conv2_Conv_output_0_2.hpp
|   |   +--- _conv1_Conv_output_0_0.hpp
|   |   +--- _conv1_Conv_output_0_2.hpp
|   |   +--- data_22_1.hpp
|   |   +--- _fc2_Gemm_output_0_2.hpp
|   |   +--- data_22_2.hpp
|   |   +--- _conv2_Conv_output_0_1.hpp
|   +--- dnn.hpp
|   +--- attributes
|   |   +--- _fc1_Gemm_output_0.hpp
|   |   +--- _pool_MaxPool_output_0.hpp
|   |   +--- _fc2_Gemm_output_0.hpp
|   |   +--- _pool_1_MaxPool_output_0.hpp
|   |   +--- data_22.hpp
|   |   +--- _conv2_Conv_output_0.hpp
|   |   +--- _conv1_Conv_output_0.hpp
+--- README.md
+--- src
|   +--- dnn.cpp

TODO:

  • Refactor code to use PathLib every where
  • Handle different types than float
  • Update copies Cmake
    • Remove coverage test
  • Add unit test, infer whith a model, export and check result of the export
  • Export generated should use the name of the folder has a project name (today, the project name is "export")
  • Rename aidge_core.export -> aidge_core.export_utils
Edited by Cyril Moineau

Merge request reports

Loading