Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aidge_backend_cpu
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_backend_cpu
Commits
782a87ec
Commit
782a87ec
authored
1 year ago
by
Maxence Naud
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/master' into OperatorTensor
parents
daa1d920
1b56f5d0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!22
Update operators implementation
Pipeline
#34908
failed
1 year ago
Stage: build
Stage: test
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+2
-2
2 additions, 2 deletions
.gitlab-ci.yml
include/aidge/backend/cpu/operator/ScalingImpl_forward_kernels.hpp
+59
-0
59 additions, 0 deletions
...idge/backend/cpu/operator/ScalingImpl_forward_kernels.hpp
with
61 additions
and
2 deletions
.gitlab-ci.yml
+
2
−
2
View file @
782a87ec
...
@@ -15,7 +15,7 @@ stages:
...
@@ -15,7 +15,7 @@ stages:
include
:
include
:
-
local
:
'
/.gitlab/ci/_global.gitlab-ci.yml'
-
local
:
'
/.gitlab/ci/_global.gitlab-ci.yml'
-
local
:
'
/.gitlab/ci/static_analysis.gitlab-ci.yml'
#
- local: '/.gitlab/ci/static_analysis.gitlab-ci.yml'
-
local
:
'
/.gitlab/ci/build.gitlab-ci.yml'
-
local
:
'
/.gitlab/ci/build.gitlab-ci.yml'
-
local
:
'
/.gitlab/ci/test.gitlab-ci.yml'
-
local
:
'
/.gitlab/ci/test.gitlab-ci.yml'
-
local
:
'
/.gitlab/ci/coverage.gitlab-ci.yml'
#
- local: '/.gitlab/ci/coverage.gitlab-ci.yml'
This diff is collapsed.
Click to expand it.
include/aidge/backend/cpu/operator/ScalingImpl_forward_kernels.hpp
+
59
−
0
View file @
782a87ec
...
@@ -16,7 +16,60 @@
...
@@ -16,7 +16,60 @@
#include
"aidge/backend/cpu/operator/ScalingImpl.hpp"
#include
"aidge/backend/cpu/operator/ScalingImpl.hpp"
//TODO : improve propagate, n2d2 :
/*
template<typename T>
void N2D2::floatingPointScaling_propagate(const Tensor<T>& input, Tensor<T>& output,
std::size_t batchSize, std::size_t nbChannels,
std::size_t height, std::size_t width,
bool isClipped,
const std::vector<Float_T>& clippingFactorPerChannel,
const std::vector<Float_T>& scalingFactorPerChannel,
std::size_t quantizedNbBits, bool isOutputUnsigned)
{
std::size_t index = 0;
for (std::size_t batch = 0; batch < batchSize; batch++) {
for(std::size_t ch = 0; ch < nbChannels; ch++) {
for(std::size_t y = 0; y < height; y++) {
for(std::size_t x = 0; x < width; x++) {
T res = isClipped ? Clip(input(index), clippingFactorPerChannel[ch])
: input(index);
res = Scale(res, scalingFactorPerChannel[ch]);
if(quantizedNbBits > 0) {
res = saturate(std::round(res), quantizedNbBits, isOutputUnsigned);
}
output(index) = (T) res;
index++;
}
}
}
}
}
*/
namespace
Aidge
{
namespace
Aidge
{
template
<
class
O
>
const
O
&
clamp
(
const
O
&
x
,
const
O
&
min
,
const
O
&
max
)
{
return
(
x
<
min
)
?
min
:
(
x
>
max
)
?
max
:
x
;
}
template
<
class
O
>
O
saturate
(
O
value
,
std
::
size_t
quantizedNbBits
,
bool
isOutputUnsigned
)
{
assert
(
quantizedNbBits
>
0
);
const
O
min
=
isOutputUnsigned
?
0
:
-
(
1ll
<<
(
quantizedNbBits
-
1ll
));
const
O
max
=
isOutputUnsigned
?
(
1ll
<<
quantizedNbBits
)
-
1ll
:
(
1ll
<<
(
quantizedNbBits
-
1ll
))
-
1ll
;
return
clamp
(
value
,
min
,
max
);
}
template
<
class
I
,
class
O
>
template
<
class
I
,
class
O
>
void
ScalingImpl_cpu_forward_kernel
(
const
Scaling_Op
::
Attrs
&
attrs
,
void
ScalingImpl_cpu_forward_kernel
(
const
Scaling_Op
::
Attrs
&
attrs
,
std
::
size_t
inputLenght
,
std
::
size_t
inputLenght
,
...
@@ -26,9 +79,15 @@ void ScalingImpl_cpu_forward_kernel(const Scaling_Op::Attrs& attrs,
...
@@ -26,9 +79,15 @@ void ScalingImpl_cpu_forward_kernel(const Scaling_Op::Attrs& attrs,
const
I
*
input
=
static_cast
<
const
I
*>
(
input_
);
const
I
*
input
=
static_cast
<
const
I
*>
(
input_
);
O
*
output
=
static_cast
<
O
*>
(
output_
);
O
*
output
=
static_cast
<
O
*>
(
output_
);
const
I
&
scalingFactor
=
static_cast
<
const
I
&>
(
std
::
get
<
0
>
(
attrs
));
const
I
&
scalingFactor
=
static_cast
<
const
I
&>
(
std
::
get
<
0
>
(
attrs
));
std
::
size_t
quantizedNbBits
=
static_cast
<
std
::
size_t
>
(
std
::
get
<
1
>
(
attrs
));
bool
isOutputUnsigned
=
static_cast
<
bool
>
(
std
::
get
<
2
>
(
attrs
));
for
(
std
::
size_t
i
=
0
;
i
<
inputLenght
;
++
i
)
{
for
(
std
::
size_t
i
=
0
;
i
<
inputLenght
;
++
i
)
{
output
[
i
]
=
input
[
i
]
*
scalingFactor
;
output
[
i
]
=
input
[
i
]
*
scalingFactor
;
if
(
quantizedNbBits
>
0
)
{
output
[
i
]
=
saturate
(
std
::
round
(
output
[
i
]),
quantizedNbBits
,
isOutputUnsigned
);
}
}
}
}
}
...
...
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