cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Schwarz
Visitor
Visitor
105 Views
Registered: ‎04-18-2021

Vivado HLS read file data failed

when I run the C++ code in Visual Studio, the file read result are as follows:

Schwarz_0-1618814445612.png

then I copy the code to Vivado HLS and do C-simulation, HLS read the file, result are as follows:

Schwarz_1-1618814549174.png

obviously the data is wrong, so the result of the code is wrong too.

And when I read the train data label, it failed like this:

in Visual Studio(right):

Schwarz_2-1618814710802.png

it means 5,0,4,1...etc

in HLS(wrong)

Schwarz_3-1618814752520.png

it's 0,0,0,0..etc

 

as you can see, the reading result is not fully wrong but it's wrong indeed. can you help me?

 

the part code of reading file are as follows:

    char rubbish[16];
    ifstream train_images("./train-images.idx3-ubyte", ios::binary | ios::in);
    ifstream train_labels("./train-labels.idx1-ubyte", ios::binary | ios::in);
    train_images.read(rubbish, 16); //4*32bit_integer
    train_labels.read(rubbish, 8);  //2*32bit_integer
    for (int i = 0; i < batch_num * batch_size; i++)
    {
        char image[IMAGE_SIZE];
        char num[LABEL_SIZE];
        train_images.read(image, IMAGE_SIZE);
        train_labels.read(num, LABEL_SIZE);
        for (int j = 0; j < IMAGE_SIZE; j++)
        {
            sw_train_data[i][j] = (unsigned char)image[j];
            sw_train_data[i][j] /= 180.0;
            //cout << sw_train_data[i][j] << " ";
        }
        for (int j = 0; j < OUT_SIZE; j++)
        {
            if (j == (unsigned char)num[0])
                sw_train_label[i][j] = 1;
            else
                sw_train_label[i][j] = 0;
        }
    }

I tried to change the file path to absolute path but it doesnt work.

files are here.

Schwarz_4-1618815007674.png

thanks for your help!

0 Kudos
0 Replies