Hi, I can generate a matrix of 10x20 dimension of random integers in tta_stream_v1.in, the FU has been added from "Add from HDB".
The code to generate 10x20 matrix in tta_stream_v1.in is (this file is named as: "random.c")
include
include
include
include "random.h"
void generateRandomMatrix(int rows, int cols, FILE *file) {
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; ++j) {
//fprintf(file, "%0.4f", ((double)rand() / (double)RAND_MAX));
fprintf(file, "%d ", rand() % 100);
}
fprintf(file, "\n");
}
}
int main() {
//int hiddenSize1=10;
//int inputSize=20;
srand(time(NULL));
FILE *outputFile = fopen("tta_stream_v1.in", "w");
if (outputFile == NULL) {
fprintf(stderr, "Error opening the file.\n");
return 1;
}
// Generate a random 10x20 matrix and write it to the file
generateRandomMatrix(hiddenSize1, inputSize, outputFile);
fclose(outputFile);
printf("Random numbers have been written to 'tta_stream_v1.in'.\n");
return 0;
}
The tta_stream_v1.in writes the matrix from the above code as follows:
Now I want to read the matrix from tta_stream_v1.in and write it to tta_stream_v1.out by writing another code random_main.c. The code is given below:
include
//#include
include
//#include
include
include "random.h"
int main()
{
int X[hiddenSize1][inputSize];
int test[hiddenSize1][inputSize]={{0},{0}};
//int test = 0;
for (int i = 0; i < hiddenSize1; i++)
{
for (int j = 0; j < inputSize; j++)
{
_TCE_STREAM_IN_V1(0,test[i][j]);
//_TCE_STREAM_IN_V1(0,test);
X[i][j] = test[i][j];
//X[i][j] = test;
_TCE_STREAM_OUT_V1(X[i][j]);
}
}
return 0;
}
The output in tta_stream_v1.out is:
What modification should I do in my random_main.c code to write the matrix in tta_stream_v1.out exactly as it is in tta_stream_v1.in?
How do the STREAMIN/OUT* operation definitions look like? These are not OpenASIP-shipped operations so I cannot tell. Do they have the correct state flags etc. in place so the compiler doesn't reorder them?
Hi, I can generate a matrix of 10x20 dimension of random integers in tta_stream_v1.in, the FU has been added from "Add from HDB".
The code to generate 10x20 matrix in tta_stream_v1.in is (this file is named as: "random.c")
include
include
include
include "random.h"
void generateRandomMatrix(int rows, int cols, FILE *file) {
}
int main() {
}
The tta_stream_v1.in writes the matrix from the above code as follows:
Now I want to read the matrix from tta_stream_v1.in and write it to tta_stream_v1.out by writing another code random_main.c. The code is given below:
include
//#include
include
//#include
include
include "random.h"
int main()
{
return 0;
}
The output in tta_stream_v1.out is:
What modification should I do in my random_main.c code to write the matrix in tta_stream_v1.out exactly as it is in tta_stream_v1.in?