PhoenixHardware
0.2.0
Tools to get hardware information
Toggle main menu visibility
Loading...
Searching...
No Matches
phoenix_template_alloc.cpp
Go to the documentation of this file.
1
/***************************************
2
Auteur : Pierre Aubert
3
Mail : pierre.aubert@lapp.in2p3.fr
4
Licence : CeCILL-C
5
****************************************/
6
7
#include <string.h>
8
#include "
phoenix_template_alloc.h
"
9
11
15
size_t
phoenix_getFullSize
(
const
size_t
* tabDim,
size_t
nbDim){
16
size_t
fullSize(1lu);
17
for
(
size_t
i(0lu); i < nbDim; ++i){
18
fullSize *= tabDim[i];
19
}
20
return
fullSize;
21
}
22
24
28
void
phoenix_copyShape
(
size_t
*& destTabDim,
const
size_t
* tabDim,
size_t
nbDim){
29
if
(destTabDim != NULL){
30
delete
[] destTabDim;
31
destTabDim = NULL;
32
}
33
if
(nbDim == 0lu || tabDim == NULL){
34
destTabDim = NULL;
35
return
;
36
}
37
destTabDim =
new
size_t
[nbDim];
38
memcpy(destTabDim, tabDim, nbDim*
sizeof
(
size_t
));
39
}
40
42
47
void
phoenix_copyShape
(
size_t
*& destTabDim,
size_t
& destNbDim,
const
size_t
* tabDim,
size_t
nbDim){
48
destNbDim = nbDim;
49
phoenix_copyShape
(destTabDim, tabDim, nbDim);
50
}
51
53
59
bool
phoenix_isSameShape
(
const
size_t
* tabDim1,
size_t
nbDim1,
const
size_t
* tabDim2,
size_t
nbDim2){
60
if
(tabDim1 == NULL && tabDim2 == NULL){
return
true
;}
61
if
(nbDim1 != nbDim2 || tabDim1 == NULL || tabDim2 == NULL){
return
false
;}
62
bool
isSameSize(
true
);
63
size_t
i(0lu);
64
while
(isSameSize && i < nbDim1){
65
isSameSize = tabDim1[i] == tabDim2[i];
66
++i;
67
}
68
return
isSameSize;
69
}
70
71
phoenix_copyShape
void phoenix_copyShape(size_t *&destTabDim, const size_t *tabDim, size_t nbDim)
Copy a shape of a tensor into an other.
Definition
phoenix_template_alloc.cpp:28
phoenix_getFullSize
size_t phoenix_getFullSize(const size_t *tabDim, size_t nbDim)
Get the fulle size of the tensor.
Definition
phoenix_template_alloc.cpp:15
phoenix_isSameShape
bool phoenix_isSameShape(const size_t *tabDim1, size_t nbDim1, const size_t *tabDim2, size_t nbDim2)
Say if two shapes are the same or not.
Definition
phoenix_template_alloc.cpp:59
phoenix_template_alloc.h
src
phoenix_template_alloc.cpp
Generated by
1.17.0