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
09630717
Commit
09630717
authored
1 year ago
by
Houssem ROUIS
Browse files
Options
Downloads
Patches
Plain Diff
minor cleanups
parent
05ca4275
No related branches found
No related tags found
2 merge requests
!50
version 0.2.0
,
!30
add broadcasting for Arithmetic operators
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/aidge/backend/cpu/data/Broadcasting.hpp
+25
-6
25 additions, 6 deletions
include/aidge/backend/cpu/data/Broadcasting.hpp
src/data/Broadcasting.cpp
+2
-2
2 additions, 2 deletions
src/data/Broadcasting.cpp
with
27 additions
and
8 deletions
include/aidge/backend/cpu/data/Broadcasting.hpp
+
25
−
6
View file @
09630717
...
...
@@ -17,13 +17,32 @@
namespace
Aidge
{
// Function to broadCast an input dims vector into the same size as an outputDims vector
std
::
vector
<
std
::
size_t
>
getBroadcastedDims
(
const
std
::
vector
<
std
::
size_t
>&
outputDims
,
const
std
::
vector
<
std
::
size_t
>&
dimsToBroadcast
);
// Function to get multi-dimensional indices from a flattened index
std
::
vector
<
std
::
size_t
>
getMultiDimIndices
(
const
std
::
vector
<
std
::
size_t
>&
dimensions
,
std
::
size_t
idx
);
// Function to get a flattened index from multi-dimensional indices
std
::
size_t
getFlattenedIndex
(
const
std
::
vector
<
std
::
size_t
>&
dimensions
,
const
std
::
vector
<
std
::
size_t
>&
indices
);
/**
* @brief Broadcast an input dims vector into the same size as an outputDims vector
* @details The missing dimensions would be completed by 1
* @param outputDims The vector of dimensions to follow
* @param dimsToBroadcast The vecotr of dimensions to braodcast
* @return std::vector<std::size_t> a broadcasted vector by addding 1 on the missing dimensions.
*/
std
::
vector
<
std
::
size_t
>
getBroadcastedDims
(
const
std
::
vector
<
std
::
size_t
>&
outputDims
,
const
std
::
vector
<
std
::
size_t
>&
dimsToBroadcast
);
/**
* @brief Get a vector of indexes along the dimensions vector from a flattened index
* @param dimensions The vector of dimensions we want the indexes on
* @param idx The flattened index
* @return std::vector<std::size_t> vector of indexes along dimensions.
*/
std
::
vector
<
std
::
size_t
>
getMultiDimIndices
(
const
std
::
vector
<
std
::
size_t
>&
dimensions
,
std
::
size_t
idx
);
// Function to get a flattened index from multi-dimensional indices
/**
* @brief Get a flattened index the dimensions vector from a given vector of indices on a broadcasted vector
* @param dimensions The vector of dimensions we want the flattened index on
* @param indices The vector of indices we want to flatten
* @return std::size_t The flattened index on the dimensions vector
*/
std
::
size_t
getFlattenedIndex
(
const
std
::
vector
<
std
::
size_t
>&
dimensions
,
const
std
::
vector
<
std
::
size_t
>&
indices
);
}
// namespace Aidge
...
...
This diff is collapsed.
Click to expand it.
src/data/Broadcasting.cpp
+
2
−
2
View file @
09630717
...
...
@@ -13,7 +13,7 @@
std
::
vector
<
std
::
size_t
>
Aidge
::
getBroadcastedDims
(
const
std
::
vector
<
std
::
size_t
>&
outputDims
,
const
std
::
vector
<
std
::
size_t
>&
dimsToBroadcast
){
std
::
vector
<
std
::
size_t
>
broadcastedDims
(
outputDims
.
size
(),
1
);
for
(
std
::
size_
t
j
=
dimsToBroadcast
.
size
()
-
1
;
j
+
1
>
0
;
--
j
)
for
(
in
t
j
=
dimsToBroadcast
.
size
()
-
1
;
j
>
=
0
;
--
j
)
{
std
::
size_t
idx
=
outputDims
.
size
()
-
(
dimsToBroadcast
.
size
()
-
j
);
broadcastedDims
[
idx
]
=
dimsToBroadcast
[
j
];
...
...
@@ -21,7 +21,7 @@ std::vector<std::size_t> Aidge::getBroadcastedDims(const std::vector<std::size_t
return
broadcastedDims
;
}
std
::
vector
<
std
::
size_t
>
Aidge
::
getMultiDimIndices
(
const
std
::
vector
<
size_t
>&
dimensions
,
std
::
size_t
idx
){
std
::
vector
<
std
::
size_t
>
Aidge
::
getMultiDimIndices
(
const
std
::
vector
<
std
::
size_t
>&
dimensions
,
std
::
size_t
idx
){
std
::
vector
<
std
::
size_t
>
indices
(
dimensions
.
size
(),
0
);
for
(
int
i
=
dimensions
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
...
...
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