model-layer/scalable-tf-module/FTcom/Tensor.cpp
/* Read meta-information from a grid-based tensor file */
Read meta-information from a grid-based tensor file
Read meta - information from a grid - based tensor file
void Read_Grid_Info(char *InputPath, int **&gridDimCnt, int **&gridDims) {
	int i, g;
	int gridSize = Option::gridSize;
	int order = Option::tensorOrder;
	char filename[1024];
	sprintf(filename, "%s_GTF", InputPath);
	int fd = open(filename, O_RDWR, S_IRWXU);
	gridDimCnt = (int **)malloc(sizeof(int *)*order);
	gridDimCnt[0] = (int *)malloc(sizeof(int)*order*(gridSize+1));
	gridDims = (int **)malloc(sizeof(int *)*order);
	gridDims[0] = (int *)malloc(sizeof(int)*order*gridSize);
	pread(fd, gridDimCnt[0], sizeof(int)*order*(gridSize+1), sizeof(int)*2);
	close(fd);
	for (i = 0; i < order; i++) {
		gridDims[i] = &gridDims[0][i*gridSize];
		gridDimCnt[i] = &gridDimCnt[0][i*(gridSize+1)];
		for (g = 0; g < gridSize; g++)
			gridDims[i][g] = gridDimCnt[i][g+1] - gridDimCnt[i][g];
	} 
}
void Read_Grid_Info ( char * InputPath , int * * & gridDimCnt , int * * & gridDims ) { int i , g ; int gridSize = Option :: gridSize ; int order = Option :: tensorOrder ; char filename [ 1024 ] ; sprintf ( filename , " " , InputPath ) ; int fd = open ( filename , O_RDWR , S_IRWXU ) ; gridDimCnt = ( int * * ) malloc ( sizeof ( int * ) * order ) ; gridDimCnt [ 0 ] = ( int * ) malloc ( sizeof ( int ) * order * ( gridSize + 1 ) ) ; gridDims = ( int * * ) malloc ( sizeof ( int * ) * order ) ; gridDims [ 0 ] = ( int * ) malloc ( sizeof ( int ) * order * gridSize ) ; pread ( fd , gridDimCnt [ 0 ] , sizeof ( int ) * order * ( gridSize + 1 ) , sizeof ( int ) * 2 ) ; close ( fd ) ; for ( i = 0 ; i < order ; i ++ ) { gridDims [ i ] = & gridDims [ 0 ] [ i * gridSize ] ; gridDimCnt [ i ] = & gridDimCnt [ 0 ] [ i * ( gridSize + 1 ) ] ; for ( g = 0 ; g < gridSize ; g ++ ) gridDims [ i ] [ g ] = gridDimCnt [ i ] [ g + 1 ] - gridDimCnt [ i ] [ g ] ; } }
Read meta-information from a grid-based tensor file
Read meta - information from a grid - based tensor file