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
22c7690e
Commit
22c7690e
authored
1 year ago
by
Olivier BICHLER
Browse files
Options
Downloads
Patches
Plain Diff
Minor changes (float16 precision was insufficient for test)
parent
cbc6472f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!29
Temporary master branch
,
!26
Draft: Add Convert operator (a.k.a. Transmitter)
Pipeline
#35563
failed
1 year ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/aidge/backend/cpu/data/TensorImpl.hpp
+3
-0
3 additions, 0 deletions
include/aidge/backend/cpu/data/TensorImpl.hpp
unit_tests/scheduler/Test_Convert.cpp
+9
-2
9 additions, 2 deletions
unit_tests/scheduler/Test_Convert.cpp
with
12 additions
and
2 deletions
include/aidge/backend/cpu/data/TensorImpl.hpp
+
3
−
0
View file @
22c7690e
...
...
@@ -51,6 +51,7 @@ class TensorImpl_cpu : public TensorImpl {
}
void
copy
(
const
void
*
src
,
NbElts_t
length
)
override
{
AIDGE_ASSERT
(
length
<=
mData
.
size
()
||
length
<=
mTensor
.
size
(),
"copy length is above capacity"
);
std
::
copy
(
static_cast
<
const
T
*>
(
src
),
static_cast
<
const
T
*>
(
src
)
+
length
,
static_cast
<
T
*>
(
rawPtr
()));
}
...
...
@@ -60,6 +61,7 @@ class TensorImpl_cpu : public TensorImpl {
return
;
}
AIDGE_ASSERT
(
length
<=
mData
.
size
()
||
length
<=
mTensor
.
size
(),
"copy length is above capacity"
);
if
(
srcDt
==
DataType
::
Float64
)
{
std
::
copy
(
static_cast
<
const
double
*>
(
src
),
static_cast
<
const
double
*>
(
src
)
+
length
,
static_cast
<
T
*>
(
rawPtr
()));
...
...
@@ -120,6 +122,7 @@ class TensorImpl_cpu : public TensorImpl {
}
void
copyToHost
(
void
*
dst
,
NbElts_t
length
)
const
override
{
AIDGE_ASSERT
(
length
<=
mData
.
size
()
||
length
<=
mTensor
.
size
(),
"copy length is above capacity"
);
const
T
*
src
=
static_cast
<
const
T
*>
(
rawPtr
());
std
::
copy
(
static_cast
<
const
T
*>
(
src
),
static_cast
<
const
T
*>
(
src
)
+
length
,
static_cast
<
T
*>
(
dst
));
...
...
This diff is collapsed.
Click to expand it.
unit_tests/scheduler/Test_Convert.cpp
+
9
−
2
View file @
22c7690e
...
...
@@ -140,6 +140,13 @@ TEST_CASE("[cpu/convert] Convert(forward)") {
REQUIRE
(
approxEq
<
int
>
(
*
other4
,
expectedOutput4
,
0.0
,
1.0e-12
));
}
SECTION
(
"Half"
)
{
Tensor
refTensor
=
Array2D
<
float
,
3
,
2
>
{{{
0.0
,
1.0
},{
2.1
,
3.4
},{
5000.0
,
1.0e5
}}};
Tensor
tensor
(
DataType
::
Float16
);
tensor
.
copyCastFrom
(
refTensor
);
REQUIRE
(
approxEq
<
float
,
half_float
::
half
>
(
refTensor
,
tensor
,
1.0e-3
,
0.0
));
}
SECTION
(
"Test explicit"
)
{
std
::
shared_ptr
<
GraphView
>
g
=
Sequential
({
...
...
@@ -188,7 +195,7 @@ TEST_CASE("[cpu/convert] Convert(forward)") {
// input->addChild(g);
g
->
setDataType
(
Aidge
::
DataType
::
Int32
);
g
->
getNode
(
"conv1"
)
->
getOperator
()
->
setDataType
(
DataType
::
Float32
);
g
->
getNode
(
"conv3"
)
->
getOperator
()
->
setDataType
(
DataType
::
Float
1
6
);
g
->
getNode
(
"conv3"
)
->
getOperator
()
->
setDataType
(
DataType
::
Float6
4
);
explicitConvert
(
g
);
g
->
setBackend
(
"cpu"
);
...
...
@@ -232,7 +239,7 @@ TEST_CASE("[cpu/convert] Convert(forward)") {
std
::
shared_ptr
<
Tensor
>
other2
=
std
::
static_pointer_cast
<
OperatorTensor
>
(
g
->
getNode
(
"conv2"
)
->
getOperator
())
->
getOutput
(
0
);
REQUIRE
(
approxEq
<
int
>
(
*
other2
,
*
expectedOutput2
,
0.0
,
1.0e-12
));
std
::
shared_ptr
<
Tensor
>
other3
=
std
::
static_pointer_cast
<
OperatorTensor
>
(
g
->
getNode
(
"conv3"
)
->
getOperator
())
->
getOutput
(
0
);
REQUIRE
(
approxEq
<
half_float
::
half
,
int
>
(
*
other3
,
*
expectedOutput3
,
0.0
,
1.0e-12
));
REQUIRE
(
approxEq
<
double
,
int
>
(
*
other3
,
*
expectedOutput3
,
0.0
,
1.0e-12
));
std
::
shared_ptr
<
Tensor
>
other4
=
std
::
static_pointer_cast
<
OperatorTensor
>
(
g
->
getNode
(
"fc"
)
->
getOperator
())
->
getOutput
(
0
);
REQUIRE
(
approxEq
<
int
>
(
*
other4
,
expectedOutput4
,
0.0
,
1.0e-12
));
}
...
...
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