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
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_cpp
Commits
dc6653a0
Unverified
Commit
dc6653a0
authored
1 month ago
by
Maxence Naud
Browse files
Options
Downloads
Patches
Plain Diff
[rm] Conv type conversion warnings
parent
10ca7e16
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!71
0.4.0
,
!61
Fix conv type conversion warnings
Pipeline
#78988
passed
1 month ago
Stage: static_analysis
Stage: build
Stage: test
Stage: coverage
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aidge_export_cpp/kernels/convolution.hpp
+59
-59
59 additions, 59 deletions
aidge_export_cpp/kernels/convolution.hpp
with
59 additions
and
59 deletions
aidge_export_cpp/kernels/convolution.hpp
+
59
−
59
View file @
dc6653a0
...
...
@@ -8,27 +8,27 @@
#include
"network/activation_utils.hpp"
template
<
in
t
NB_CHANNELS
,
in
t
CHANNELS_HEIGHT
,
in
t
CHANNELS_WIDTH
,
in
t
NB_OUTPUTS
,
in
t
OUTPUTS_HEIGHT
,
in
t
OUTPUTS_WIDTH
,
in
t
PADDING_Y
,
in
t
PADDING_X
,
in
t
STRIDE_Y
,
in
t
STRIDE_X
,
in
t
DILATION_Y
,
in
t
DILATION_X
,
in
t
KERNEL_HEIGHT
,
in
t
KERNEL_WIDTH
,
template
<
size_
t
NB_CHANNELS
,
size_
t
CHANNELS_HEIGHT
,
size_
t
CHANNELS_WIDTH
,
size_
t
NB_OUTPUTS
,
size_
t
OUTPUTS_HEIGHT
,
size_
t
OUTPUTS_WIDTH
,
size_
t
PADDING_Y
,
size_
t
PADDING_X
,
size_
t
STRIDE_Y
,
size_
t
STRIDE_X
,
size_
t
DILATION_Y
,
size_
t
DILATION_X
,
size_
t
KERNEL_HEIGHT
,
size_
t
KERNEL_WIDTH
,
ActivationFunction_T
ACTIVATION
,
// Memory mapping: inputs
in
t
INPUT_MEM_CONT_OFFSET
,
in
t
INPUT_MEM_CONT_SIZE
,
in
t
INPUT_MEM_WRAP_OFFSET
,
in
t
INPUT_MEM_WRAP_SIZE
,
in
t
INPUT_MEM_STRIDE
,
size_
t
INPUT_MEM_CONT_OFFSET
,
size_
t
INPUT_MEM_CONT_SIZE
,
size_
t
INPUT_MEM_WRAP_OFFSET
,
size_
t
INPUT_MEM_WRAP_SIZE
,
size_
t
INPUT_MEM_STRIDE
,
// Memory mapping: outputs
in
t
OUTPUT_MEM_CONT_OFFSET
,
in
t
OUTPUT_MEM_CONT_SIZE
,
in
t
OUTPUT_MEM_WRAP_OFFSET
,
in
t
OUTPUT_MEM_WRAP_SIZE
,
in
t
OUTPUT_MEM_STRIDE
,
size_
t
OUTPUT_MEM_CONT_OFFSET
,
size_
t
OUTPUT_MEM_CONT_SIZE
,
size_
t
OUTPUT_MEM_WRAP_OFFSET
,
size_
t
OUTPUT_MEM_WRAP_SIZE
,
size_
t
OUTPUT_MEM_STRIDE
,
typename
Input_T
,
typename
Output_T
,
typename
Weight_T
,
typename
Bias_T
,
typename
Rescaling_T
>
...
...
@@ -40,43 +40,43 @@ void convolution_forward(
const
Bias_T
*
__restrict
biases
,
const
Rescaling_T
&
__restrict
rescaling
)
{
constexpr
in
t
DILATED_KERNEL_HEIGHT
constexpr
size_
t
DILATED_KERNEL_HEIGHT
=
KERNEL_HEIGHT
+
(
DILATION_Y
-
1
)
*
(
KERNEL_HEIGHT
-
1
);
constexpr
in
t
DILATED_KERNEL_WIDTH
constexpr
size_
t
DILATED_KERNEL_WIDTH
=
KERNEL_WIDTH
+
(
DILATION_X
-
1
)
*
(
KERNEL_WIDTH
-
1
);
constexpr
in
t
OUTPUTS_HEIGHT_NOPAD
constexpr
size_
t
OUTPUTS_HEIGHT_NOPAD
=
(
CHANNELS_HEIGHT
-
DILATION_Y
*
(
KERNEL_HEIGHT
-
1
)
-
1
+
STRIDE_Y
)
/
STRIDE_Y
;
constexpr
in
t
OUTPUTS_WIDTH_NOPAD
constexpr
size_
t
OUTPUTS_WIDTH_NOPAD
=
(
CHANNELS_WIDTH
-
DILATION_X
*
(
KERNEL_WIDTH
-
1
)
-
1
+
STRIDE_X
)
/
STRIDE_X
;
for
(
in
t
oy
=
0
;
oy
<
OUTPUTS_HEIGHT
;
++
oy
)
{
const
in
t
syMin
=
(
PADDING_Y
==
0
)
?
0
for
(
size_
t
oy
=
0
;
oy
<
OUTPUTS_HEIGHT
;
++
oy
)
{
const
size_
t
syMin
=
(
PADDING_Y
==
0
)
?
0
:
max
(
PADDING_Y
-
(
oy
*
STRIDE_Y
),
0
);
const
in
t
syMax
=
(
PADDING_Y
==
0
const
size_
t
syMax
=
(
PADDING_Y
==
0
&&
OUTPUTS_HEIGHT
==
OUTPUTS_HEIGHT_NOPAD
)
?
DILATED_KERNEL_HEIGHT
:
clamp
(
CHANNELS_HEIGHT
+
PADDING_Y
-
(
oy
*
STRIDE_Y
),
0
,
DILATED_KERNEL_HEIGHT
);
const
int
iy
=
(
oy
*
STRIDE_Y
)
-
PADDING_Y
;
const
int
iy
=
static_cast
<
int
>
(
oy
*
STRIDE_Y
)
-
static_cast
<
int
>
(
PADDING_Y
)
;
#ifdef _OPENMP
#pragma omp parallel for collapse(2)
#endif
for
(
in
t
ox
=
0
;
ox
<
OUTPUTS_WIDTH
;
++
ox
)
{
for
(
in
t
output
=
0
;
output
<
NB_OUTPUTS
;
++
output
)
{
for
(
size_
t
ox
=
0
;
ox
<
OUTPUTS_WIDTH
;
++
ox
)
{
for
(
size_
t
output
=
0
;
output
<
NB_OUTPUTS
;
++
output
)
{
// moved to inner loop for collapsing -->
const
in
t
sxMin
=
(
PADDING_X
==
0
)
?
0
const
size_
t
sxMin
=
(
PADDING_X
==
0
)
?
0
:
max
(
PADDING_X
-
(
ox
*
STRIDE_X
),
0
);
const
in
t
sxMax
=
(
PADDING_X
==
0
const
size_
t
sxMax
=
(
PADDING_X
==
0
&&
OUTPUTS_WIDTH
==
OUTPUTS_WIDTH_NOPAD
)
?
DILATED_KERNEL_WIDTH
:
clamp
(
CHANNELS_WIDTH
+
PADDING_X
-
(
ox
*
STRIDE_X
),
0
,
DILATED_KERNEL_WIDTH
);
const
int
ix
=
(
ox
*
STRIDE_X
)
-
PADDING_X
;
const
int
ix
=
static_cast
<
int
>
(
ox
*
STRIDE_X
)
-
static_cast
<
int
>
(
PADDING_X
)
;
const
in
t
oPos
=
(
ox
+
OUTPUTS_WIDTH
*
oy
);
in
t
oOffset
=
(
OUTPUT_MEM_STRIDE
/
sizeof
(
Output_T
))
*
oPos
;
const
size_
t
oPos
=
(
ox
+
OUTPUTS_WIDTH
*
oy
);
size_
t
oOffset
=
(
OUTPUT_MEM_STRIDE
/
sizeof
(
Output_T
))
*
oPos
;
if
(
OUTPUT_MEM_WRAP_SIZE
>
0
&&
oOffset
>=
(
OUTPUT_MEM_CONT_SIZE
/
sizeof
(
Output_T
)))
{
oOffset
+=
(
OUTPUT_MEM_WRAP_OFFSET
-
OUTPUT_MEM_CONT_OFFSET
...
...
@@ -87,7 +87,7 @@ void convolution_forward(
// Check if the biases are defined
Bias_T
weightedSum
=
biases
?
biases
[
output
]
:
0
;
for
(
in
t
sy
=
0
;
sy
<
KERNEL_HEIGHT
;
++
sy
)
{
for
(
size_
t
sy
=
0
;
sy
<
KERNEL_HEIGHT
;
++
sy
)
{
if
((
PADDING_Y
!=
0
||
OUTPUTS_HEIGHT
!=
OUTPUTS_HEIGHT_NOPAD
)
&&
((
sy
*
DILATION_Y
<
syMin
)
||
(
sy
*
DILATION_Y
>=
syMax
)))
...
...
@@ -95,9 +95,9 @@ void convolution_forward(
continue
;
}
const
in
t
iPos
=
((
sxMin
+
ix
)
+
CHANNELS_WIDTH
*
(
iy
+
syMin
+
sy
*
DILATION_Y
));
in
t
iOffset
=
(
INPUT_MEM_STRIDE
/
sizeof
(
Input_T
))
*
iPos
;
const
size_
t
iPos
=
(
static_cast
<
size_t
>
(
sxMin
+
ix
)
+
CHANNELS_WIDTH
*
(
static_cast
<
size_t
>
(
iy
+
syMin
)
+
sy
*
DILATION_Y
));
size_
t
iOffset
=
(
INPUT_MEM_STRIDE
/
sizeof
(
Input_T
))
*
iPos
;
// Wrapping cannot occur in the middle of a line, except if
// there is only one line (1D)!
...
...
@@ -117,7 +117,7 @@ void convolution_forward(
wrapInRange
=
true
;
}
const
in
t
wOffset
=
NB_CHANNELS
*
(
sxMin
const
size_
t
wOffset
=
NB_CHANNELS
*
(
sxMin
+
KERNEL_WIDTH
*
(
syMin
+
sy
+
KERNEL_HEIGHT
*
output
));
if
(
!
wrapInRange
&&
NB_CHANNELS
==
(
INPUT_MEM_STRIDE
/
sizeof
(
Input_T
))
...
...
@@ -130,7 +130,7 @@ void convolution_forward(
weightedSum
);
}
else
{
for
(
in
t
sx
=
0
;
sx
<
KERNEL_WIDTH
;
++
sx
)
{
for
(
size_
t
sx
=
0
;
sx
<
KERNEL_WIDTH
;
++
sx
)
{
if
((
PADDING_X
!=
0
||
OUTPUTS_WIDTH
!=
OUTPUTS_WIDTH_NOPAD
)
&&
((
sx
*
DILATION_X
<
sxMin
)
||
(
sx
*
DILATION_X
>=
sxMax
)))
...
...
@@ -138,7 +138,7 @@ void convolution_forward(
continue
;
}
in
t
iOffsetInRange
=
iOffset
size_
t
iOffsetInRange
=
iOffset
+
sx
*
DILATION_X
*
(
INPUT_MEM_STRIDE
/
sizeof
(
Input_T
));
if
(
wrapInRange
...
...
@@ -164,28 +164,28 @@ void convolution_forward(
}
}
// Template
specialization
when biases are not given to the convolution
template
<
in
t
NB_CHANNELS
,
in
t
CHANNELS_HEIGHT
,
in
t
CHANNELS_WIDTH
,
in
t
NB_OUTPUTS
,
in
t
OUTPUTS_HEIGHT
,
in
t
OUTPUTS_WIDTH
,
in
t
PADDING_Y
,
in
t
PADDING_X
,
in
t
STRIDE_Y
,
in
t
STRIDE_X
,
in
t
DILATION_Y
,
in
t
DILATION_X
,
in
t
KERNEL_HEIGHT
,
in
t
KERNEL_WIDTH
,
// Template
overloading
when biases are not given to the convolution
template
<
size_
t
NB_CHANNELS
,
size_
t
CHANNELS_HEIGHT
,
size_
t
CHANNELS_WIDTH
,
size_
t
NB_OUTPUTS
,
size_
t
OUTPUTS_HEIGHT
,
size_
t
OUTPUTS_WIDTH
,
size_
t
PADDING_Y
,
size_
t
PADDING_X
,
size_
t
STRIDE_Y
,
size_
t
STRIDE_X
,
size_
t
DILATION_Y
,
size_
t
DILATION_X
,
size_
t
KERNEL_HEIGHT
,
size_
t
KERNEL_WIDTH
,
ActivationFunction_T
ACTIVATION
,
// Memory mapping: inputs
in
t
INPUT_MEM_CONT_OFFSET
,
in
t
INPUT_MEM_CONT_SIZE
,
in
t
INPUT_MEM_WRAP_OFFSET
,
in
t
INPUT_MEM_WRAP_SIZE
,
in
t
INPUT_MEM_STRIDE
,
size_
t
INPUT_MEM_CONT_OFFSET
,
size_
t
INPUT_MEM_CONT_SIZE
,
size_
t
INPUT_MEM_WRAP_OFFSET
,
size_
t
INPUT_MEM_WRAP_SIZE
,
size_
t
INPUT_MEM_STRIDE
,
// Memory mapping: outputs
in
t
OUTPUT_MEM_CONT_OFFSET
,
in
t
OUTPUT_MEM_CONT_SIZE
,
in
t
OUTPUT_MEM_WRAP_OFFSET
,
in
t
OUTPUT_MEM_WRAP_SIZE
,
in
t
OUTPUT_MEM_STRIDE
,
size_
t
OUTPUT_MEM_CONT_OFFSET
,
size_
t
OUTPUT_MEM_CONT_SIZE
,
size_
t
OUTPUT_MEM_WRAP_OFFSET
,
size_
t
OUTPUT_MEM_WRAP_SIZE
,
size_
t
OUTPUT_MEM_STRIDE
,
typename
Input_T
,
typename
Output_T
,
typename
Weight_T
,
typename
Rescaling_T
>
...
...
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