进一步解释 void load_image_chunk_norm( ap_uint<8> img_buf[16][34][66], ap_uint<8> * image_in_raw_pad_burst,// int raw, int col, int raw_shape, int col_shape) { ap_uint<8> * image_pad_in_pad_burst_ptr; for (int co = 0; co < 16; co++) { image_pad_in_pad_burst_ptr = image_in_raw_pad_burst + co * raw_shape * col_shape + raw * 32 * col_shape + col * 64; for (int h = 0; h < 34; h++) { for (int w = 0; w < 66; w++) { img_buf[co][h][w] = image_pad_in_pad_burst_ptr[w]; } image_pad_in_pad_burst_ptr += col_shape; } } } void Special_test1( ap_uint<8> static image_in_raw_pad[16 * 512 * 1024], ap_uint<8> static ddr_dw0_out_PL_burst[16 * 130 * 258], ap_uint<8> static ddr_dw1_out_PL_burst[16 * 130 * 258], ap_uint<8> static out_feature[16 * 128 * 256]) { ap_uint<8> static FeatureMapBuf0[16][34][66]; ap_uint<8> static FeatureMapBuf1[16][34][66]; for (int raw = 0; raw < 16; raw++) { for (int col = 0; col < 16; col++) { load_image_1x1(FeatureMapBuf0, image_in_raw_pad, raw, col, 512, 1024); conv1x1(FeatureMapBuf0, FeatureMapBuf1, weight_conv1,bias_conv1_int, q_dq_1); store_4x4_AvgPooling_debug(FeatureMapBuf1, ddr_dw0_out_PL_burst, raw, col, 130, 258); } } std::cout << "over!!!!"; for (int raw = 0; raw < 8; raw++) { for (int col = 0; col < 8; col++) { load_image_chunk_norm(FeatureMapBuf0, ddr_dw0_out_PL_burst, raw, col, 130, 258); DW_CONV_3x3(FeatureMapBuf0, FeatureMapBuf1, weight_conv3,bias_conv3_int, q_dq_3); store_3x3conv(FeatureMapBuf1, ddr_dw1_out_PL_burst, raw, col, 130, 258); } }
时间: 2024-04-24 13:21:43 浏览: 10
在函数`load_image_chunk_norm`中,偏移公式计算的步骤如下:
1. 根据通道索引`co`,计算通道维度的偏移量:`co * raw_shape * col_shape`。该偏移量表示将当前通道的起始位置移动到正确的位置。
2. 根据行索引`raw`,计算行维度的偏移量:`raw * 32 * col_shape`。该偏移量表示将当前行的起始位置移动到正确的位置。由于每行有32个元素,所以将行索引乘以32得到偏移量。
3. 根据列索引`col`,计算列维度的偏移量:`col * 64`。该偏移量表示将当前列的起始位置移动到正确的位置。由于每列有64个元素,所以将列索引乘以64得到偏移量。
通过这些偏移量的计算,可以将指向`image_in_raw_pad_burst`数组的指针`image_pad_in_pad_burst_ptr`定位到正确的位置,以便从该位置开始读取数据并存储到`img_buf[co][h][w]`中。
在函数`Special_test1`中的循环中,调用了`load_image_chunk_norm`函数来加载图像块数据到`FeatureMapBuf0`中。传递给函数的参数为:`FeatureMapBuf0`(表示存储加载后图像块数据的目标数组)、`ddr_dw0_out_PL_burst`(表示图像块数据的源数组)、`raw`(表示当前图像块所在的行索引)、`col`(表示当前图像块所在的列索引)、`130`(表示原始行数)、`258`(表示原始列数)。
通过调用`load_image_chunk_norm`函数,将图像块数据加载到`FeatureMapBuf0`中后,可以进行后续的处理,如调用`DW_CONV_3x3`函数来进行3x3卷积,并将结果存储到其他数组中。
总结来说,偏移公式计算是正确的,并且在`Special_test1`函数中正确地调用了`load_image_chunk_norm`函数来加载和处理图像块数据。