Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aidge_export_arm_cortexm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eclipse Projects
aidge
aidge_export_arm_cortexm
Commits
d12fb1bd
Commit
d12fb1bd
authored
8 months ago
by
Cyril Moineau
Browse files
Options
Downloads
Patches
Plain Diff
Use aidge2c to convert datatype instead of aidge_datatype2ctype.
parent
105ac6e4
No related branches found
No related tags found
2 merge requests
!17
v0.1.0
,
!12
v0.4.0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aidge_export_arm_cortexm/operators.py
+14
-12
14 additions, 12 deletions
aidge_export_arm_cortexm/operators.py
aidge_export_arm_cortexm/utils/converter.py
+2
-2
2 additions, 2 deletions
aidge_export_arm_cortexm/utils/converter.py
with
16 additions
and
14 deletions
aidge_export_arm_cortexm/operators.py
+
14
−
12
View file @
d12fb1bd
...
...
@@ -9,8 +9,10 @@ from typing import Tuple, List, Union, Dict
import
aidge_core
from
aidge_core
import
ExportNode
from
aidge_core.export_utils.code_generation
import
*
from
aidge_core.export_utils.data_conversion
import
aidge2c
from
aidge_export_arm_cortexm.utils
import
ROOT
,
operator_register
from
aidge_export_arm_cortexm.utils.converter
import
numpy_dtype2ctype
,
aidge_datatype2dataformat
,
aidge
_datatype2ctype
from
aidge_export_arm_cortexm.utils.converter
import
numpy_dtype2ctype
,
aidge_datatype2dataformat
,
aidge
2c
from
aidge_export_arm_cortexm.utils.generation
import
*
##############################################
...
...
@@ -210,7 +212,7 @@ class ReLU_ARMCortexM(ExportNode):
self
.
board
=
board
self
.
library
=
library
self
.
dataformat
=
aidge_datatype2dataformat
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
self
.
datatype
=
aidge
_datatype2ctype
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
self
.
datatype
=
aidge
2c
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
def
export
(
self
,
export_folder
:
Path
,
list_configs
:
list
):
...
...
@@ -263,7 +265,7 @@ class Conv_ARMCortexM(ExportNode):
self
.
board
=
board
self
.
library
=
library
self
.
dataformat
=
aidge_datatype2dataformat
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
self
.
datatype
=
aidge
_datatype2ctype
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
self
.
datatype
=
aidge
2c
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
self
.
scaling
=
Scaling
()(
"
no_scaling
"
)
self
.
activation
=
"
Linear
"
...
...
@@ -386,7 +388,7 @@ class PaddedConv_ARMCortexM(Conv_ARMCortexM):
self
.
board
=
board
self
.
library
=
library
self
.
dataformat
=
aidge_datatype2dataformat
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
self
.
datatype
=
aidge
_datatype2ctype
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
self
.
datatype
=
aidge
2c
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
self
.
scaling
=
Scaling
()(
"
no_scaling
"
)
self
.
activation
=
"
Linear
"
...
...
@@ -420,13 +422,13 @@ class ConvReluScaling_ARMCortexM(Conv_ARMCortexM):
self
.
activation
=
"
Rectifier
"
# Should do this line but there is a bug while changing the datatype of generic operator...
# self.datatype = aidge
_datatype2ctype
(node.get_operator().get_output(0).dtype())
# self.datatype = aidge
2c
(node.get_operator().get_output(0).dtype())
# Do this instead
if
self
.
operator
.
get_attr
(
"
quantizedNbBits
"
)
==
8
:
if
self
.
operator
.
get_attr
(
"
isOutputUnsigned
"
):
self
.
datatype
=
aidge
_datatype2ctype
(
aidge_core
.
DataType
.
UInt8
)
self
.
datatype
=
aidge
2c
(
aidge_core
.
DataType
.
UInt8
)
else
:
self
.
datatype
=
aidge
_datatype2ctype
(
aidge_core
.
DataType
.
Int8
)
self
.
datatype
=
aidge
2c
(
aidge_core
.
DataType
.
Int8
)
# Impose Single Shift (perhaps change it to have a more modular system)
self
.
scaling
=
Scaling
(
self
.
operator
.
get_attr
(
"
scalingFactor
"
),
...
...
@@ -440,7 +442,7 @@ class Pooling_ARMCortexM(ExportNode):
self
.
board
=
board
self
.
library
=
library
self
.
dataformat
=
aidge_datatype2dataformat
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
self
.
datatype
=
aidge
_datatype2ctype
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
self
.
datatype
=
aidge
2c
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
self
.
pool_type
=
"
None
"
self
.
activation
=
"
Linear
"
...
...
@@ -564,7 +566,7 @@ class FC_ARMCortexM(ExportNode):
self
.
board
=
board
self
.
library
=
library
self
.
dataformat
=
aidge_datatype2dataformat
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
self
.
datatype
=
aidge
_datatype2ctype
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
self
.
datatype
=
aidge
2c
(
node
.
get_operator
().
get_output
(
0
).
dtype
())
self
.
scaling
=
Scaling
()(
"
no_scaling
"
)
self
.
activation
=
"
Linear
"
...
...
@@ -675,13 +677,13 @@ class FCScaling_ARMCortexM(FC_ARMCortexM):
super
(
FC_ARMCortexM
,
self
).
__init__
(
node
,
board
,
library
)
# Should do this line but there is a bug while changing the datatype of generic operator...
# self.datatype = aidge
_datatype2ctype
(node.get_operator().get_output(0).dtype())
# self.datatype = aidge
2c
(node.get_operator().get_output(0).dtype())
# Do this instead
if
self
.
operator
.
get_attr
(
"
quantizedNbBits
"
)
==
8
:
if
self
.
operator
.
get_attr
(
"
isOutputUnsigned
"
):
self
.
datatype
=
aidge
_datatype2ctype
(
aidge_core
.
DataType
.
UInt8
)
self
.
datatype
=
aidge
2c
(
aidge_core
.
DataType
.
UInt8
)
else
:
self
.
datatype
=
aidge
_datatype2ctype
(
aidge_core
.
DataType
.
Int8
)
self
.
datatype
=
aidge
2c
(
aidge_core
.
DataType
.
Int8
)
# Impose Single Shift (perhaps change it to have a more modular system)
self
.
scaling
=
Scaling
(
self
.
operator
.
get_attr
(
"
scalingFactor
"
),
...
...
This diff is collapsed.
Click to expand it.
aidge_export_arm_cortexm/utils/converter.py
+
2
−
2
View file @
d12fb1bd
...
...
@@ -19,7 +19,7 @@ def numpy_dtype2ctype(dtype):
# Add more dtype mappings as needed
else
:
raise
ValueError
(
f
"
Unsupported
{
dtype
}
dtype
"
)
def
aidge_datatype2ctype
(
datatype
):
if
datatype
==
aidge_core
.
DataType
.
Int8
:
...
...
@@ -37,7 +37,7 @@ def aidge_datatype2ctype(datatype):
# Add more dtype mappings as needed
else
:
raise
ValueError
(
f
"
Unsupported
{
datatype
}
aidge datatype
"
)
def
aidge_datatype2dataformat
(
datatype
):
if
datatype
==
aidge_core
.
DataType
.
Int8
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment