#include #include "tiny_cnn_accel.h" #include "tiny_cnn_test_image.h" int main() { hls::stream input_stream; hls::stream output_stream; std::cout << "Preparing input stream" << std::endl; for (int row = 0; row < IMG_SIZE; row++) { for (int col = 0; col < IMG_SIZE; col++) { axis_word_t word; word.data = test_image_u8[row][col]; word.keep = -1; word.strb = -1; word.user = 0; word.id = 0; word.dest = 0; word.last = (row == IMG_SIZE - 1 && col == IMG_SIZE - 1) ? 1 : 0; input_stream.write(word); } } std::cout << "Running tiny_cnn_accel" << std::endl; tiny_cnn_accel(input_stream, output_stream); std::cout << "Reading output stream" << std::endl; int best_class = 0; int best_logit = -2147483647; std::cout << "TinyCNN HLS test image: " << TINY_CNN_TEST_IMAGE_PATH << std::endl; for (int cls = 0; cls < NUM_CLASSES; cls++) { axis_word_t word = output_stream.read(); int logit = word.data.to_int(); std::cout << "logit[" << cls << "]=" << logit << std::endl; if (logit > best_logit) { best_logit = logit; best_class = cls; } if (cls == NUM_CLASSES - 1 && word.last != 1) { std::cerr << "ERROR: last flag missing on final output" << std::endl; return 1; } } std::cout << "predicted_class=" << best_class << std::endl; return 0; }