Skip to content
Snippets Groups Projects

Low bit support for ARM Cortex-M export

Merged Thibault Allenet requested to merge low_bit_support_arm into dev
2 files
+ 55
15
Compare changes
  • Side-by-side
  • Inline
Files
2
import numpy as np
import numpy as np
import aidge_core
import aidge_core
 
from typing import Dict
datatype_converter_aide2c = {
datatype_converter_aidge2c = {
aidge_core.dtype.float64 : "double",
aidge_core.dtype.float64 : "double",
aidge_core.dtype.float32 : "float",
aidge_core.dtype.float32 : "float",
aidge_core.dtype.float16 : "half_float::half",
aidge_core.dtype.float16 : "half_float::half",
@@ -26,9 +27,24 @@ def aidge2c(datatype):
@@ -26,9 +27,24 @@ def aidge2c(datatype):
:return: A string representing the C type
:return: A string representing the C type
:rtype: string
:rtype: string
"""
"""
if datatype in datatype_converter_aide2c:
if datatype in datatype_converter_aidge2c:
return datatype_converter_aide2c[datatype]
return datatype_converter_aidge2c[datatype]
else:
else:
# raise ValueError(f"Unsupported {datatype} aidge datatype")
raise ValueError(f"Unsupported {datatype} aidge datatype")
aidge_core.Log.warn(f"Unsupported conversion of {datatype} (aidge datatype) to a C type.")
return None
def aidge2export_type(datatype: aidge_core.dtype, conversion_map: Dict[aidge_core.dtype, str] = datatype_converter_aidge2c) -> str:
 
"""Convert a aidge datatype to the export type specified by the map passed in argument
 
 
If the aidge type is not convertible, that is to say, is not specified in the map, a value Error is raised.
 
 
:param datatype: Aidge datatype to convert
 
:type datatype: :py:object:`aidge_core.DataType`
 
:param conversion_map: Map that specify the conversion
 
:type conversion_map: Dict[:py:object:`aidge_core.DataType`, str]
 
:return: A string representing the export type
 
:rtype: string
 
"""
 
if datatype in conversion_map:
 
return conversion_map[datatype]
 
else:
 
raise ValueError(f"Unsupported type conversion {datatype} aidge datatype for export")
Loading