From 14b473c3abdbbf39c5c571929791f5f863f4ebf5 Mon Sep 17 00:00:00 2001 From: cmoineau <cyril.moineau@cea.fr> Date: Thu, 5 Dec 2024 12:25:46 +0000 Subject: [PATCH] Fix export path. --- aidge_export_arm_cortexm/__init__.py | 5 +++++ aidge_export_arm_cortexm/export.py | 6 +----- aidge_export_arm_cortexm/operators.py | 22 +++++++++++++++++++--- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/aidge_export_arm_cortexm/__init__.py b/aidge_export_arm_cortexm/__init__.py index 7794c23..846fe42 100644 --- a/aidge_export_arm_cortexm/__init__.py +++ b/aidge_export_arm_cortexm/__init__.py @@ -3,7 +3,12 @@ Use this module to generate CPP exports for ARM CortexM boards. This module has to be used with the Aidge suite """ +from pathlib import Path + +FILE = Path(__file__).resolve() +ROOT = FILE.parents[0] from .export import * from .export_registry import ExportLibAidgeARM, ExportLibCMSISNN from .operators import * + diff --git a/aidge_export_arm_cortexm/export.py b/aidge_export_arm_cortexm/export.py index be332bc..95b09b2 100644 --- a/aidge_export_arm_cortexm/export.py +++ b/aidge_export_arm_cortexm/export.py @@ -1,7 +1,7 @@ import os import shutil from pathlib import Path -from aidge_export_arm_cortexm.utils import (ROOT, AVAILABLE_BOARDS, has_board) +from aidge_export_arm_cortexm import ROOT from aidge_export_arm_cortexm.export_registry import ExportLibAidgeARM # from aidge_export_arm_cortexm.utils.converter import numpy_dtype2ctype @@ -50,7 +50,3 @@ def gen_board_files(path:str, board:str)->None: # Copy all static files in the export shutil.copytree(BOARDS_MAP[board], str(path), dirs_exist_ok=True) - # For N2D2 library, copy static folder to export/include - dnn_include_folder = dnn_folder / "include" - os.makedirs(str(dnn_include_folder), exist_ok=True) - shutil.copytree(str(ROOT / "_N2D2" / "static"), str(dnn_include_folder), dirs_exist_ok=True) diff --git a/aidge_export_arm_cortexm/operators.py b/aidge_export_arm_cortexm/operators.py index 64eb57c..9f00632 100644 --- a/aidge_export_arm_cortexm/operators.py +++ b/aidge_export_arm_cortexm/operators.py @@ -7,14 +7,30 @@ from typing import Tuple, List import aidge_core from aidge_core.export_utils import ExportNode, ExportNodeCpp from aidge_core.export_utils.code_generation import * -from aidge_export_arm_cortexm.utils import ROOT -from aidge_export_arm_cortexm.utils.converter import numpy_dtype2ctype -from aidge_export_arm_cortexm.utils.generation import * +from aidge_export_arm_cortexm import ROOT from aidge_export_arm_cortexm.export_registry import ExportLibAidgeARM ############################################## ############## Export functions ############## ############################################## +# Note: to remove +def numpy_dtype2ctype(dtype): + if dtype == np.int8: + return "int8_t" + elif dtype == np.int16: + return "int16_t" + elif dtype == np.int32: + return "int32_t" + elif dtype == np.int64: + return "int64_t" + elif dtype == np.float32: + return "float" + elif dtype == np.float64: + return "double" + # Add more dtype mappings as needed + else: + raise ValueError(f"Unsupported {dtype} dtype") + def export_params(name:str, array: np.ndarray, -- GitLab