PhoenixHardware  0.2.0
Tools to get hardware information
Loading...
Searching...
No Matches
phoenix_template_alloc.cpp File Reference
#include <string.h>
#include "phoenix_template_alloc.h"
+ Include dependency graph for phoenix_template_alloc.cpp:

Go to the source code of this file.

Functions

void phoenix_copyShape (size_t *&destTabDim, const size_t *tabDim, size_t nbDim)
 Copy a shape of a tensor into an other.
 
void phoenix_copyShape (size_t *&destTabDim, size_t &destNbDim, 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.
 

Function Documentation

◆ phoenix_copyShape() [1/2]

void phoenix_copyShape ( size_t *& destTabDim,
const size_t * tabDim,
size_t nbDim )

Copy a shape of a tensor into an other.

Parameters
[out]destTabDim: copy of the table of the size of each dimension
tabDim: table of the size of each dimension
nbDim: number of dimensions

Definition at line 28 of file phoenix_template_alloc.cpp.

28 {
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}

Referenced by phoenix_copyShape().

+ Here is the caller graph for this function:

◆ phoenix_copyShape() [2/2]

void phoenix_copyShape ( size_t *& destTabDim,
size_t & destNbDim,
const size_t * tabDim,
size_t nbDim )

Copy a shape of a tensor into an other.

Parameters
[out]destTabDim: copy of the table of the size of each dimension
[out]destNbDim: copy of the number of dimensions
tabDim: table of the size of each dimension
nbDim: number of dimensions

Definition at line 47 of file phoenix_template_alloc.cpp.

47 {
48 destNbDim = nbDim;
49 phoenix_copyShape(destTabDim, tabDim, nbDim);
50}
void phoenix_copyShape(size_t *&destTabDim, const size_t *tabDim, size_t nbDim)
Copy a shape of a tensor into an other.

References phoenix_copyShape().

+ Here is the call graph for this function:

◆ phoenix_getFullSize()

size_t phoenix_getFullSize ( const size_t * tabDim,
size_t nbDim )

Get the fulle size of the tensor.

Parameters
tabDim: table of the dimensions of the tensor
nbDim: number of dimensions of the tensor
Returns
size of the tensor

Definition at line 15 of file phoenix_template_alloc.cpp.

15 {
16 size_t fullSize(1lu);
17 for(size_t i(0lu); i < nbDim; ++i){
18 fullSize *= tabDim[i];
19 }
20 return fullSize;
21}

Referenced by phoenix_template_alloc().

+ Here is the caller graph for this function:

◆ 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.

Parameters
tabDim1: table of the size of each dimension
nbDim1: number of dimensions
tabDim2: table of the size of each dimension
nbDim2: number of dimensions
Returns
true if the shapes are equal, false otherwise

Definition at line 59 of file phoenix_template_alloc.cpp.

59 {
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}