Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aidge_export_cpp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Charles Villard
aidge_export_cpp
Commits
034f98a5
Commit
034f98a5
authored
2 years ago
by
Vincent Templier
Browse files
Options
Downloads
Patches
Plain Diff
Update export and operator files with NodeExport
parent
b2eb8a11
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aidge_export_cpp/__init__.py
+6
-2
6 additions, 2 deletions
aidge_export_cpp/__init__.py
aidge_export_cpp/operators.py
+34
-3
34 additions, 3 deletions
aidge_export_cpp/operators.py
with
40 additions
and
5 deletions
aidge_export_cpp/__init__.py
+
6
−
2
View file @
034f98a5
...
...
@@ -45,15 +45,19 @@ def export(export_folder, graphview, scheduler):
list_configs
=
[]
list_forward_nodes
=
scheduler
.
get_static_scheduling
()
list_op
=
{}
for
node
in
list_forward
_nodes
:
for
node
in
graphview
.
get
_nodes
()
:
if
node
.
type
()
in
supported_operators
():
op
=
EXPORT_CPP_REGISTRY
[
node
.
type
()](
node
)
list_op
[
node
.
name
()]
=
op
else
:
continue
list_configs
=
op
.
export
(
dnn_folder
,
list_configs
)
list_actions
=
op
.
forward
(
list_actions
)
for
node
in
list_forward_nodes
:
list_actions
=
list_op
[
node
.
name
()].
forward
(
list_actions
)
# Memory management
...
...
This diff is collapsed.
Click to expand it.
aidge_export_cpp/operators.py
+
34
−
3
View file @
034f98a5
...
...
@@ -241,9 +241,8 @@ class ReLUCPP(ExportNode):
def
__init__
(
self
,
node
):
super
().
__init__
(
node
)
self
.
input_dims
=
self
.
input
.
get_operator
().
output
(
0
).
dims
()
self
.
nb_data
=
1
for
i
in
self
.
input_dims
:
for
i
in
self
.
input
s
_dims
[
0
]
:
self
.
nb_data
*=
i
def
export
(
self
,
export_folder
:
str
,
list_configs
:
list
):
...
...
@@ -270,7 +269,7 @@ class ReLUCPP(ExportNode):
list_actions
.
append
(
generate_action
(
KERNELS_FORWARD
.
ACTIVATION
,
name
=
self
.
name
,
input_name
=
self
.
input
[
0
].
name
(),
input_name
=
self
.
input
s
[
0
].
name
(),
output_name
=
self
.
name
))
return
list_actions
...
...
@@ -367,6 +366,14 @@ class FcCPP(ExportNode):
def
__init__
(
self
,
node
):
super
().
__init__
(
node
)
if
len
(
self
.
inputs_dims
[
0
])
==
2
:
self
.
inputs_dims
[
0
]
=
[
self
.
inputs_dims
[
0
][
1
],
1
,
1
]
elif
len
(
self
.
inputs_dims
[
0
])
==
4
:
self
.
inputs_dims
[
0
]
=
self
.
inputs_dims
[
0
][
1
:]
if
len
(
self
.
outputs_dims
[
0
])
==
2
:
self
.
outputs_dims
[
0
]
=
[
self
.
outputs_dims
[
0
][
1
],
1
,
1
]
def
export
(
self
,
export_folder
:
str
,
list_configs
:
list
):
copyfile
(
KERNELS
.
FC
,
f
"
{
export_folder
}
/include/kernels/
"
)
...
...
@@ -382,6 +389,10 @@ class FcCPP(ExportNode):
output_dims
=
self
.
outputs_dims
[
0
],
activation
=
"
Linear
"
,
rescaling
=
"
NoScaling
"
)
print
(
self
.
name
)
print
(
self
.
inputs_dims
[
0
])
print
(
self
.
outputs_dims
[
0
])
# TODO : replace this by producer node export !
# for i in range(len(self.parameters)):
...
...
@@ -408,3 +419,23 @@ class FcCPP(ExportNode):
biases_name
=
self
.
inputs
[
2
].
name
()
))
return
list_actions
@export_cpp_register
(
"
Producer
"
)
class
ProducerCPP
(
ExportNode
):
def
__init__
(
self
,
node
):
super
().
__init__
(
node
)
self
.
values
=
np
.
array
(
self
.
operator
.
output
(
0
))
def
export
(
self
,
export_folder
:
str
,
list_configs
:
list
):
list_configs
.
append
(
f
"
parameters/
{
self
.
name
}
.h
"
)
export_to_static
(
self
.
name
,
self
.
values
.
reshape
(
-
1
),
f
"
{
export_folder
}
/parameters/
{
self
.
name
}
.h
"
)
return
list_configs
def
forward
(
self
,
list_actions
:
list
):
return
list_actions
\ No newline at end of file
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