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
5efaf89d
Commit
5efaf89d
authored
1 year ago
by
laurent soulier
Browse files
Options
Downloads
Patches
Plain Diff
[WIP] working on extraction
parent
32d4e3b2
No related branches found
No related tags found
1 merge request
!9
Refactoring Tensor
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/aidge/backend/cpu/data/TensorImpl.hpp
+23
-0
23 additions, 0 deletions
include/aidge/backend/cpu/data/TensorImpl.hpp
unit_tests/data/Test_TensorImpl.cpp
+23
-0
23 additions, 0 deletions
unit_tests/data/Test_TensorImpl.cpp
with
46 additions
and
0 deletions
include/aidge/backend/cpu/data/TensorImpl.hpp
+
23
−
0
View file @
5efaf89d
...
@@ -104,6 +104,29 @@ public:
...
@@ -104,6 +104,29 @@ public:
return
detail
::
pimpl
::
ImplPtr_t
(
ptr
);
return
detail
::
pimpl
::
ImplPtr_t
(
ptr
);
}
}
/// @brief Creates a new TensorImpl with same properties as self but restricted to a
/// given area
/// @param i_FirstDataCoordinates Logical coordinates of the data at null natural
/// coordinates
/// @param i_Dimensions Tensor dimensions
/// @details Copy all characteristics of calling TensorImpl and its data (deep copy),
/// restricting data to the given area.
/// @return Pointer to an extract of the TensorImpl object
detail
::
pimpl
::
ImplPtr_t
Extract
(
std
::
vector
<
Coord_t
>
const
&
i_FirstDataCoordinates
,
std
::
vector
<
DimSize_t
>
const
&
i_Dimensions
)
const
override
{
auto
ptr
=
new
TensorImpl_cpu
<
T
>
(
getDataType
(),
getFirstDataCoordinates
(),
getDimensions
());
if
(
ptr
)
{
ptr
->
cloneProperties
(
*
this
);
NbElts_t
n
=
getNbElts
();
ptr
->
copyFromHost
(
getDataAddress
(),
n
);
}
return
detail
::
pimpl
::
ImplPtr_t
(
ptr
);
}
Byte_t
*
rawPtr
()
override
Byte_t
*
rawPtr
()
override
{
{
lazyInit
();
lazyInit
();
...
...
This diff is collapsed.
Click to expand it.
unit_tests/data/Test_TensorImpl.cpp
+
23
−
0
View file @
5efaf89d
...
@@ -207,4 +207,27 @@ TEST_CASE("Tensor extract")
...
@@ -207,4 +207,27 @@ TEST_CASE("Tensor extract")
}
}
}
}
}
}
SECTION
(
"deep extract"
)
{
Tensor
Rainbow
;
Rainbow
.
resize
({
2
,
4
,
5
});
Rainbow
.
setDatatype
(
DataType
::
UInt16
);
Rainbow
.
setBackend
(
"cpu"
);
MakeRainbow
<
std
::
uint16_t
>
(
Rainbow
);
Tensor
extract
(
Rainbow
,
{
2
,
2
,
3
},
{
0
,
1
,
1
},
false
);
/// @todo REQUIRE to be added
// REQUIRE impl size is same as extract
for
(
Coord_t
a
=
0
;
a
<
extract
.
dims
()[
0
];
++
a
)
{
for
(
Coord_t
b
=
0
;
b
<
extract
.
dims
()[
1
];
++
b
)
{
for
(
Coord_t
c
=
0
;
c
<
extract
.
dims
()[
2
];
++
c
)
{
REQUIRE
(
extract
.
get
<
std
::
uint16_t
>
({
a
,
b
+
1
,
c
+
1
})
==
Rainbow
.
get
<
std
::
uint16_t
>
({
a
,
b
+
1
,
c
+
1
}));
}
}
}
}
}
}
\ 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