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
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
Axel Farrugia
aidge_export_cpp
Commits
1a4bf629
Commit
1a4bf629
authored
10 months ago
by
Maxence Naud
Browse files
Options
Downloads
Patches
Plain Diff
Remove merge artifacts
parent
c5e15c4f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aidge_export_cpp/operators.py
+0
-173
0 additions, 173 deletions
aidge_export_cpp/operators.py
with
0 additions
and
173 deletions
aidge_export_cpp/operators.py
+
0
−
173
View file @
1a4bf629
...
@@ -192,7 +192,6 @@ class MaxPoolCPP(ExportNodeCpp):
...
@@ -192,7 +192,6 @@ class MaxPoolCPP(ExportNodeCpp):
# No padding with MaxPooling
# No padding with MaxPooling
# Use PaddedMaxPooling to add padding attribute
# Use PaddedMaxPooling to add padding attribute
<<<<<<<
HEAD
self
.
attributes
[
"
padding
"
]
=
[
0
,
0
]
self
.
attributes
[
"
padding
"
]
=
[
0
,
0
]
self
.
attributes
[
"
pool_type
"
]
=
"
Max
"
self
.
attributes
[
"
pool_type
"
]
=
"
Max
"
self
.
attributes
[
"
activation
"
]
=
"
Linear
"
self
.
attributes
[
"
activation
"
]
=
"
Linear
"
...
@@ -281,175 +280,3 @@ class FcCPP(ExportNodeCpp):
...
@@ -281,175 +280,3 @@ class FcCPP(ExportNodeCpp):
str
(
ROOT
/
"
kernels
"
/
"
activation.hpp
"
),
str
(
ROOT
/
"
kernels
"
/
"
activation.hpp
"
),
str
(
ROOT
/
"
kernels
"
/
"
rescaling.hpp
"
)
str
(
ROOT
/
"
kernels
"
/
"
rescaling.hpp
"
)
]
]
=======
self
.
padding
=
[
0
,
0
]
if
len
(
self
.
inputs_dims
[
0
])
==
4
:
# if dims == [batch, nb_channels, height, width]
# transform to [nb_channels, height, width]
self
.
inputs_dims
[
0
]
=
self
.
inputs_dims
[
0
][
1
:]
if
len
(
self
.
outputs_dims
[
0
])
==
4
:
# if dims == [batch, nb_outputs]
# transform to [nb_outputs, 1, 1]
self
.
outputs_dims
[
0
]
=
self
.
outputs_dims
[
0
][
1
:]
def
export
(
self
,
export_folder
:
Path
,
list_configs
:
list
):
copyfile
(
str
(
ROOT
/
"
kernels
"
/
"
pooling.hpp
"
),
str
(
export_folder
/
"
include
"
/
"
kernels
"
))
list_configs
.
append
(
"
kernels/pooling.hpp
"
)
list_configs
.
append
(
f
"
layers/
{
self
.
name
}
.h
"
)
generate_file
(
str
(
export_folder
/
"
layers
"
/
f
"
{
self
.
name
}
.h
"
),
str
(
ROOT
/
"
templates
"
/
"
configuration
"
/
"
pooling_config.jinja
"
),
name
=
self
.
name
,
input_dims
=
self
.
inputs_dims
[
0
],
output_dims
=
self
.
outputs_dims
[
0
],
kernel
=
self
.
kernel
,
stride
=
self
.
stride
,
padding
=
self
.
padding
,
pool_type
=
"
Max
"
,
activation
=
"
Linear
"
)
return
list_configs
def
forward
(
self
,
list_actions
:
list
):
if
not
self
.
is_last
:
list_actions
.
append
(
set_up_output
(
self
.
name
,
"
float
"
))
list_actions
.
append
(
generate_str
(
str
(
ROOT
/
"
templates
"
/
"
kernel_forward
"
/
"
pooling_forward.jinja
"
),
name
=
self
.
name
,
input_name
=
self
.
inputs
[
0
].
name
()
if
self
.
inputs
[
0
]
else
self
.
name
+
"
_input
"
,
output_name
=
self
.
name
))
return
list_actions
@operator_register
(
"
FC
"
)
class
FcCPP
(
ExportNode
):
def
__init__
(
self
,
node
):
super
().
__init__
(
node
)
if
len
(
self
.
inputs_dims
[
0
])
==
4
:
# if dims == [batch, nb_channels, height, width]
# transform to [nb_channels, height, width]
self
.
inputs_dims
[
0
]
=
self
.
inputs_dims
[
0
][
1
:]
elif
len
(
self
.
inputs_dims
[
0
])
==
2
:
# if dims == [batch, nb_channels]
# transform to [nb_channels, 1, 1]
self
.
inputs_dims
[
0
]
=
[
self
.
inputs_dims
[
0
][
1
],
1
,
1
]
if
len
(
self
.
outputs_dims
[
0
])
==
2
:
# if dims == [batch, nb_outputs]
# transform to [nb_outputs, 1, 1]
self
.
outputs_dims
[
0
]
=
[
self
.
outputs_dims
[
0
][
1
],
1
,
1
]
def
export
(
self
,
export_folder
:
Path
,
list_configs
:
list
):
copyfile
(
str
(
ROOT
/
"
kernels
"
/
"
fullyconnected.hpp
"
),
str
(
export_folder
/
"
include
"
/
"
kernels
"
))
copyfile
(
str
(
ROOT
/
"
kernels
"
/
"
macs.hpp
"
),
str
(
export_folder
/
"
include
"
/
"
kernels
"
))
copyfile
(
str
(
ROOT
/
"
kernels
"
/
"
activation.hpp
"
),
str
(
export_folder
/
"
include
"
/
"
kernels
"
))
# Add to config list the include of configurations
list_configs
.
append
(
"
kernels/fullyconnected.hpp
"
)
list_configs
.
append
(
f
"
layers/
{
self
.
name
}
.h
"
)
# Export configuration file
generate_file
(
str
(
export_folder
/
"
layers
"
/
f
"
{
self
.
name
}
.h
"
),
str
(
ROOT
/
"
templates
"
/
"
configuration
"
/
"
fullyconnected_config.jinja
"
),
name
=
self
.
name
,
input_dims
=
self
.
inputs_dims
[
0
],
output_dims
=
self
.
outputs_dims
[
0
],
activation
=
"
Linear
"
,
rescaling
=
"
NoScaling
"
)
return
list_configs
def
forward
(
self
,
list_actions
:
list
):
if
not
self
.
is_last
:
list_actions
.
append
(
set_up_output
(
self
.
name
,
"
float
"
))
list_actions
.
append
(
generate_str
(
str
(
ROOT
/
"
templates
"
/
"
kernel_forward
"
/
"
fullyconnected_forward.jinja
"
),
name
=
self
.
name
,
inputs_name
=
self
.
inputs
[
0
].
name
()
if
(
self
.
inputs
[
0
]
is
not
None
)
else
self
.
name
+
'
_input
'
,
weights_name
=
self
.
inputs
[
1
].
name
(),
biases_name
=
self
.
inputs
[
2
].
name
(),
outputs_name
=
self
.
name
))
return
list_actions
@operator_register
(
"
MatMul
"
)
class
MatMulCPP
(
ExportNode
):
def
__init__
(
self
,
node
):
super
().
__init__
(
node
)
dims0
,
dims1
,
outdims
=
[
tuple
(
x
)
for
x
in
[
self
.
inputs_dims
[
0
],
self
.
inputs_dims
[
1
],
self
.
outputs_dims
[
0
]]]
# TODO: MatMul aidge operator supports N-D multi broadcast dimensions where N > 2
assert
len
(
dims0
)
<=
2
and
len
(
dims1
)
<=
2
,
(
f
"
MatMul export do not support yet dimensions above 2D: inputs shapes are:
{
dims0
}
,
{
dims1
}
"
)
# Cast to at least 1D
# Note that from MatMul::forwardDims(), scalar inputs are supported
# which is actually more general than np.matmul
dims0
=
dims0
if
len
(
dims0
)
>=
1
else
(
1
,
1
)
dims1
=
dims1
if
len
(
dims1
)
>=
1
else
(
1
,
1
)
# Cast to at least 2D
dims0
=
dims0
if
len
(
dims0
)
>=
2
else
(
1
,
dims0
[
0
])
dims1
=
dims1
if
len
(
dims1
)
>=
2
else
(
dims1
[
0
],
1
)
assert
dims0
[
1
]
==
dims1
[
0
],
(
f
"
MatMul input dimensions do no match, expected (m, k), (k, n): inputs shapes are:
{
dims0
}
,
{
dims1
}
"
)
outdims
=
outdims
if
len
(
outdims
)
>
0
else
(
1
,
1
)
assert
outdims
==
(
dims0
[
0
],
dims1
[
1
]),
(
f
"
MatMul output dimensions do no match, expected (m, n) for inputs (m, k) (k, n): output shape is:
{
outdims
}
, inputs shapes are:
{
dims0
}
,
{
dims1
}
"
)
self
.
matmul_inputs_dims
=
dims0
,
dims1
self
.
matmul_output_dims
=
outdims
def
export
(
self
,
export_folder
:
Path
,
list_configs
:
list
):
copyfile
(
str
(
ROOT
/
"
kernels
"
/
"
matmul.hpp
"
),
str
(
export_folder
/
"
include
"
/
"
kernels
"
))
copyfile
(
str
(
ROOT
/
"
kernels
"
/
"
activation.hpp
"
),
str
(
export_folder
/
"
include
"
/
"
kernels
"
))
# Add to config list the include of configurations
list_configs
.
append
(
"
kernels/matmul.hpp
"
)
list_configs
.
append
(
f
"
layers/
{
self
.
name
}
.h
"
)
# Export configuration file
generate_file
(
str
(
export_folder
/
"
layers
"
/
f
"
{
self
.
name
}
.h
"
),
str
(
ROOT
/
"
templates
"
/
"
configuration
"
/
"
matmul_config.jinja
"
),
name
=
self
.
name
,
inputs_dims
=
self
.
matmul_inputs_dims
,
output_dims
=
self
.
matmul_output_dims
,
activation
=
"
Linear
"
,
rescaling
=
"
NoScaling
"
,
)
return
list_configs
def
forward
(
self
,
list_actions
:
list
):
if
not
self
.
is_last
:
list_actions
.
append
(
set_up_output
(
self
.
name
,
"
float
"
))
list_actions
.
append
(
generate_str
(
str
(
ROOT
/
"
templates
"
/
"
kernel_forward
"
/
"
matmul_forward.jinja
"
),
name
=
self
.
name
,
inputs1_name
=
self
.
inputs
[
0
].
name
()
if
self
.
inputs
[
0
]
else
self
.
name
+
"
_input1
"
,
inputs2_name
=
self
.
inputs
[
1
].
name
()
if
self
.
inputs
[
1
]
else
self
.
name
+
"
_input2
"
,
outputs_name
=
self
.
name
))
return
list_actions
>>>>>>>
origin
/
dev
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