Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Gitlab is now running v13.10.2 - More info ->
here
<-
Open sidebar
CTA-LAPP
PHOENIX_LIBS
TensorAlloc
Commits
1c5561ba
Commit
1c5561ba
authored
Jan 16, 2021
by
Pierre Aubert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add function to reshuffle tensor in vector mode
parent
def1f070
Pipeline
#99804
failed with stages
in 4 minutes
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
1 deletion
+111
-1
TESTS/CMakeLists.txt
TESTS/CMakeLists.txt
+1
-0
src/PTensor.h
src/PTensor.h
+1
-1
src/reshuffle_tensor.h
src/reshuffle_tensor.h
+26
-0
src/reshuffle_tensor_impl.h
src/reshuffle_tensor_impl.h
+83
-0
No files found.
TESTS/CMakeLists.txt
View file @
1c5561ba
...
...
@@ -6,4 +6,5 @@ add_subdirectory(TEST_TENSOR_SIZE)
add_subdirectory
(
TEST_TENSOR_MESSAGE
)
add_subdirectory
(
TEST_TENSOR_FILE
)
add_subdirectory
(
TEST_TENSOR_COPY_POINTER
)
add_subdirectory
(
TEST_TENSOR_RESHUFFLE
)
src/PTensor.h
View file @
1c5561ba
...
...
@@ -10,7 +10,7 @@
#include <stdio.h>
#include "data_all.h"
#include "template_alloc.h"
#include "reshuffle_tensor.h"
///@brief Deal with general tensor, allocation and other stuff
template
<
typename
T
>
...
...
src/reshuffle_tensor.h
0 → 100644
View file @
1c5561ba
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#ifndef __RESHUFFLE_TENSOR_H__
#define __RESHUFFLE_TENSOR_H__
#include <iostream>
template
<
typename
T
>
void
reshuffle_row_toVecNeighbour
(
T
*
rowVecNeighbour
,
size_t
paddingVec
,
const
T
*
rowScalNeighbour
,
size_t
nbCol
,
size_t
vectorSize
);
template
<
typename
T
>
void
reshuffle_row_toScalNeighbour
(
T
*
rowScalNeighbour
,
const
T
*
rowVecNeighbour
,
size_t
paddingVec
,
size_t
nbCol
,
size_t
vectorSize
);
template
<
typename
T
>
void
reshuffle_tensor_toVecNeighbour
(
T
*
tensorVecNeighbour
,
size_t
paddingVec
,
const
T
*
tensorScalNeighbour
,
size_t
paddingScal
,
size_t
nbRow
,
size_t
nbCol
,
size_t
vectorSize
);
template
<
typename
T
>
void
reshuffle_tensor_toScalNeighbour
(
T
*
tensorScalNeighbour
,
size_t
paddingScal
,
const
T
*
tensorVecNeighbour
,
size_t
paddingVec
,
size_t
nbRow
,
size_t
nbCol
,
size_t
vectorSize
);
#include "reshuffle_tensor_impl.h"
#endif
src/reshuffle_tensor_impl.h
0 → 100644
View file @
1c5561ba
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
#ifndef __RESHUFFLE_TENSOR_IMPL_H__
#define __RESHUFFLE_TENSOR_IMPL_H__
#include "reshuffle_tensor.h"
///Convert a row of a tensor with neigbhour in the given register size
/** @param[out] rowVecNeighbour : pointer to the reordered row
* @param paddingVec : padding of the vectorial row
* @param rowScalNeighbour : pointer to the row to be reoganised
* @param nbCol : number of column of the row
* @param vectorSize : number of element in the vectorial register (to make vectorial register usable as element)
*/
template
<
typename
T
>
void
reshuffle_row_toVecNeighbour
(
T
*
rowVecNeighbour
,
size_t
paddingVec
,
const
T
*
rowScalNeighbour
,
size_t
nbCol
,
size_t
vectorSize
){
size_t
rowSizeVec
(
nbCol
+
paddingVec
);
for
(
size_t
i
(
0lu
);
i
<
nbCol
;
++
i
){
T
value
(
rowScalNeighbour
[
i
]);
size_t
shift
(
i
*
vectorSize
/
rowSizeVec
);
size_t
vecIndex
((
i
*
vectorSize
+
shift
)
%
rowSizeVec
);
rowVecNeighbour
[
vecIndex
]
=
value
;
}
}
///Convert a row of a reshuffled tensor with neigbhour back with scalar neigbhours
/** @param[out] rowScalNeighbour : pointer to the reordered row
* @param rowVecNeighbour : pointer to the row to be reoganised
* @param paddingVec : padding of the vectorial row
* @param nbCol : number of column of the row
* @param vectorSize : number of element in the vectorial register (to make vectorial register usable as element)
*/
template
<
typename
T
>
void
reshuffle_row_toScalNeighbour
(
T
*
rowScalNeighbour
,
const
T
*
rowVecNeighbour
,
size_t
paddingVec
,
size_t
nbCol
,
size_t
vectorSize
){
size_t
rowSizeVec
(
nbCol
+
paddingVec
);
for
(
size_t
i
(
0lu
);
i
<
nbCol
;
++
i
){
size_t
shift
(
i
*
vectorSize
/
rowSizeVec
);
size_t
vecIndex
((
i
*
vectorSize
+
shift
)
%
rowSizeVec
);
T
value
(
rowVecNeighbour
[
vecIndex
]);
rowScalNeighbour
[
i
]
=
value
;
}
}
///Convert a tensor with scalar neigbhours (sa a classical tensor) in tensor with vectorial neigbhours with the given register size
/** @param[out] tensorVecNeighbour : pointer to the reordered tensor
* @param paddingVec : padding of the vectorial tensor
* @param tensorScalNeighbour : pointer to the row to be reoganised
* @param paddingScal : padding of the scalar tensor
* @param nbRow : number of rows of the tensor
* @param nbCol : number of column of the tensor
* @param vectorSize : number of element in the vectorial register (to make vectorial register usable as element)
*/
template
<
typename
T
>
void
reshuffle_tensor_toVecNeighbour
(
T
*
tensorVecNeighbour
,
size_t
paddingVec
,
const
T
*
tensorScalNeighbour
,
size_t
paddingScal
,
size_t
nbRow
,
size_t
nbCol
,
size_t
vectorSize
){
size_t
rowSizeScal
(
nbCol
+
paddingScal
),
rowSizeVec
(
nbCol
+
paddingVec
);
for
(
size_t
i
(
0lu
);
i
<
nbRow
;
++
i
){
reshuffle_row_toVecNeighbour
(
tensorVecNeighbour
+
i
*
rowSizeVec
,
paddingVec
,
tensorScalNeighbour
+
i
*
rowSizeScal
,
nbCol
,
vectorSize
);
}
}
///Convert a reshuffled tensor with neigbhour back with scalar neigbhours
/** @param[out] tensorScalNeighbour : pointer to the reordered tensor
* @param paddingScal : padding of the scalar tensor
* @param tensorVecNeighbour : pointer to the tensor to be reoganised
* @param paddingVec : padding of the vectorial tensor
* @param nbRow : number of rows of the tensor
* @param nbCol : number of column of the tensor
* @param vectorSize : number of element in the vectorial register (to make vectorial register usable as element)
*/
template
<
typename
T
>
void
reshuffle_tensor_toScalNeighbour
(
T
*
tensorScalNeighbour
,
size_t
paddingScal
,
const
T
*
tensorVecNeighbour
,
size_t
paddingVec
,
size_t
nbRow
,
size_t
nbCol
,
size_t
vectorSize
){
size_t
rowSizeScal
(
nbCol
+
paddingScal
),
rowSizeVec
(
nbCol
+
paddingVec
);
for
(
size_t
i
(
0lu
);
i
<
nbRow
;
++
i
){
reshuffle_row_toScalNeighbour
(
tensorScalNeighbour
+
i
*
rowSizeScal
,
tensorVecNeighbour
+
i
*
rowSizeVec
,
paddingVec
,
nbCol
,
vectorSize
);
}
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment