add print and sprint tensor and split dim end tensor
This commit is contained in:
@@ -121,6 +121,30 @@ dimension* sub_dim_tail(dimension *root, size_t subdim){
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void split_dim_part(dimension *root, dimension **part_1, dimension **part_2, size_t sz_nb_minus_part ) */
|
||||||
|
void split_dim_part(dimension *root, dimension **part_1, dimension **part_2, size_t pivotSplit, size_t rangeInPivot ) {
|
||||||
|
if(pivotSplit < root->size){
|
||||||
|
if(rangeInPivot < root->perm[pivotSplit]){
|
||||||
|
//size_t sz_part1= (root->rank * sz_nb_minus_part)/(root->perm[(root->size)-1]);
|
||||||
|
//printf("sz_part1 :%ld \n",sz_part1);
|
||||||
|
*part_1 = init_copy_dim(root->perm, root->size);
|
||||||
|
((*part_1)->perm[pivotSplit]) -= rangeInPivot;
|
||||||
|
updateRankDim(*part_1);
|
||||||
|
/*if(sz_nb_minus_part <2)
|
||||||
|
*part_2 = init_copy_dim((root->perm), root->size-1 );
|
||||||
|
else{*/
|
||||||
|
*part_2 = init_copy_dim((root->perm), root->size );
|
||||||
|
(*part_2)->perm[pivotSplit] = rangeInPivot ;
|
||||||
|
//}
|
||||||
|
updateRankDim(*part_2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void add_dimension(dimension **d, dimension *d0, dimension *d1) {
|
void add_dimension(dimension **d, dimension *d0, dimension *d1) {
|
||||||
(*d) = create_dim(d0->size + d1->size);
|
(*d) = create_dim(d0->size + d1->size);
|
||||||
for (size_t i = 0; i < d0->size; i++) (*d)->perm[i] = d0->perm[i];
|
for (size_t i = 0; i < d0->size; i++) (*d)->perm[i] = d0->perm[i];
|
||||||
@@ -146,10 +170,13 @@ void min_dimension(dimension **d, dimension *d0, dimension *d1) {
|
|||||||
|
|
||||||
void printDebug_dimension(dimension *d,char *msg){
|
void printDebug_dimension(dimension *d,char *msg){
|
||||||
|
|
||||||
printf("%s / dim->size = %ld | dim->rank = %ld \n",msg,d->size,d->rank);
|
printf("(%s)->size = %ld | (%s)->rank = %ld \n",msg,d->size,msg,d->rank);
|
||||||
for(size_t i=0; i<d->size; ++i)
|
for(size_t i=0; i<d->size; ++i)
|
||||||
printf("[%ld: %ld] |", i,d->perm[i]);
|
printf("[%ld: %ld] |", i,d->perm[i]);
|
||||||
printf("\n");
|
if(endian)
|
||||||
|
printf("litle endian (true)\n");
|
||||||
|
else
|
||||||
|
printf("litle endian (false) \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateRankDim(dimension *dim){
|
void updateRankDim(dimension *dim){
|
||||||
|
|||||||
@@ -5,6 +5,15 @@
|
|||||||
|
|
||||||
extern bool endian;
|
extern bool endian;
|
||||||
|
|
||||||
|
|
||||||
|
bool isLessEqThan(long int a, long int b) ;
|
||||||
|
bool isLessThan(long int a, long int b) ;
|
||||||
|
bool isGreatEqThan(long int a, long int b) ;
|
||||||
|
bool isGreatThan(long int a, long int b) ;
|
||||||
|
long int incr(long int i) ;
|
||||||
|
long int decr(long int i) ;
|
||||||
|
|
||||||
|
|
||||||
typedef struct PERMUTATION_TYPE_SIZE_T dimension ;
|
typedef struct PERMUTATION_TYPE_SIZE_T dimension ;
|
||||||
|
|
||||||
dimension * create_dim(size_t size);
|
dimension * create_dim(size_t size);
|
||||||
@@ -22,6 +31,8 @@ dimension* sub_copy_minus_dim_tail(dimension *t, size_t minusSubdim);
|
|||||||
dimension* sub_copy_dim_head(dimension *t, size_t sub_copydim);
|
dimension* sub_copy_dim_head(dimension *t, size_t sub_copydim);
|
||||||
dimension* sub_copy_dim_tail(dimension *t, size_t sub_copydim);
|
dimension* sub_copy_dim_tail(dimension *t, size_t sub_copydim);
|
||||||
|
|
||||||
|
void split_dim_part(dimension *root, dimension **part_1, dimension **part_2, size_t pivotSplit, size_t rangeInPivot );
|
||||||
|
|
||||||
void add_copy_dimension(dimension **d, dimension *d0, dimension *d1);
|
void add_copy_dimension(dimension **d, dimension *d0, dimension *d1);
|
||||||
void min_copy_dimension(dimension **d, dimension *d0, dimension *d1);
|
void min_copy_dimension(dimension **d, dimension *d0, dimension *d1);
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ TEST(dimension0){
|
|||||||
|
|
||||||
EXPECT_EQ(D->size,5);
|
EXPECT_EQ(D->size,5);
|
||||||
|
|
||||||
|
free_dimension(D);
|
||||||
}
|
}
|
||||||
TEST(rank){
|
TEST(rank){
|
||||||
dimension *D=create_dim(4);
|
dimension *D=create_dim(4);
|
||||||
@@ -33,7 +34,71 @@ TEST(rank){
|
|||||||
updateRankDim(D);
|
updateRankDim(D);
|
||||||
EXPECT_EQ(D->rank, 180);
|
EXPECT_EQ(D->rank, 180);
|
||||||
|
|
||||||
|
free_dimension(D);
|
||||||
}
|
}
|
||||||
|
TEST(SplitDim){
|
||||||
|
dimension *D=create_dim(4);
|
||||||
|
D->perm[0]=2;
|
||||||
|
D->perm[1]=3;
|
||||||
|
D->perm[2]=5;
|
||||||
|
D->perm[3]=6;
|
||||||
|
|
||||||
|
updateRankDim(D);
|
||||||
|
printDebug_dimension(D," D root");
|
||||||
|
|
||||||
|
dimension *d_part1 = NULL,*d_part2=NULL;
|
||||||
|
|
||||||
|
split_dim_part(D, &d_part1, &d_part2, 1, 2);
|
||||||
|
|
||||||
|
printDebug_dimension(d_part1," part1 from Root");
|
||||||
|
printDebug_dimension(d_part2," part2 from Root");
|
||||||
|
|
||||||
|
dimension *ad;
|
||||||
|
|
||||||
|
add_dimension(&ad,d_part1, d_part2);
|
||||||
|
printDebug_dimension(D," D root");
|
||||||
|
printDebug_dimension(ad," ad ");
|
||||||
|
|
||||||
|
|
||||||
|
free_dimension(D);
|
||||||
|
free_dimension(ad);
|
||||||
|
free(d_part1);
|
||||||
|
free(d_part2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SplitDim_2){
|
||||||
|
dimension *D=create_dim(4);
|
||||||
|
D->perm[0]=2;
|
||||||
|
D->perm[1]=3;
|
||||||
|
D->perm[2]=5;
|
||||||
|
D->perm[3]=6;
|
||||||
|
|
||||||
|
updateRankDim(D);
|
||||||
|
printDebug_dimension(D," D root");
|
||||||
|
|
||||||
|
dimension *d_part1 = NULL,*d_part2=NULL;
|
||||||
|
|
||||||
|
split_dim_part(D, &d_part1, &d_part2, 3, 2);
|
||||||
|
|
||||||
|
printDebug_dimension(d_part1," part1 from Root");
|
||||||
|
printDebug_dimension(d_part2," part2 from Root");
|
||||||
|
|
||||||
|
dimension *ad;
|
||||||
|
|
||||||
|
add_dimension(&ad,d_part1, d_part2);
|
||||||
|
printDebug_dimension(D," D root");
|
||||||
|
printDebug_dimension(ad," ad ");
|
||||||
|
|
||||||
|
|
||||||
|
free_dimension(D);
|
||||||
|
free_dimension(ad);
|
||||||
|
free(d_part1);
|
||||||
|
free(d_part2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST(SubDim){
|
TEST(SubDim){
|
||||||
dimension *D=create_dim(4);
|
dimension *D=create_dim(4);
|
||||||
D->perm[0]=2;
|
D->perm[0]=2;
|
||||||
@@ -49,6 +114,9 @@ TEST(SubDim){
|
|||||||
dimension *d_tail2 = sub_minus_dim_tail(D,2);
|
dimension *d_tail2 = sub_minus_dim_tail(D,2);
|
||||||
EXPECT_EQ(d_tail2->rank, 5*6);
|
EXPECT_EQ(d_tail2->rank, 5*6);
|
||||||
|
|
||||||
|
free_dimension(D);
|
||||||
|
free(d_tail2);
|
||||||
|
free(d_head2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(SubDim){
|
TEST(SubDim){
|
||||||
@@ -67,6 +135,9 @@ TEST(SubDim){
|
|||||||
dimension *d_tail2 = sub_minus_dim_tail(D,2);
|
dimension *d_tail2 = sub_minus_dim_tail(D,2);
|
||||||
EXPECT_EQ(d_tail2->rank, 5*6);
|
EXPECT_EQ(d_tail2->rank, 5*6);
|
||||||
|
|
||||||
|
free_dimension(D);
|
||||||
|
free(d_tail2);
|
||||||
|
free(d_head2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Coord_linear){
|
TEST(Coord_linear){
|
||||||
@@ -86,6 +157,8 @@ TEST(Coord_linear){
|
|||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_EQ(line, LineFromCoord(coord, D));
|
EXPECT_EQ(line, LineFromCoord(coord, D));
|
||||||
|
free_dimension(D);
|
||||||
|
free(coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv){
|
int main(int argc, char **argv){
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
#ifndef __NEURON_T_C__H
|
|
||||||
#define __NEURON_T_C__H
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "tools_t/tools_t.h"
|
|
||||||
#include "permutation_t/permutation_t.h"
|
|
||||||
|
|
||||||
typedef PERMUTATION_TYPE_FLOAT vectf;
|
|
||||||
|
|
||||||
struct neuron {
|
|
||||||
size_t id;
|
|
||||||
struct vectf *x; /* input */
|
|
||||||
struct vectf *w_in; /* weight link in */
|
|
||||||
struct vectf *w_out; /* weight link out */
|
|
||||||
struct vectf *d; /* delta */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct func {
|
|
||||||
float (*func_act)(struct neuron *nr); /* function activation */
|
|
||||||
float (*d_func_act)(struct neuron *nr); /* derivate func act */
|
|
||||||
float (*func_agreg)(struct neuron *nr); /* function aggregation */
|
|
||||||
};
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
#define GENERATE_NEURON(type) \
|
|
||||||
struct NEURON_##type{ \
|
|
||||||
type *x; \
|
|
||||||
type *w; \
|
|
||||||
}; \
|
|
||||||
typedef struct NEURON_##type NEURON_##type; \
|
|
||||||
NEURON_##type * CREATE_NEURON_##type(size_t id/*TYPE_##type*/); \
|
|
||||||
bool IS_NEURON_##type(NEURON_##type *st); \
|
|
||||||
|
|
||||||
GENERATE_NEURON(TYPE_FLOAT)
|
|
||||||
GENERATE_NEURON(TYPE_DOUBLE)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*__NEURON_T_C__H*/
|
|
||||||
@@ -23,6 +23,14 @@ void printArraySzt(size_t *a, size_t sz,char *msg){
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
bool isLessEqThan(long int a, long int b) { return a <= b; }
|
||||||
|
bool isLessThan(long int a, long int b) { return a < b; }
|
||||||
|
bool isGreatEqThan(long int a, long int b) { return a >= b; }
|
||||||
|
bool isGreatThan(long int a, long int b) { return a > b; }
|
||||||
|
long int incr(long int i) { return i + 1; }
|
||||||
|
long int decr(long int i) { return i - 1; }
|
||||||
|
*/
|
||||||
|
|
||||||
#define FREE_COORD_\
|
#define FREE_COORD_\
|
||||||
free(coord0);\
|
free(coord0);\
|
||||||
@@ -52,6 +60,45 @@ void printArraySzt(size_t *a, size_t sz,char *msg){
|
|||||||
r_tens->x = malloc(sizeof(type)*dim->rank);\
|
r_tens->x = malloc(sizeof(type)*dim->rank);\
|
||||||
return r_tens;\
|
return r_tens;\
|
||||||
}\
|
}\
|
||||||
|
\
|
||||||
|
tensor_##type* init_tensor_head_##type(tensor_##type *troot ,dimension *dim){\
|
||||||
|
tensor_##type *r_tens=malloc(sizeof(tensor_##type));\
|
||||||
|
updateRankDim(dim);\
|
||||||
|
r_tens->dim = dim;\
|
||||||
|
r_tens->x = troot->x;\
|
||||||
|
return r_tens;\
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
tensor_##type* init_tensor_tail_##type(tensor_##type *troot ,dimension *dim){\
|
||||||
|
tensor_##type *r_tens=malloc(sizeof(tensor_##type));\
|
||||||
|
updateRankDim(dim);\
|
||||||
|
r_tens->dim = dim;\
|
||||||
|
r_tens->x = troot->x + ((troot->dim)->rank - dim->rank);\
|
||||||
|
return r_tens;\
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
\
|
||||||
|
tensor_##type* init_copy_tensor_head_##type(tensor_##type *troot ,dimension *dim){\
|
||||||
|
tensor_##type *r_tens=malloc(sizeof(tensor_##type));\
|
||||||
|
updateRankDim(dim);\
|
||||||
|
r_tens->dim = dim;\
|
||||||
|
/*r_tens->x = troot->x;*/\
|
||||||
|
for(size_t i=0; i<dim->rank;++i)\
|
||||||
|
r_tens->x[i]=troot->x[i];\
|
||||||
|
return r_tens;\
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
tensor_##type* init_copy_tensor_tail_##type(tensor_##type *troot ,dimension *dim){\
|
||||||
|
tensor_##type *r_tens=malloc(sizeof(tensor_##type));\
|
||||||
|
updateRankDim(dim);\
|
||||||
|
r_tens->dim = dim;\
|
||||||
|
/*r_tens->x = troot->x + ((troot->dim)->rank - dim->rank);*/\
|
||||||
|
r_tens->x = malloc(sizeof(type)*dim->rank);\
|
||||||
|
for(size_t dRank=(troot->dim)->rank - dim->rank, i=0; i<dim->rank;++i)\
|
||||||
|
r_tens->x[i]=troot->x[i+dRank];\
|
||||||
|
return r_tens;\
|
||||||
|
}\
|
||||||
|
\
|
||||||
\
|
\
|
||||||
tensor_##type* CREATE_TENSOR_FROM_CPY_DIM_##type(dimension *dim){\
|
tensor_##type* CREATE_TENSOR_FROM_CPY_DIM_##type(dimension *dim){\
|
||||||
tensor_##type *r_tens=malloc(sizeof(tensor_##type));\
|
tensor_##type *r_tens=malloc(sizeof(tensor_##type));\
|
||||||
@@ -67,7 +114,16 @@ void printArraySzt(size_t *a, size_t sz,char *msg){
|
|||||||
free(tens);\
|
free(tens);\
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
/* tensor_##type * sub_minus_tensor_head_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim){\
|
void init_random_x_##type(tensor_##type *M, type minR, type maxR, int randomRange){\
|
||||||
|
srand(time(NULL));\
|
||||||
|
int randVal;\
|
||||||
|
for(size_t i =0; i<(M->dim)->rank;++i){\
|
||||||
|
randVal = rand() % randomRange;\
|
||||||
|
M->x[i]=minR + (maxR-minR)*randVal / randomRange ;\
|
||||||
|
\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
tensor_##type * sub_minus_tensor_head_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim){\
|
||||||
dimension *rdim= rootens->dim;\
|
dimension *rdim= rootens->dim;\
|
||||||
dimension *dS_t = sub_minus_dim_tail(rdim,rdim->size - minuSubdim);\
|
dimension *dS_t = sub_minus_dim_tail(rdim,rdim->size - minuSubdim);\
|
||||||
if(rankInDim < dS_t->rank){\
|
if(rankInDim < dS_t->rank){\
|
||||||
@@ -157,7 +213,7 @@ void printArraySzt(size_t *a, size_t sz,char *msg){
|
|||||||
}\
|
}\
|
||||||
return NULL;\
|
return NULL;\
|
||||||
}\
|
}\
|
||||||
*/ \
|
\
|
||||||
tensor_##type * sub_copy_minus_tensor_head_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim){\
|
tensor_##type * sub_copy_minus_tensor_head_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim){\
|
||||||
dimension *rdim= rootens->dim;\
|
dimension *rdim= rootens->dim;\
|
||||||
dimension *dS_t = sub_copy_minus_dim_tail(rdim,rdim->size - minuSubdim);\
|
dimension *dS_t = sub_copy_minus_dim_tail(rdim,rdim->size - minuSubdim);\
|
||||||
@@ -273,6 +329,147 @@ void printArraySzt(size_t *a, size_t sz,char *msg){
|
|||||||
return NULL;\
|
return NULL;\
|
||||||
}\
|
}\
|
||||||
\
|
\
|
||||||
|
void print_tensor_msg_##type(tensor_##type *T,char *msg) {\
|
||||||
|
size_t j=0,k=0;\
|
||||||
|
long int *coord = malloc(sizeof(long int)*(T->dim)->size); \
|
||||||
|
char *val=NULL;\
|
||||||
|
char *dimsg=malloc(512);\
|
||||||
|
sprintf(dimsg,"(%s)->dim",msg);\
|
||||||
|
printDebug_dimension(T->dim,dimsg);\
|
||||||
|
printf("%s\n",msg);\
|
||||||
|
long int begin , end, beginIter, endIter ;\
|
||||||
|
long int (*iter)(long int) ;\
|
||||||
|
bool (*cond)(long int, long int) ; \
|
||||||
|
if (endian ) {\
|
||||||
|
begin = (T->dim->size) - 1; end = 0;\
|
||||||
|
iter = decr; cond = isGreatEqThan; \
|
||||||
|
}else{\
|
||||||
|
begin = 0 ; end = (T->dim->size) - 1; \
|
||||||
|
iter = incr; cond = isLessEqThan; \
|
||||||
|
}\
|
||||||
|
for(long int i=0;i<(T->dim)->rank;++i){\
|
||||||
|
vCoordFromLin(coord,i,T->dim);\
|
||||||
|
if(coord[begin]==0){\
|
||||||
|
for(long int j=begin; cond(j,end); j= iter(j) ){\
|
||||||
|
if(coord[j]==0) printf("(");\
|
||||||
|
else break;\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
printf(" [{");\
|
||||||
|
for(size_t k=0; k<(T->dim)->size;++k) printf(" %ld,",coord[k]);\
|
||||||
|
val=type##_TO_STR(T->x[i]);\
|
||||||
|
printf("}#%ld] %s, ",i,val);\
|
||||||
|
free(val); val=NULL;\
|
||||||
|
if(coord[begin]==(T->dim)->perm[begin]-1){\
|
||||||
|
for(long int j=begin; cond(j,end); j = iter(j)){\
|
||||||
|
if(coord[j]==(T->dim)->perm[j]-1) printf(")");\
|
||||||
|
else break;\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
free(coord);\
|
||||||
|
printf("\n");\
|
||||||
|
free(dimsg);\
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
size_t sprint_tensor_##type(char **tensorContent,tensor_##type *T, bool withIndex) {\
|
||||||
|
if(*tensorContent != NULL) {\
|
||||||
|
free(*tensorContent);\
|
||||||
|
*tensorContent = NULL; \
|
||||||
|
}\
|
||||||
|
size_t sz = ((T->dim)->rank)*(32+ withIndex * 5*(T->dim)->size + 9 );\
|
||||||
|
printf("malloc %ld char\n",sz);\
|
||||||
|
*tensorContent = malloc(sz ) ;\
|
||||||
|
size_t cur=0;\
|
||||||
|
long int *coord = malloc(sizeof(long int)*(T->dim)->size); \
|
||||||
|
char *val=NULL;\
|
||||||
|
long int begin , end, beginIter, endIter ;\
|
||||||
|
long int (*iter)(long int) ;\
|
||||||
|
bool (*cond)(long int, long int) ; \
|
||||||
|
if (endian ) {\
|
||||||
|
begin = (T->dim->size) - 1; end = 0;\
|
||||||
|
iter = decr; cond = isGreatEqThan; \
|
||||||
|
}else{\
|
||||||
|
begin = 0 ; end = (T->dim->size) - 1; \
|
||||||
|
iter = incr; cond = isLessEqThan; \
|
||||||
|
}\
|
||||||
|
for(long int i=0;i<(T->dim)->rank;++i){\
|
||||||
|
vCoordFromLin(coord,i,T->dim);\
|
||||||
|
if(coord[begin]==0){\
|
||||||
|
for(long int j=begin; cond(j,end); j= iter(j) ){\
|
||||||
|
if(coord[j]==0) /*printf("(")*/(*tensorContent)[cur++]='(';\
|
||||||
|
else break;\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
if(withIndex){\
|
||||||
|
(*tensorContent)[cur++]=' ';\
|
||||||
|
(*tensorContent)[cur++]='[';\
|
||||||
|
(*tensorContent)[cur++]='{';\
|
||||||
|
for(size_t k=0; k<(T->dim)->size;++k) {\
|
||||||
|
/*printf(" %ld,",coord[k]);*/\
|
||||||
|
val=TYPE_SIZE_T_TO_STR(coord[k]);\
|
||||||
|
for(size_t c=0;c<strlen(val);++c){\
|
||||||
|
(*tensorContent)[cur++]=' ';\
|
||||||
|
(*tensorContent)[cur++]=val[c];\
|
||||||
|
}\
|
||||||
|
free(val); val = NULL;\
|
||||||
|
(*tensorContent)[cur++]=',';\
|
||||||
|
}\
|
||||||
|
(*tensorContent)[cur++]='}';\
|
||||||
|
(*tensorContent)[cur++]='#';\
|
||||||
|
val=TYPE_SIZE_T_TO_STR(i);\
|
||||||
|
for(size_t c=0;c<strlen(val);++c)\
|
||||||
|
(*tensorContent)[cur++]=val[c];\
|
||||||
|
free(val); val = NULL;\
|
||||||
|
(*tensorContent)[cur++]=']';\
|
||||||
|
(*tensorContent)[cur++]=' ';\
|
||||||
|
}\
|
||||||
|
val=type##_TO_STR(T->x[i]);\
|
||||||
|
/*printf(" {%ld} %s [",i,val);*/\
|
||||||
|
(*tensorContent)[cur++]=' ';\
|
||||||
|
for(size_t c=0;c<strlen(val);++c)\
|
||||||
|
(*tensorContent)[cur++]=val[c];\
|
||||||
|
free(val); val = NULL;\
|
||||||
|
(*tensorContent)[cur++]=',';\
|
||||||
|
if(coord[begin]==(T->dim)->perm[begin]-1){\
|
||||||
|
for(long int j=begin; cond(j,end); j = iter(j)){\
|
||||||
|
if(coord[j]==(T->dim)->perm[j]-1) /*printf(")"); */ (*tensorContent)[cur++]=')';\
|
||||||
|
else break;\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
free(coord);\
|
||||||
|
/*printf("\n");*/(*tensorContent)[cur++]='\n';\
|
||||||
|
(*tensorContent)[cur++]='\0';\
|
||||||
|
return cur;\
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
\
|
||||||
|
void split_tensor_##type(tensor_##type *Troot, tensor_##type **Tpart1, tensor_##type **Tpart2, size_t pivotSplit, size_t rangeInPivot){\
|
||||||
|
size_t sz = (Troot->dim)->size;\
|
||||||
|
if(pivotSplit < sz){\
|
||||||
|
if( rangeInPivot < (Troot->dim)->perm[pivotSplit]){\
|
||||||
|
dimension *dpart1, *dpart2;\
|
||||||
|
split_dim_part(Troot->dim, &dpart1, &dpart2, pivotSplit, rangeInPivot);\
|
||||||
|
*Tpart1 = init_tensor_head_##type(Troot, dpart1);\
|
||||||
|
*Tpart2 = init_tensor_tail_##type(Troot, dpart2);\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
} \
|
||||||
|
void split_copy_tensor_##type(tensor_##type *Troot, tensor_##type **Tpart1, tensor_##type **Tpart2, size_t pivotSplit, size_t rangeInPivot){\
|
||||||
|
size_t sz = (Troot->dim)->size;\
|
||||||
|
if(pivotSplit < sz){\
|
||||||
|
if( rangeInPivot < (Troot->dim)->perm[pivotSplit]){\
|
||||||
|
dimension *dpart1, *dpart2;\
|
||||||
|
split_dim_part(Troot->dim, &dpart1, &dpart2, pivotSplit, rangeInPivot);\
|
||||||
|
*Tpart1 = init_tensor_head_##type(Troot, dpart1);\
|
||||||
|
*Tpart2 = init_tensor_tail_##type(Troot, dpart2);\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
\
|
||||||
void tensorProdNotOpt_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1) { \
|
void tensorProdNotOpt_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1) { \
|
||||||
dimension *dd; \
|
dimension *dd; \
|
||||||
add_dimension(&dd, M0->dim, M1->dim); \
|
add_dimension(&dd, M0->dim, M1->dim); \
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef __TENSOR_T__H__
|
#ifndef __TENSOR_T__H__
|
||||||
#define __TENSOR_T__H__
|
#define __TENSOR_T__H__
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "dimension_t/dimension_t.h"
|
#include "dimension_t/dimension_t.h"
|
||||||
@@ -14,15 +16,19 @@ struct tensor_##type{\
|
|||||||
};\
|
};\
|
||||||
typedef struct tensor_##type tensor_##type;\
|
typedef struct tensor_##type tensor_##type;\
|
||||||
tensor_##type * CREATE_TENSOR_##type(dimension *dim); \
|
tensor_##type * CREATE_TENSOR_##type(dimension *dim); \
|
||||||
|
tensor_##type* CREATE_TENSOR_FROM_CPY_DIM_##type(dimension *dim);\
|
||||||
void free_tensor_##type(tensor_##type * tens); \
|
void free_tensor_##type(tensor_##type * tens); \
|
||||||
/*tensor_##type * sub_minus_tensor_head_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim); \
|
tensor_##type * sub_minus_tensor_head_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim); \
|
||||||
tensor_##type * sub_minus_tensor_tail_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim); \
|
tensor_##type * sub_minus_tensor_tail_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim); \
|
||||||
tensor_##type * sub_tensor_head_##type(tensor_##type *rootens, size_t subdim, size_t rankInDim); \
|
tensor_##type * sub_tensor_head_##type(tensor_##type *rootens, size_t subdim, size_t rankInDim); \
|
||||||
tensor_##type * sub_tensor_tail_##type(tensor_##type *rootens, size_t subdim, size_t rankInDim); \
|
tensor_##type * sub_tensor_tail_##type(tensor_##type *rootens, size_t subdim, size_t rankInDim); \
|
||||||
*/tensor_##type * sub_copy_minus_tensor_head_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim); \
|
tensor_##type * sub_copy_minus_tensor_head_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim); \
|
||||||
tensor_##type * sub_copy_minus_tensor_tail_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim); \
|
tensor_##type * sub_copy_minus_tensor_tail_##type(tensor_##type *rootens, size_t minuSubdim, size_t rankInDim); \
|
||||||
tensor_##type * sub_copy_tensor_head_##type(tensor_##type *rootens, size_t sub_copydim, size_t rankInDim); \
|
tensor_##type * sub_copy_tensor_head_##type(tensor_##type *rootens, size_t sub_copydim, size_t rankInDim); \
|
||||||
tensor_##type * sub_copy_tensor_tail_##type(tensor_##type *rootens, size_t sub_copydim, size_t rankInDim); \
|
tensor_##type * sub_copy_tensor_tail_##type(tensor_##type *rootens, size_t sub_copydim, size_t rankInDim); \
|
||||||
|
void print_tensor_msg_##type(tensor_##type *T, char *msg);\
|
||||||
|
size_t sprint_tensor_##type(char **tensorContent,tensor_##type *T, bool withIndex);\
|
||||||
|
void split_tensor_##type(tensor_##type *Troot, tensor_##type **Tpart1, tensor_##type **Tpart2, size_t pivotSplit, size_t rangeInPivot);\
|
||||||
void tensorProdNotOpt_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1); \
|
void tensorProdNotOpt_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1); \
|
||||||
void tensorProd_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1); \
|
void tensorProd_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1); \
|
||||||
void tensorContractnProd_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber); \
|
void tensorContractnProd_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber); \
|
||||||
@@ -31,6 +37,7 @@ void tensorProdThrea2d_##type(tensor_##type **MM, tensor_##type *M0, tensor_##ty
|
|||||||
void tensorContractnProdThread_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber, size_t nbthread); \
|
void tensorContractnProdThread_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber, size_t nbthread); \
|
||||||
void tensorContractnPro2dThread_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber, size_t nbthread); \
|
void tensorContractnPro2dThread_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber, size_t nbthread); \
|
||||||
void tensorContractnProdNotOpt_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber); \
|
void tensorContractnProdNotOpt_##type(tensor_##type **MM, tensor_##type *M0, tensor_##type *M1, size_t contractionNumber); \
|
||||||
|
void init_random_x_##type(tensor_##type *M, type minR, type maxR, int randomRange);\
|
||||||
|
|
||||||
|
|
||||||
GENERATE_TENSOR_TYPE(TYPE_FLOAT);
|
GENERATE_TENSOR_TYPE(TYPE_FLOAT);
|
||||||
|
|||||||
+266
-4
@@ -17,7 +17,7 @@
|
|||||||
//#include "permutation_t/permutation_t.h"
|
//#include "permutation_t/permutation_t.h"
|
||||||
#include "tensor_t/tensor_t.h"
|
#include "tensor_t/tensor_t.h"
|
||||||
|
|
||||||
#define VALGRIND_ 0
|
#define VALGRIND_ 1
|
||||||
|
|
||||||
TEST(rank){
|
TEST(rank){
|
||||||
endian =true;
|
endian =true;
|
||||||
@@ -42,9 +42,10 @@ void print_tensor_float(tensor_TYPE_FLOAT *M, char *msg){
|
|||||||
LOG("================= %s ===============\n",msg);
|
LOG("================= %s ===============\n",msg);
|
||||||
|
|
||||||
#if VALGRIND_
|
#if VALGRIND_
|
||||||
for(size_t i=0; i<M->dim->rank;++i)
|
/*for(size_t i=0; i<M->dim->rank;++i)
|
||||||
LOG("[%ld]: %f ",i,M->x[i]);
|
LOG("[%ld]: %f ",i,M->x[i]);
|
||||||
|
*/
|
||||||
|
print_tensor_msg_TYPE_FLOAT(M,msg);
|
||||||
#endif
|
#endif
|
||||||
LOG("%s","\n");
|
LOG("%s","\n");
|
||||||
}
|
}
|
||||||
@@ -53,9 +54,11 @@ void print_tensor_float(tensor_TYPE_FLOAT *M, char *msg){
|
|||||||
void print_tensor_double(tensor_TYPE_DOUBLE *M, char *msg){
|
void print_tensor_double(tensor_TYPE_DOUBLE *M, char *msg){
|
||||||
LOG("================= %s ===============\n",msg);
|
LOG("================= %s ===============\n",msg);
|
||||||
#if VALGRIND_
|
#if VALGRIND_
|
||||||
|
/*
|
||||||
for(size_t i=0; i<M->dim->rank;++i)
|
for(size_t i=0; i<M->dim->rank;++i)
|
||||||
LOG("[%ld]: %lf ",i,M->x[i]);
|
LOG("[%ld]: %lf ",i,M->x[i]);
|
||||||
|
*/
|
||||||
|
print_tensor_msg_TYPE_DOUBLE(M,msg);
|
||||||
#endif
|
#endif
|
||||||
LOG("%s","\n");
|
LOG("%s","\n");
|
||||||
}
|
}
|
||||||
@@ -260,6 +263,201 @@ TEST(tensorSubtail ){
|
|||||||
free_tensor_TYPE_FLOAT(s2t);
|
free_tensor_TYPE_FLOAT(s2t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(randomInit){
|
||||||
|
dimension *d0=create_dim(3);
|
||||||
|
|
||||||
|
d0->perm[0]=4;
|
||||||
|
d0->perm[1]=3;
|
||||||
|
d0->perm[2]=5;
|
||||||
|
|
||||||
|
|
||||||
|
updateRankDim(d0);
|
||||||
|
|
||||||
|
|
||||||
|
tensor_TYPE_FLOAT *M0 = CREATE_TENSOR_TYPE_FLOAT(d0);
|
||||||
|
|
||||||
|
LOG("M0->dim->rank = %ld\n",M0->dim->rank);
|
||||||
|
|
||||||
|
init_random_x_TYPE_FLOAT(M0,2.7,5.4,50001);
|
||||||
|
|
||||||
|
print_tensor_float(M0, "M0 random");
|
||||||
|
free_tensor_TYPE_FLOAT(M0);
|
||||||
|
}
|
||||||
|
TEST(printT_init_false){
|
||||||
|
endian=false;
|
||||||
|
dimension *d0=create_dim(3);
|
||||||
|
|
||||||
|
d0->perm[0]=2;
|
||||||
|
d0->perm[1]=3;
|
||||||
|
d0->perm[2]=4;
|
||||||
|
|
||||||
|
|
||||||
|
updateRankDim(d0);
|
||||||
|
|
||||||
|
|
||||||
|
tensor_TYPE_FLOAT *M0 = CREATE_TENSOR_TYPE_FLOAT(d0);
|
||||||
|
|
||||||
|
LOG("M0->dim->rank = %ld\n",M0->dim->rank);
|
||||||
|
|
||||||
|
//init_random_x_TYPE_FLOAT(M0,2,5,50);
|
||||||
|
for(size_t i=0; i<M0->dim->rank;++i) M0->x[i]=i*0.1 +1;
|
||||||
|
|
||||||
|
|
||||||
|
// print_tensor_float(M0, "M0 ");
|
||||||
|
print_tensor_msg_TYPE_FLOAT(M0, "M0 ");
|
||||||
|
free_tensor_TYPE_FLOAT(M0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST(printT_Init_true){
|
||||||
|
endian=true;
|
||||||
|
dimension *d0=create_dim(3);
|
||||||
|
|
||||||
|
d0->perm[0]=2;
|
||||||
|
d0->perm[1]=3;
|
||||||
|
d0->perm[2]=4;
|
||||||
|
|
||||||
|
|
||||||
|
updateRankDim(d0);
|
||||||
|
|
||||||
|
|
||||||
|
tensor_TYPE_FLOAT *M0 = CREATE_TENSOR_TYPE_FLOAT(d0);
|
||||||
|
|
||||||
|
LOG("M0->dim->rank = %ld\n",M0->dim->rank);
|
||||||
|
|
||||||
|
//init_random_x_TYPE_FLOAT(M0,2,5,50);
|
||||||
|
for(size_t i=0; i<M0->dim->rank;++i) M0->x[i]=i*0.1 +1;
|
||||||
|
|
||||||
|
|
||||||
|
// print_tensor_float(M0, "M0 ");
|
||||||
|
print_tensor_msg_TYPE_FLOAT(M0, "M0 ");
|
||||||
|
free_tensor_TYPE_FLOAT(M0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(sprinttens){
|
||||||
|
dimension *d0=create_dim(3);
|
||||||
|
|
||||||
|
d0->perm[0]=4;
|
||||||
|
d0->perm[1]=3;
|
||||||
|
d0->perm[2]=2;
|
||||||
|
|
||||||
|
|
||||||
|
updateRankDim(d0);
|
||||||
|
|
||||||
|
|
||||||
|
tensor_TYPE_DOUBLE *M0 = CREATE_TENSOR_TYPE_DOUBLE(d0);
|
||||||
|
|
||||||
|
LOG("M0->dim->rank = %ld\n",M0->dim->rank);
|
||||||
|
|
||||||
|
init_random_x_TYPE_DOUBLE(M0,2.7,5.4,50001);
|
||||||
|
|
||||||
|
//print_tensor_double(M0, "test print M0");
|
||||||
|
char *tensCont = NULL;
|
||||||
|
size_t nbChar = sprint_tensor_TYPE_DOUBLE(&tensCont, M0, false);
|
||||||
|
|
||||||
|
LOG(" avec Sprint_tensor sans index, M0 est : \n%s \n, il y a %ld charactères\n",tensCont, nbChar);
|
||||||
|
|
||||||
|
nbChar = sprint_tensor_TYPE_DOUBLE(&tensCont, M0, true);
|
||||||
|
|
||||||
|
LOG(" avec Sprint_tensor avec index, M0 est : \n%s \n, il y a %ld charactères\n",tensCont, nbChar);
|
||||||
|
|
||||||
|
endian=false;
|
||||||
|
|
||||||
|
nbChar = sprint_tensor_TYPE_DOUBLE(&tensCont, M0, true);
|
||||||
|
|
||||||
|
LOG(" avec Sprint_tensor avec index et endian=false, M0 est : \n%s \n, il y a %ld charactères\n",tensCont, nbChar);
|
||||||
|
|
||||||
|
|
||||||
|
free(tensCont);
|
||||||
|
free_tensor_TYPE_DOUBLE(M0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
TEST(Split_randomInit){
|
||||||
|
dimension *d0=create_dim(3);
|
||||||
|
|
||||||
|
d0->perm[0]=4;
|
||||||
|
d0->perm[1]=3;
|
||||||
|
d0->perm[2]=5;
|
||||||
|
|
||||||
|
|
||||||
|
updateRankDim(d0);
|
||||||
|
|
||||||
|
|
||||||
|
tensor_TYPE_FLOAT *M0 = CREATE_TENSOR_TYPE_FLOAT(d0);
|
||||||
|
|
||||||
|
LOG("M0->dim->rank = %ld\n",M0->dim->rank);
|
||||||
|
|
||||||
|
init_random_x_TYPE_FLOAT(M0,2.7,5.4,50001);
|
||||||
|
|
||||||
|
print_tensor_float(M0, "M0 random");
|
||||||
|
print_tensor_msg_TYPE_FLOAT(M0, "M0 random");
|
||||||
|
|
||||||
|
tensor_TYPE_FLOAT *Tpart1=NULL, *Tpart2=NULL;
|
||||||
|
|
||||||
|
split_tensor_TYPE_FLOAT(M0,&Tpart1,&Tpart2, 1, 2);
|
||||||
|
|
||||||
|
print_tensor_float(Tpart1, " Tpart1 1");
|
||||||
|
print_tensor_msg_TYPE_FLOAT(Tpart1, " Tpart1 1");
|
||||||
|
print_tensor_float(Tpart2, "Tpart2 ..");
|
||||||
|
print_tensor_msg_TYPE_FLOAT(Tpart2, "Tpart2 ..");
|
||||||
|
|
||||||
|
printDebug_dimension(Tpart1->dim,"dim part1 ");
|
||||||
|
printDebug_dimension(Tpart2->dim,"dim part2 ");
|
||||||
|
printDebug_dimension(M0->dim,"dim root ");
|
||||||
|
|
||||||
|
free_tensor_TYPE_FLOAT(M0);
|
||||||
|
free(Tpart1->dim);
|
||||||
|
free(Tpart2->dim);
|
||||||
|
free(Tpart1);
|
||||||
|
free(Tpart2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
TEST(Split_randomInit){
|
||||||
|
dimension *d0=create_dim(3);
|
||||||
|
|
||||||
|
d0->perm[0]=4;
|
||||||
|
d0->perm[1]=3;
|
||||||
|
d0->perm[2]=5;
|
||||||
|
|
||||||
|
|
||||||
|
updateRankDim(d0);
|
||||||
|
|
||||||
|
|
||||||
|
tensor_TYPE_FLOAT *M0 = CREATE_TENSOR_TYPE_FLOAT(d0);
|
||||||
|
|
||||||
|
LOG("M0->dim->rank = %ld\n",M0->dim->rank);
|
||||||
|
|
||||||
|
init_random_x_TYPE_FLOAT(M0,2.7,5.4,50001);
|
||||||
|
|
||||||
|
print_tensor_float(M0, "M0 random");
|
||||||
|
|
||||||
|
tensor_TYPE_FLOAT *Tpart1=NULL, *Tpart2=NULL;
|
||||||
|
|
||||||
|
split_tensor_TYPE_FLOAT(M0,&Tpart1,&Tpart2, 2, 1);
|
||||||
|
|
||||||
|
print_tensor_float(Tpart1, " Tpart1 1");
|
||||||
|
print_tensor_float(Tpart2, "Tpart2 ..");
|
||||||
|
|
||||||
|
printDebug_dimension(Tpart1->dim,"dim part1 ");
|
||||||
|
printDebug_dimension(Tpart2->dim,"dim part2 ");
|
||||||
|
printDebug_dimension(M0->dim,"dim root ");
|
||||||
|
|
||||||
|
free_tensor_TYPE_FLOAT(M0);
|
||||||
|
free(Tpart1->dim);
|
||||||
|
free(Tpart2->dim);
|
||||||
|
free(Tpart1);
|
||||||
|
free(Tpart2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST(tensorProd ){
|
TEST(tensorProd ){
|
||||||
dimension *d0=create_dim(3);
|
dimension *d0=create_dim(3);
|
||||||
dimension *d1=create_dim(2);
|
dimension *d1=create_dim(2);
|
||||||
@@ -620,6 +818,70 @@ TEST(Pthread_tensorContractnPro2d_TYPE_DOUBLE2 ){
|
|||||||
free_tensor_TYPE_DOUBLE(M1);
|
free_tensor_TYPE_DOUBLE(M1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
TEST(contract_dim1){
|
||||||
|
dimension *d0=create_dim(3);
|
||||||
|
dimension *d1=create_dim(1);
|
||||||
|
#if VALGRIND_
|
||||||
|
d0->perm[0]=5;
|
||||||
|
d0->perm[1]=2; //3;
|
||||||
|
d0->perm[2]=3;
|
||||||
|
|
||||||
|
d1->perm[0]=3;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
d0->perm[0]=125;
|
||||||
|
d0->perm[1]=52; //3;
|
||||||
|
d0->perm[2]=63;
|
||||||
|
|
||||||
|
d1->perm[0]=63;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
updateRankDim(d0);
|
||||||
|
updateRankDim(d1);
|
||||||
|
|
||||||
|
|
||||||
|
tensor_TYPE_DOUBLE *M0 = CREATE_TENSOR_TYPE_DOUBLE(d0);
|
||||||
|
tensor_TYPE_DOUBLE *M1 = CREATE_TENSOR_TYPE_DOUBLE(d1);
|
||||||
|
|
||||||
|
LOG("M0->dim->rank = %ld\n",M0->dim->rank);
|
||||||
|
LOG("M1->dim->rank = %ld\n",M1->dim->rank);
|
||||||
|
for(size_t i=0; i<M0->dim->rank;++i) M0->x[i]=i*0.1 +1;
|
||||||
|
for(size_t i=0; i<M1->dim->rank;++i) M1->x[i]=i*0.003 + 2;
|
||||||
|
|
||||||
|
print_tensor_double(M0,"M0");
|
||||||
|
print_tensor_double(M1,"M1");
|
||||||
|
|
||||||
|
tensor_TYPE_DOUBLE *M;
|
||||||
|
tensor_TYPE_DOUBLE *MnO;
|
||||||
|
|
||||||
|
size_t nbthread = 5;
|
||||||
|
|
||||||
|
tensorContractnProd_TYPE_DOUBLE(&M, M0,M1,1);
|
||||||
|
//print_tensor_double(M,"M");
|
||||||
|
//cl_tensorContractnProd_TYPE_DOUBLE(&MnO, M0,M1,1);
|
||||||
|
tensorContractnProdThread_TYPE_DOUBLE(&MnO, M0,M1,1,nbthread);
|
||||||
|
|
||||||
|
print_tensor_double(MnO,"MnO");
|
||||||
|
|
||||||
|
printDebug_dimension(M0->dim," M0 dimension ");
|
||||||
|
printDebug_dimension(M1->dim," M1 dimension ");
|
||||||
|
printDebug_dimension(M->dim," M dimension ");
|
||||||
|
|
||||||
|
|
||||||
|
// for(size_t i=0;i<M->dim->rank;++i)
|
||||||
|
// EXPECT_EQ_TYPE_DOUBLE(M->x[i],MnO->x[i]);
|
||||||
|
|
||||||
|
EXPECT_ARRAY_EQ_TYPE_DOUBLE(M->x,M->dim->rank,MnO->x,MnO->dim->rank);
|
||||||
|
|
||||||
|
free_tensor_TYPE_DOUBLE(M);
|
||||||
|
free_tensor_TYPE_DOUBLE(MnO);
|
||||||
|
free_tensor_TYPE_DOUBLE(M0);
|
||||||
|
free_tensor_TYPE_DOUBLE(M1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
TEST(Pthread_tensorContractnProd_TYPE_DOUBLE2 ){
|
TEST(Pthread_tensorContractnProd_TYPE_DOUBLE2 ){
|
||||||
dimension *d0=create_dim(3);
|
dimension *d0=create_dim(3);
|
||||||
dimension *d1=create_dim(3);
|
dimension *d1=create_dim(3);
|
||||||
|
|||||||
Reference in New Issue
Block a user