PhoenixHardware  0.2.0
Tools to get hardware information
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>
9
11
15size_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
28void 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
47void 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
59bool 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
void phoenix_copyShape(size_t *&destTabDim, const size_t *tabDim, size_t nbDim)
Copy a shape of a tensor into an other.
size_t phoenix_getFullSize(const size_t *tabDim, size_t nbDim)
Get the fulle size of the tensor.
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.