diff --git a/CMakeLists.txt b/CMakeLists.txt index 77da651..376c175 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,7 @@ target_link_libraries(tkDNN ${tkdnn_LIBS}) #add_library(tkDNN_static STATIC ${tkdnn_SRC}) #target_link_libraries(tkDNN_static ${tkdnn_LIBS}) +# SMALL NETS add_executable(test_simple tests/simple/test_simple.cpp) target_link_libraries(test_simple tkDNN) @@ -63,91 +64,43 @@ target_link_libraries(test_mnist tkDNN) add_executable(test_mnistRT tests/mnist/test_mnistRT.cpp) target_link_libraries(test_mnistRT tkDNN) -## YOLO NETS -add_executable(test_yolo tests/yolo/yolo.cpp) -target_link_libraries(test_yolo tkDNN) - -add_executable(test_yolo_voc tests/yolo_voc/yolo_voc.cpp) -target_link_libraries(test_yolo_voc tkDNN) - -add_executable(test_yolo_tiny tests/yolo_tiny/yolo_tiny.cpp) -target_link_libraries(test_yolo_tiny tkDNN) - -add_executable(test_yolo_relu tests/yolo_relu/yolo_relu.cpp) -target_link_libraries(test_yolo_relu tkDNN) - - -add_executable(test_yolo_224 tests/yolo_224/yolo_224.cpp) -target_link_libraries(test_yolo_224 tkDNN) - -add_executable(test_yolo_berkeley tests/yolo_berkeley/yolo_berkeley.cpp) -target_link_libraries(test_yolo_berkeley tkDNN) - -add_executable(test_yolo3_coco4 tests/yolo3_coco4/yolo3_coco4.cpp) -target_link_libraries(test_yolo3_coco4 tkDNN) - -add_executable(test_yolo3 tests/yolo3/yolo3.cpp) -target_link_libraries(test_yolo3 tkDNN) - -add_executable(test_yolo3_512 tests/yolo3_512/yolo3_512.cpp) -target_link_libraries(test_yolo3_512 tkDNN) - -add_executable(test_yolo3_512tp tests/yolo3_512tp/yolo3_512tp.cpp) -target_link_libraries(test_yolo3_512tp tkDNN) - -add_executable(test_yolo3_tiny tests/yolo3_tiny/yolo3_tiny.cpp) -target_link_libraries(test_yolo3_tiny tkDNN) - -add_executable(test_yolo3_tiny512 tests/yolo3_tiny512/yolo3_tiny512.cpp) -target_link_libraries(test_yolo3_tiny512 tkDNN) - -add_executable(test_yolo3_tinyNM512 tests/yolo3_tinyNM512/yolo3_tinyNM512.cpp) -target_link_libraries(test_yolo3_tinyNM512 tkDNN) - -add_executable(test_yolo3_tiny512tp tests/yolo3_tiny512tp/yolo3_tiny512tp.cpp) -target_link_libraries(test_yolo3_tiny512tp tkDNN) - -add_executable(test_yolo3_berkeley tests/yolo3_berkeley/yolo3_berkeley.cpp) -target_link_libraries(test_yolo3_berkeley tkDNN) - -add_executable(test_yolo3_flir tests/yolo3_flir/yolo3_flir.cpp) -target_link_libraries(test_yolo3_flir tkDNN) - -add_executable(test_yolo4 tests/yolo4/yolo4.cpp) -target_link_libraries(test_yolo4 tkDNN) - -add_executable(test_mobilenetv2ssd tests/mobilenetv2ssd/mobilenetv2ssd.cpp) -target_link_libraries(test_mobilenetv2ssd tkDNN) - -add_executable(test_bdd-mobilenetv2ssd tests/bdd-mobilenetv2ssd/bdd-mobilenetv2ssd.cpp) -target_link_libraries(test_bdd-mobilenetv2ssd tkDNN) - -add_executable(test_mobilenetv2ssd512 tests/mobilenetv2ssd512/mobilenetv2ssd512.cpp) -target_link_libraries(test_mobilenetv2ssd512 tkDNN) - -add_executable(test_resnet101 tests/resnet101/resnet101.cpp) -target_link_libraries(test_resnet101 tkDNN) - -add_executable(test_csresnext50-panet-spp tests/csresnext50-panet-spp/csresnext50-panet-spp.cpp) -target_link_libraries(test_csresnext50-panet-spp tkDNN) - -add_executable(test_bdd-csresnext50-panet-spp tests/bdd-csresnext50-panet-spp/bdd-csresnext50-panet-spp.cpp) -target_link_libraries(test_bdd-csresnext50-panet-spp tkDNN) - -add_executable(test_resnet101_cnet tests/resnet101_cnet/resnet101_cnet.cpp) -target_link_libraries(test_resnet101_cnet tkDNN) - -add_executable(test_dla34 tests/dla34/dla34.cpp) -target_link_libraries(test_dla34 tkDNN) - -add_executable(test_dla34_cnet tests/dla34_cnet/dla34_cnet.cpp) -target_link_libraries(test_dla34_cnet tkDNN) - add_executable(test_imuodom tests/imuodom/imuodom.cpp) target_link_libraries(test_imuodom tkDNN) -################################################################################ +# DARKNET +file(GLOB darknet_SRC "tests/darknet/*.cpp") +foreach(test_SRC ${darknet_SRC}) + get_filename_component(test_NAME "${test_SRC}" NAME_WE) + set(test_NAME test_${test_NAME}) + add_executable(${test_NAME} ${test_SRC}) + target_link_libraries(${test_NAME} tkDNN) +endforeach() +# MOBILENET +add_executable(test_mobilenetv2ssd tests/mobilenet/mobilenetv2ssd/mobilenetv2ssd.cpp) +target_link_libraries(test_mobilenetv2ssd tkDNN) + +add_executable(test_bdd-mobilenetv2ssd tests/mobilenet/bdd-mobilenetv2ssd/bdd-mobilenetv2ssd.cpp) +target_link_libraries(test_bdd-mobilenetv2ssd tkDNN) + +add_executable(test_mobilenetv2ssd512 tests/mobilenet/mobilenetv2ssd512/mobilenetv2ssd512.cpp) +target_link_libraries(test_mobilenetv2ssd512 tkDNN) + +# BACKBONES +add_executable(test_resnet101 tests/backbones/resnet101/resnet101.cpp) +target_link_libraries(test_resnet101 tkDNN) + +add_executable(test_dla34 tests/backbones/dla34/dla34.cpp) +target_link_libraries(test_dla34 tkDNN) + +# CENTERNET +add_executable(test_resnet101_cnet tests/centernet/resnet101_cnet/resnet101_cnet.cpp) +target_link_libraries(test_resnet101_cnet tkDNN) + +add_executable(test_dla34_cnet tests/centernet/dla34_cnet/dla34_cnet.cpp) +target_link_libraries(test_dla34_cnet tkDNN) + +# DEMOS add_executable(test_rtinference tests/test_rtinference/rtinference.cpp) target_link_libraries(test_rtinference tkDNN) @@ -171,18 +124,3 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" # source directory DESTINATION "share/tkDNN/cmake/" # target directory ) - -#------------------------------------------------------------------------------- -# Prepare for test (not needed anymore) -#------------------------------------------------------------------------------- -#set(TEST_DATA true CACHE BOOL "If true download deps") -#if( ${TEST_DATA} ) -# message("Launching pre-build dependency installer script...") -# -# execute_process (COMMAND bash -c "bash build_models.sh download" -# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests) -# -# set(TEST_DATA false CACHE BOOL "If true download deps" FORCE) -# message("Finished dowloading test weights") -#endif() - diff --git a/include/tkDNN/models/Yolo3.h b/include/tkDNN/models/Yolo3.h deleted file mode 100644 index cd69b32..0000000 --- a/include/tkDNN/models/Yolo3.h +++ /dev/null @@ -1,289 +0,0 @@ -int preYoloFilters = (classes+5)*3; - -std::string input_bin = bin_path + "/layers/input.bin"; -std::vector output_bins = { - bin_path + "/debug/layer82_out.bin", - bin_path + "/debug/layer94_out.bin", - bin_path + "/debug/layer106_out.bin" -}; -std::string c0_bin = bin_path + "/layers/c0.bin"; -std::string c1_bin = bin_path + "/layers/c1.bin"; -std::string c2_bin = bin_path + "/layers/c2.bin"; -std::string c3_bin = bin_path + "/layers/c3.bin"; -std::string c5_bin = bin_path + "/layers/c5.bin"; -std::string c6_bin = bin_path + "/layers/c6.bin"; -std::string c7_bin = bin_path + "/layers/c7.bin"; -std::string c9_bin = bin_path + "/layers/c9.bin"; -std::string c10_bin = bin_path + "/layers/c10.bin"; -std::string c12_bin = bin_path + "/layers/c12.bin"; -std::string c13_bin = bin_path + "/layers/c13.bin"; -std::string c14_bin = bin_path + "/layers/c14.bin"; -std::string c16_bin = bin_path + "/layers/c16.bin"; -std::string c17_bin = bin_path + "/layers/c17.bin"; -std::string c19_bin = bin_path + "/layers/c19.bin"; -std::string c20_bin = bin_path + "/layers/c20.bin"; -std::string c22_bin = bin_path + "/layers/c22.bin"; -std::string c23_bin = bin_path + "/layers/c23.bin"; -std::string c25_bin = bin_path + "/layers/c25.bin"; -std::string c26_bin = bin_path + "/layers/c26.bin"; -std::string c28_bin = bin_path + "/layers/c28.bin"; -std::string c29_bin = bin_path + "/layers/c29.bin"; -std::string c31_bin = bin_path + "/layers/c31.bin"; -std::string c32_bin = bin_path + "/layers/c32.bin"; -std::string c34_bin = bin_path + "/layers/c34.bin"; -std::string c35_bin = bin_path + "/layers/c35.bin"; -std::string c37_bin = bin_path + "/layers/c37.bin"; -std::string c38_bin = bin_path + "/layers/c38.bin"; -std::string c39_bin = bin_path + "/layers/c39.bin"; -std::string c41_bin = bin_path + "/layers/c41.bin"; -std::string c42_bin = bin_path + "/layers/c42.bin"; -std::string c44_bin = bin_path + "/layers/c44.bin"; -std::string c45_bin = bin_path + "/layers/c45.bin"; -std::string c47_bin = bin_path + "/layers/c47.bin"; -std::string c48_bin = bin_path + "/layers/c48.bin"; -std::string c50_bin = bin_path + "/layers/c50.bin"; -std::string c51_bin = bin_path + "/layers/c51.bin"; -std::string c53_bin = bin_path + "/layers/c53.bin"; -std::string c54_bin = bin_path + "/layers/c54.bin"; -std::string c56_bin = bin_path + "/layers/c56.bin"; -std::string c57_bin = bin_path + "/layers/c57.bin"; -std::string c59_bin = bin_path + "/layers/c59.bin"; -std::string c60_bin = bin_path + "/layers/c60.bin"; -std::string c62_bin = bin_path + "/layers/c62.bin"; -std::string c63_bin = bin_path + "/layers/c63.bin"; -std::string c64_bin = bin_path + "/layers/c64.bin"; -std::string c66_bin = bin_path + "/layers/c66.bin"; -std::string c67_bin = bin_path + "/layers/c67.bin"; -std::string c69_bin = bin_path + "/layers/c69.bin"; -std::string c70_bin = bin_path + "/layers/c70.bin"; -std::string c72_bin = bin_path + "/layers/c72.bin"; -std::string c73_bin = bin_path + "/layers/c73.bin"; -std::string c75_bin = bin_path + "/layers/c75.bin"; -std::string c76_bin = bin_path + "/layers/c76.bin"; -std::string c77_bin = bin_path + "/layers/c77.bin"; -std::string c78_bin = bin_path + "/layers/c78.bin"; -std::string c79_bin = bin_path + "/layers/c79.bin"; -std::string c80_bin = bin_path + "/layers/c80.bin"; -std::string c81_bin = bin_path + "/layers/c81.bin"; -std::string g82_bin = bin_path + "/layers/g82.bin"; -std::string c84_bin = bin_path + "/layers/c84.bin"; -std::string c87_bin = bin_path + "/layers/c87.bin"; -std::string c88_bin = bin_path + "/layers/c88.bin"; -std::string c89_bin = bin_path + "/layers/c89.bin"; -std::string c90_bin = bin_path + "/layers/c90.bin"; -std::string c91_bin = bin_path + "/layers/c91.bin"; -std::string c92_bin = bin_path + "/layers/c92.bin"; -std::string c93_bin = bin_path + "/layers/c93.bin"; -std::string g94_bin = bin_path + "/layers/g94.bin"; -std::string c96_bin = bin_path + "/layers/c96.bin"; -std::string c99_bin = bin_path + "/layers/c99.bin"; -std::string c100_bin = bin_path + "/layers/c100.bin"; -std::string c101_bin = bin_path + "/layers/c101.bin"; -std::string c102_bin = bin_path + "/layers/c102.bin"; -std::string c103_bin = bin_path + "/layers/c103.bin"; -std::string c104_bin = bin_path + "/layers/c104.bin"; -std::string c105_bin = bin_path + "/layers/c105.bin"; -std::string g106_bin = bin_path + "/layers/g106.bin"; - -tk::dnn::Conv2d c0 (&net, 32, 3, 3, 1, 1, 1, 1, c0_bin, true); -tk::dnn::Activation a0 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c1 (&net, 64, 3, 3, 2, 2, 1, 1, c1_bin, true); -tk::dnn::Activation a1 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c2 (&net, 32, 1, 1, 1, 1, 0, 0, c2_bin, true); -tk::dnn::Activation a2 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c3 (&net, 64, 3, 3, 1, 1, 1, 1, c3_bin, true); -tk::dnn::Activation a3 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s4 (&net, &a1); -tk::dnn::Conv2d c5 (&net, 128, 3, 3, 2, 2, 1, 1, c5_bin, true); -tk::dnn::Activation a5 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c6 (&net, 64, 1, 1, 1, 1, 0, 0, c6_bin, true); -tk::dnn::Activation a6 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c7 (&net, 128, 3, 3, 1, 1, 1, 1, c7_bin, true); -tk::dnn::Activation a7 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s8 (&net, &a5); -tk::dnn::Conv2d c9 (&net, 64, 1, 1, 1, 1, 0, 0, c9_bin, true); -tk::dnn::Activation a9 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c10 (&net, 128, 3, 3, 1, 1, 1, 1, c10_bin, true); -tk::dnn::Activation a10 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s11 (&net, &s8); - -tk::dnn::Conv2d c12 (&net, 256, 3, 3, 2, 2, 1, 1, c12_bin, true); -tk::dnn::Activation a12 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c13 (&net, 128, 1, 1, 1, 1, 0, 0, c13_bin, true); -tk::dnn::Activation a13 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c14 (&net, 256, 3, 3, 1, 1, 1, 1, c14_bin, true); -tk::dnn::Activation a14 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s15 (&net, &a12); - -tk::dnn::Conv2d c16 (&net, 128, 1, 1, 1, 1, 0, 0, c16_bin, true); -tk::dnn::Activation a16 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c17 (&net, 256, 3, 3, 1, 1, 1, 1, c17_bin, true); -tk::dnn::Activation a17 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s18 (&net, &s15); -tk::dnn::Conv2d c19 (&net, 128, 1, 1, 1, 1, 0, 0, c19_bin, true); -tk::dnn::Activation a19 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c20 (&net, 256, 3, 3, 1, 1, 1, 1, c20_bin, true); -tk::dnn::Activation a20 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s21 (&net, &s18); -tk::dnn::Conv2d c22 (&net, 128, 1, 1, 1, 1, 0, 0, c22_bin, true); -tk::dnn::Activation a22 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c23 (&net, 256, 3, 3, 1, 1, 1, 1, c23_bin, true); -tk::dnn::Activation a23 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s24 (&net, &s21); -tk::dnn::Conv2d c25 (&net, 128, 1, 1, 1, 1, 0, 0, c25_bin, true); -tk::dnn::Activation a25 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c26 (&net, 256, 3, 3, 1, 1, 1, 1, c26_bin, true); -tk::dnn::Activation a26 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s27 (&net, &s24); -tk::dnn::Conv2d c28 (&net, 128, 1, 1, 1, 1, 0, 0, c28_bin, true); -tk::dnn::Activation a28 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c29 (&net, 256, 3, 3, 1, 1, 1, 1, c29_bin, true); -tk::dnn::Activation a29 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s30 (&net, &s27); -tk::dnn::Conv2d c31 (&net, 128, 1, 1, 1, 1, 0, 0, c31_bin, true); -tk::dnn::Activation a31 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c32 (&net, 256, 3, 3, 1, 1, 1, 1, c32_bin, true); -tk::dnn::Activation a32 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s33 (&net, &s30); -tk::dnn::Conv2d c34 (&net, 128, 1, 1, 1, 1, 0, 0, c34_bin, true); -tk::dnn::Activation a34 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c35 (&net, 256, 3, 3, 1, 1, 1, 1, c35_bin, true); -tk::dnn::Activation a35 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s36 (&net, &s33); - -tk::dnn::Conv2d c37 (&net, 512, 3, 3, 2, 2, 1, 1, c37_bin, true); -tk::dnn::Activation a37 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c38 (&net, 256, 1, 1, 1, 1, 0, 0, c38_bin, true); -tk::dnn::Activation a38 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c39 (&net, 512, 3, 3, 1, 1, 1, 1, c39_bin, true); -tk::dnn::Activation a39 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s40 (&net, &a37); - -tk::dnn::Conv2d c41 (&net, 256, 1, 1, 1, 1, 0, 0, c41_bin, true); -tk::dnn::Activation a41 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c42 (&net, 512, 3, 3, 1, 1, 1, 1, c42_bin, true); -tk::dnn::Activation a42 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s43 (&net, &s40); -tk::dnn::Conv2d c44 (&net, 256, 1, 1, 1, 1, 0, 0, c44_bin, true); -tk::dnn::Activation a44 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c45 (&net, 512, 3, 3, 1, 1, 1, 1, c45_bin, true); -tk::dnn::Activation a45 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s46 (&net, &s43); -tk::dnn::Conv2d c47 (&net, 256, 1, 1, 1, 1, 0, 0, c47_bin, true); -tk::dnn::Activation a47 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c48 (&net, 512, 3, 3, 1, 1, 1, 1, c48_bin, true); -tk::dnn::Activation a48 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s49 (&net, &s46); -tk::dnn::Conv2d c50 (&net, 256, 1, 1, 1, 1, 0, 0, c50_bin, true); -tk::dnn::Activation a50 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c51 (&net, 512, 3, 3, 1, 1, 1, 1, c51_bin, true); -tk::dnn::Activation a51 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s52 (&net, &s49); -tk::dnn::Conv2d c53 (&net, 256, 1, 1, 1, 1, 0, 0, c53_bin, true); -tk::dnn::Activation a53 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c54 (&net, 512, 3, 3, 1, 1, 1, 1, c54_bin, true); -tk::dnn::Activation a54 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s55 (&net, &s52); -tk::dnn::Conv2d c56 (&net, 256, 1, 1, 1, 1, 0, 0, c56_bin, true); -tk::dnn::Activation a56 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c57 (&net, 512, 3, 3, 1, 1, 1, 1, c57_bin, true); -tk::dnn::Activation a57 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s58 (&net, &s55); -tk::dnn::Conv2d c59 (&net, 256, 1, 1, 1, 1, 0, 0, c59_bin, true); -tk::dnn::Activation a59 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c60 (&net, 512, 3, 3, 1, 1, 1, 1, c60_bin, true); -tk::dnn::Activation a60 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s61 (&net, &s58); - -tk::dnn::Conv2d c62 (&net,1024, 3, 3, 2, 2, 1, 1, c62_bin, true); -tk::dnn::Activation a62 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c63 (&net, 512, 1, 1, 1, 1, 0, 0, c63_bin, true); -tk::dnn::Activation a63 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c64 (&net,1024, 3, 3, 1, 1, 1, 1, c64_bin, true); -tk::dnn::Activation a64 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s65 (&net, &a62); - -tk::dnn::Conv2d c66 (&net, 512, 1, 1, 1, 1, 0, 0, c66_bin, true); -tk::dnn::Activation a66 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c67 (&net,1024, 3, 3, 1, 1, 1, 1, c67_bin, true); -tk::dnn::Activation a67 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s68 (&net, &s65); - -tk::dnn::Conv2d c69 (&net, 512, 1, 1, 1, 1, 0, 0, c69_bin, true); -tk::dnn::Activation a69 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c70 (&net,1024, 3, 3, 1, 1, 1, 1, c70_bin, true); -tk::dnn::Activation a70 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s71 (&net, &s68); - -tk::dnn::Conv2d c72 (&net, 512, 1, 1, 1, 1, 0, 0, c72_bin, true); -tk::dnn::Activation a72 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c73 (&net,1024, 3, 3, 1, 1, 1, 1, c73_bin, true); -tk::dnn::Activation a73 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Shortcut s74 (&net, &s71); - -tk::dnn::Conv2d c75 (&net, 512, 1, 1, 1, 1, 0, 0, c75_bin, true); -tk::dnn::Activation a75 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c76 (&net,1024, 3, 3, 1, 1, 1, 1, c76_bin, true); -tk::dnn::Activation a76 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c77 (&net, 512, 1, 1, 1, 1, 0, 0, c77_bin, true); -tk::dnn::Activation a77 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c78 (&net,1024, 3, 3, 1, 1, 1, 1, c78_bin, true); -tk::dnn::Activation a78 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c79 (&net, 512, 1, 1, 1, 1, 0, 0, c79_bin, true); -tk::dnn::Activation a79 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c80 (&net,1024, 3, 3, 1, 1, 1, 1, c80_bin, true); -tk::dnn::Activation a80 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c81 (&net, preYoloFilters, 1, 1, 1, 1, 0, 0, c81_bin, false); -tk::dnn::Yolo yolo0 (&net, classes, 3, g82_bin); - -tk::dnn::Layer *m83_layers[1] = { &a79 }; -tk::dnn::Route m83 (&net, m83_layers, 1); -tk::dnn::Conv2d c84 (&net, 256, 1, 1, 1, 1, 0, 0, c84_bin, true); -tk::dnn::Activation a84 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Upsample u85 (&net, 2); - -tk::dnn::Layer *m86_layers[2] = { &u85, &s61 }; -tk::dnn::Route m86 (&net, m86_layers, 2); -tk::dnn::Conv2d c87 (&net, 256, 1, 1, 1, 1, 0, 0, c87_bin, true); -tk::dnn::Activation a87 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c88 (&net, 512, 3, 3, 1, 1, 1, 1, c88_bin, true); -tk::dnn::Activation a88 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c89 (&net, 256, 1, 1, 1, 1, 0, 0, c89_bin, true); -tk::dnn::Activation a89 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c90 (&net, 512, 3, 3, 1, 1, 1, 1, c90_bin, true); -tk::dnn::Activation a90 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c91 (&net, 256, 1, 1, 1, 1, 0, 0, c91_bin, true); -tk::dnn::Activation a91 (&net, tk::dnn::ACTIVATION_LEAKY); - -tk::dnn::Conv2d c92 (&net, 512, 3, 3, 1, 1, 1, 1, c92_bin, true); -tk::dnn::Activation a92 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c93 (&net, preYoloFilters, 1, 1, 1, 1, 0, 0, c93_bin, false); -tk::dnn::Yolo yolo1 (&net, classes, 3, g94_bin); - -tk::dnn::Layer *m95_layers[1] = { &a91 }; -tk::dnn::Route m95 (&net, m95_layers, 1); -tk::dnn::Conv2d c96 (&net, 128, 1, 1, 1, 1, 0, 0, c96_bin, true); -tk::dnn::Activation a96 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Upsample u97 (&net, 2); - -tk::dnn::Layer *m98_layers[2] = { &u97, &s36 }; -tk::dnn::Route m98 (&net, m98_layers, 2); -tk::dnn::Conv2d c99 (&net, 128, 1, 1, 1, 1, 0, 0, c99_bin, true); -tk::dnn::Activation a99 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c100 (&net, 256, 3, 3, 1, 1, 1, 1, c100_bin, true); -tk::dnn::Activation a100 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c101 (&net, 128, 1, 1, 1, 1, 0, 0, c101_bin, true); -tk::dnn::Activation a101 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c102 (&net, 256, 3, 3, 1, 1, 1, 1, c102_bin, true); -tk::dnn::Activation a102 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c103 (&net, 128, 1, 1, 1, 1, 0, 0, c103_bin, true); -tk::dnn::Activation a103 (&net, tk::dnn::ACTIVATION_LEAKY); - -tk::dnn::Conv2d c104 (&net, 256, 3, 3, 1, 1, 1, 1, c104_bin, true); -tk::dnn::Activation a104 (&net, tk::dnn::ACTIVATION_LEAKY); -tk::dnn::Conv2d c105 (&net, preYoloFilters, 1, 1, 1, 1, 0, 0, c105_bin, false); -tk::dnn::Yolo yolo2 (&net, classes, 3, g106_bin); - -yolo[0] = &yolo0; -yolo[1] = &yolo1; -yolo[2] = &yolo2; \ No newline at end of file diff --git a/include/tkDNN/test.h b/include/tkDNN/test.h new file mode 100644 index 0000000..0b810da --- /dev/null +++ b/include/tkDNN/test.h @@ -0,0 +1,68 @@ + +#include +int testInference(std::vector input_bins, std::vector output_bins, + tk::dnn::Network *net, tk::dnn::NetworkRT *netRT = nullptr) { + + std::vector outputs; + for(int i=0; inum_layers; i++) { + if(net->layers[i]->final) + outputs.push_back(net->layers[i]); + } + + // check input + if(input_bins.size() != 1) { + FatalError("currently support only 1 input"); + } + if(output_bins.size() != outputs.size()) { + std::cout<input_dim.tot(), &input_h, &data); + + // outputs + dnnType *cudnn_out[outputs.size()], *rt_out[outputs.size()]; + + tk::dnn::dataDim_t dim1 = net->input_dim; //input dim + printCenteredTitle(" CUDNN inference ", '=', 30); { + dim1.print(); + TIMER_START + net->infer(dim1, data); + TIMER_STOP + dim1.print(); + } + for(int i=0; idstData; + + if(netRT != nullptr) { + tk::dnn::dataDim_t dim2 = net->input_dim; + printCenteredTitle(" TENSORRT inference ", '=', 30); { + dim2.print(); + TIMER_START + netRT->infer(dim2, data); + TIMER_STOP + dim2.print(); + } + for(int i=0; ibuffersRT[i+1]; + } + + int ret_cudnn = 0, ret_tensorrt = 0, ret_cudnn_tensorrt = 0; + for(int i=0; idstData; - - printCenteredTitle(" compute detections ", '=', 30); - TIMER_START - int ndets = 0; - tk::dnn::Yolo::detection *dets = tk::dnn::Yolo::allocateDetections(tk::dnn::Yolo::MAX_DETECTIONS, classes); - for (int i = 0; i < 3; i++) - yolo[i]->computeDetections(dets, ndets, net.input_dim.w, net.input_dim.h, 0.5); - tk::dnn::Yolo::mergeDetections(dets, ndets, classes); - - for (int j = 0; j < ndets; j++) - { - tk::dnn::Yolo::box b = dets[j].bbox; - int x0 = (b.x - b.w / 2.); - int x1 = (b.x + b.w / 2.); - int y0 = (b.y - b.h / 2.); - int y1 = (b.y + b.h / 2.); - - int cl = 0; - for (int c = 0; c < classes; ++c) - { - float prob = dets[j].prob[c]; - if (prob > 0) - cl = c; - } - std::cout << cl << ": " << x0 << " " << y0 << " " << x1 << " " << y1 << "\n"; - } - TIMER_STOP - - tk::dnn::dataDim_t dim2 = dim; - printCenteredTitle(" TENSORRT inference ", '=', 30); - { - dim2.print(); - TIMER_START - netRT.infer(dim2, data); - TIMER_STOP - dim2.print(); - } - - for (int i = 0; i < 3; i++) - rt_out[i] = (dnnType *)netRT.buffersRT[i + 1]; - - int ret_cudnn = 0, ret_tensorrt = 0, ret_cudnn_tensorrt = 0; - for (int i = 0; i < 3; i++) - { - printCenteredTitle((std::string(" YOLO ") + std::to_string(i) + " CHECK RESULTS ").c_str(), '=', 30); - dnnType *out, *out_h; - int odim = out_dim[i].tot(); - readBinaryFile(output_bins[i], odim, &out_h, &out); - std::cout<<"CUDNN vs correct"; - ret_cudnn |= checkResult(odim, cudnn_out[i], out) == 0 ? 0: ERROR_CUDNN; - std::cout<<"TRT vs correct"; - ret_tensorrt |= checkResult(odim, rt_out[i], out) == 0 ? 0 : ERROR_TENSORRT; - std::cout<<"CUDNN vs TRT "; - ret_cudnn_tensorrt |= checkResult(odim, cudnn_out[i], rt_out[i]) == 0 ? 0 : ERROR_CUDNNvsTENSORRT; - } - return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; -} diff --git a/tests/build_models.sh b/tests/build_models.sh deleted file mode 100644 index c6b5fe2..0000000 --- a/tests/build_models.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -if [ "$1" == "download" ]; then - wget https://github.com/ceccocats/tkDNN/releases/download/testData/tkDNN_testwg.tar.gz --no-check-certificate - tar -xf tkDNN_testwg.tar.gz - rm tkDNN_testwg.tar.gz - exit -fi - -echo "build test Model" -cd test -python test_model.py -cd .. -cd mnist -python mnist_model.py -cd .. -echo "export weights" -python weights_exporter.py test/net.h5 --output test/layers -python caffe_weights_exporter.py mnist/lenet.prototxt mnist/lenet.caffemodel --output mnist/layers diff --git a/tests/dla34_cnet/dla34_cnet.cpp b/tests/centernet/dla34_cnet/dla34_cnet.cpp similarity index 100% rename from tests/dla34_cnet/dla34_cnet.cpp rename to tests/centernet/dla34_cnet/dla34_cnet.cpp diff --git a/tests/resnet101_cnet/resnet101_cnet.cpp b/tests/centernet/resnet101_cnet/resnet101_cnet.cpp similarity index 100% rename from tests/resnet101_cnet/resnet101_cnet.cpp rename to tests/centernet/resnet101_cnet/resnet101_cnet.cpp diff --git a/tests/csresnext50-panet-spp/csresnext50-panet-spp.cpp b/tests/csresnext50-panet-spp/csresnext50-panet-spp.cpp deleted file mode 100644 index 11a40ae..0000000 --- a/tests/csresnext50-panet-spp/csresnext50-panet-spp.cpp +++ /dev/null @@ -1,554 +0,0 @@ -#include -#include -#include "tkdnn.h" - -int main() -{ - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 416, 416, 1); - tk::dnn::Network net(dim); - - // create csresnext50-panet-spp model - std::string bin_path = "csresnext50-panet-spp"; - int classes = 80; - tk::dnn::Yolo *yolo[3]; - - std::string input_bin = bin_path + "/layers/input.bin"; - std::string output_bin = bin_path + "/debug/layer137_out.bin"; - std::vector output_bins = { - bin_path + "/debug/layer115_out.bin", - bin_path + "/debug/layer126_out.bin", - bin_path + "/debug/layer137_out.bin"}; - std::string c0_bin = bin_path + "/layers/c0.bin"; - std::string c2_bin = bin_path + "/layers/c2.bin"; - std::string c4_bin = bin_path + "/layers/c4.bin"; - std::string c5_bin = bin_path + "/layers/c5.bin"; - std::string c6_bin = bin_path + "/layers/c6.bin"; - std::string c7_bin = bin_path + "/layers/c7.bin"; - std::string c9_bin = bin_path + "/layers/c9.bin"; - std::string c10_bin = bin_path + "/layers/c10.bin"; - std::string c11_bin = bin_path + "/layers/c11.bin"; - std::string c13_bin = bin_path + "/layers/c13.bin"; - std::string c14_bin = bin_path + "/layers/c14.bin"; - std::string c15_bin = bin_path + "/layers/c15.bin"; - std::string c17_bin = bin_path + "/layers/c17.bin"; - std::string c19_bin = bin_path + "/layers/c19.bin"; - std::string c20_bin = bin_path + "/layers/c20.bin"; - std::string c21_bin = bin_path + "/layers/c21.bin"; - std::string c23_bin = bin_path + "/layers/c23.bin"; - std::string c24_bin = bin_path + "/layers/c24.bin"; - std::string c25_bin = bin_path + "/layers/c25.bin"; - std::string c26_bin = bin_path + "/layers/c26.bin"; - std::string c28_bin = bin_path + "/layers/c28.bin"; - std::string c29_bin = bin_path + "/layers/c29.bin"; - std::string c30_bin = bin_path + "/layers/c30.bin"; - std::string c32_bin = bin_path + "/layers/c32.bin"; - std::string c33_bin = bin_path + "/layers/c33.bin"; - std::string c34_bin = bin_path + "/layers/c34.bin"; - std::string c36_bin = bin_path + "/layers/c36.bin"; - std::string c38_bin = bin_path + "/layers/c38.bin"; - std::string c39_bin = bin_path + "/layers/c39.bin"; - std::string c40_bin = bin_path + "/layers/c40.bin"; - std::string c42_bin = bin_path + "/layers/c42.bin"; - std::string c43_bin = bin_path + "/layers/c43.bin"; - std::string c44_bin = bin_path + "/layers/c44.bin"; - std::string c45_bin = bin_path + "/layers/c45.bin"; - std::string c47_bin = bin_path + "/layers/c47.bin"; - std::string c48_bin = bin_path + "/layers/c48.bin"; - std::string c49_bin = bin_path + "/layers/c49.bin"; - std::string c51_bin = bin_path + "/layers/c51.bin"; - std::string c52_bin = bin_path + "/layers/c52.bin"; - std::string c53_bin = bin_path + "/layers/c53.bin"; - std::string c55_bin = bin_path + "/layers/c55.bin"; - std::string c56_bin = bin_path + "/layers/c56.bin"; - std::string c57_bin = bin_path + "/layers/c57.bin"; - std::string c59_bin = bin_path + "/layers/c59.bin"; - std::string c60_bin = bin_path + "/layers/c60.bin"; - std::string c61_bin = bin_path + "/layers/c61.bin"; - std::string c63_bin = bin_path + "/layers/c63.bin"; - std::string c65_bin = bin_path + "/layers/c65.bin"; - std::string c66_bin = bin_path + "/layers/c66.bin"; - std::string c67_bin = bin_path + "/layers/c67.bin"; - std::string c69_bin = bin_path + "/layers/c69.bin"; - std::string c70_bin = bin_path + "/layers/c70.bin"; - std::string c71_bin = bin_path + "/layers/c71.bin"; - std::string c72_bin = bin_path + "/layers/c72.bin"; - std::string c74_bin = bin_path + "/layers/c74.bin"; - std::string c75_bin = bin_path + "/layers/c75.bin"; - std::string c76_bin = bin_path + "/layers/c76.bin"; - std::string c78_bin = bin_path + "/layers/c78.bin"; - std::string c80_bin = bin_path + "/layers/c80.bin"; - std::string c81_bin = bin_path + "/layers/c81.bin"; - std::string c82_bin = bin_path + "/layers/c82.bin"; - std::string c83_bin = bin_path + "/layers/c83.bin"; - std::string c90_bin = bin_path + "/layers/c90.bin"; - std::string c91_bin = bin_path + "/layers/c91.bin"; - std::string c92_bin = bin_path + "/layers/c92.bin"; - std::string c93_bin = bin_path + "/layers/c93.bin"; - std::string c96_bin = bin_path + "/layers/c96.bin"; - std::string c98_bin = bin_path + "/layers/c98.bin"; - std::string c99_bin = bin_path + "/layers/c99.bin"; - std::string c100_bin = bin_path + "/layers/c100.bin"; - std::string c101_bin = bin_path + "/layers/c101.bin"; - std::string c102_bin = bin_path + "/layers/c102.bin"; - std::string c103_bin = bin_path + "/layers/c103.bin"; - std::string c106_bin = bin_path + "/layers/c106.bin"; - std::string c108_bin = bin_path + "/layers/c108.bin"; - std::string c109_bin = bin_path + "/layers/c109.bin"; - std::string c110_bin = bin_path + "/layers/c110.bin"; - std::string c111_bin = bin_path + "/layers/c111.bin"; - std::string c112_bin = bin_path + "/layers/c112.bin"; - std::string c113_bin = bin_path + "/layers/c113.bin"; - std::string c114_bin = bin_path + "/layers/c114.bin"; - std::string c117_bin = bin_path + "/layers/c117.bin"; - std::string c119_bin = bin_path + "/layers/c119.bin"; - std::string c120_bin = bin_path + "/layers/c120.bin"; - std::string c121_bin = bin_path + "/layers/c121.bin"; - std::string c122_bin = bin_path + "/layers/c122.bin"; - std::string c123_bin = bin_path + "/layers/c123.bin"; - std::string c124_bin = bin_path + "/layers/c124.bin"; - std::string c125_bin = bin_path + "/layers/c125.bin"; - std::string c128_bin = bin_path + "/layers/c128.bin"; - std::string c130_bin = bin_path + "/layers/c130.bin"; - std::string c131_bin = bin_path + "/layers/c131.bin"; - std::string c132_bin = bin_path + "/layers/c132.bin"; - std::string c133_bin = bin_path + "/layers/c133.bin"; - std::string c134_bin = bin_path + "/layers/c134.bin"; - std::string c135_bin = bin_path + "/layers/c135.bin"; - std::string c136_bin = bin_path + "/layers/c136.bin"; - std::string g115_bin = bin_path + "/layers/g115.bin"; - std::string g126_bin = bin_path + "/layers/g126.bin"; - std::string g137_bin = bin_path + "/layers/g137.bin"; - - downloadWeightsifDoNotExist(input_bin, bin_path, "https://cloud.hipert.unimore.it/s/Kcs4xBozwY4wFx8/download"); - - tk::dnn::Conv2d c0(&net, 64, 7, 7, 2, 2, 3, 3, c0_bin, true); - tk::dnn::Activation a0(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p1(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c2(&net, 128, 1, 1, 1, 1, 0, 0, c2_bin, true); - tk::dnn::Activation a2(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Layer *r3_layers[1] = {&p1}; - tk::dnn::Route r3(&net, r3_layers, 1); - - tk::dnn::Conv2d c4(&net, 64, 1, 1, 1, 1, 0, 0, c4_bin, true); - tk::dnn::Activation a4(&net, tk::dnn::ACTIVATION_LEAKY); - - // //1-1 - tk::dnn::Conv2d c5(&net, 128, 1, 1, 1, 1, 0, 0, c5_bin, true); - tk::dnn::Activation a5(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c6(&net, 128, 3, 3, 1, 1, 1, 1, c6_bin, true, false, 32, false); - tk::dnn::Activation a6(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c7(&net, 128, 1, 1, 1, 1, 0, 0, c7_bin, true); - - tk::dnn::Shortcut s8(&net, &a4); - tk::dnn::Activation a8(&net, tk::dnn::ACTIVATION_LEAKY); - - //1-2 - tk::dnn::Conv2d c9(&net, 128, 1, 1, 1, 1, 0, 0, c9_bin, true); - tk::dnn::Activation a9(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c10(&net, 128, 3, 3, 1, 1, 1, 1, c10_bin, true, false, 32); - tk::dnn::Activation a10(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c11(&net, 128, 1, 1, 1, 1, 0, 0, c11_bin, true); - - tk::dnn::Shortcut s12(&net, &a8); - tk::dnn::Activation a12(&net, tk::dnn::ACTIVATION_LEAKY); - - //1-3 - tk::dnn::Conv2d c13(&net, 128, 1, 1, 1, 1, 0, 0, c13_bin, true); - tk::dnn::Activation a13(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c14(&net, 128, 3, 3, 1, 1, 1, 1, c14_bin, true, false, 32); - tk::dnn::Activation a14(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c15(&net, 128, 1, 1, 1, 1, 0, 0, c15_bin, true); - - tk::dnn::Shortcut s16(&net, &a12); - tk::dnn::Activation a16(&net, tk::dnn::ACTIVATION_LEAKY); - - // //1-T - tk::dnn::Conv2d c17(&net, 128, 1, 1, 1, 1, 0, 0, c17_bin, true); - tk::dnn::Activation a17(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Layer *r18_layers[2] = {&a17, &a2}; - tk::dnn::Route r18(&net, r18_layers, 2); - - tk::dnn::Conv2d c19(&net, 256, 1, 1, 1, 1, 0, 0, c19_bin, true); - tk::dnn::Activation a19(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c20(&net, 256, 3, 3, 2, 2, 1, 1, c20_bin, true, false, 32); - tk::dnn::Activation a20(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c21(&net, 256, 1, 1, 1, 1, 0, 0, c21_bin, true); - - tk::dnn::Layer *r22_layers[2] = {&a20}; - tk::dnn::Route r22(&net, r22_layers, 1); - - tk::dnn::Conv2d c23(&net, 256, 1, 1, 1, 1, 0, 0, c23_bin, true); - - //2-1 - tk::dnn::Conv2d c24(&net, 256, 1, 1, 1, 1, 0, 0, c24_bin, true); - tk::dnn::Activation a24(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c25(&net, 256, 3, 3, 1, 1, 1, 1, c25_bin, true, false, 32); - tk::dnn::Activation a25(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c26(&net, 256, 1, 1, 1, 1, 0, 0, c26_bin, true); - - tk::dnn::Shortcut s27(&net, &c23); - tk::dnn::Activation a27(&net, tk::dnn::ACTIVATION_LEAKY); - - //2-2 - tk::dnn::Conv2d c28(&net, 256, 1, 1, 1, 1, 0, 0, c28_bin, true); - tk::dnn::Activation a28(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c29(&net, 256, 3, 3, 1, 1, 1, 1, c29_bin, true, false, 32); - tk::dnn::Activation a29(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c30(&net, 256, 1, 1, 1, 1, 0, 0, c30_bin, true); - - tk::dnn::Shortcut s31(&net, &a27); - tk::dnn::Activation a31(&net, tk::dnn::ACTIVATION_LEAKY); - - //2-3 - tk::dnn::Conv2d c32(&net, 256, 1, 1, 1, 1, 0, 0, c32_bin, true); - tk::dnn::Activation a32(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c33(&net, 256, 3, 3, 1, 1, 1, 1, c33_bin, true, false, 32); - tk::dnn::Activation a33(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c34(&net, 256, 1, 1, 1, 1, 0, 0, c34_bin, true); - - tk::dnn::Shortcut s35(&net, &a31); - tk::dnn::Activation a35(&net, tk::dnn::ACTIVATION_LEAKY); - - // //2-T - tk::dnn::Conv2d c36(&net, 256, 1, 1, 1, 1, 0, 0, c36_bin, true); - tk::dnn::Activation a36(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Layer *r37_layers[2] = {&a36, &c21}; - tk::dnn::Route r37(&net, r37_layers, 2); - - tk::dnn::Conv2d c38(&net, 512, 1, 1, 1, 1, 0, 0, c38_bin, true); - tk::dnn::Activation a38(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c39(&net, 512, 3, 3, 2, 2, 1, 1, c39_bin, true, false, 32); - tk::dnn::Activation a39(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c40(&net, 512, 1, 1, 1, 1, 0, 0, c40_bin, true); - - tk::dnn::Layer *r41_layers[2] = {&a39}; - tk::dnn::Route r41(&net, r41_layers, 1); - - tk::dnn::Conv2d c42(&net, 512, 1, 1, 1, 1, 0, 0, c42_bin, true); - - //3-1 - tk::dnn::Conv2d c43(&net, 512, 1, 1, 1, 1, 0, 0, c43_bin, true); - tk::dnn::Activation a43(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c44(&net, 512, 3, 3, 1, 1, 1, 1, c44_bin, true, false, 32); - tk::dnn::Activation a44(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c45(&net, 512, 1, 1, 1, 1, 0, 0, c45_bin, true); - - tk::dnn::Shortcut s46(&net, &c42); - tk::dnn::Activation a46(&net, tk::dnn::ACTIVATION_LEAKY); - - //3-2 - tk::dnn::Conv2d c47(&net, 512, 1, 1, 1, 1, 0, 0, c47_bin, true); - tk::dnn::Activation a47(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c48(&net, 512, 3, 3, 1, 1, 1, 1, c48_bin, true, false, 32); - tk::dnn::Activation a48(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c49(&net, 512, 1, 1, 1, 1, 0, 0, c49_bin, true); - - tk::dnn::Shortcut s50(&net, &a46); - tk::dnn::Activation a50(&net, tk::dnn::ACTIVATION_LEAKY); - - //3-3 - tk::dnn::Conv2d c51(&net, 512, 1, 1, 1, 1, 0, 0, c51_bin, true); - tk::dnn::Activation a51(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c52(&net, 512, 3, 3, 1, 1, 1, 1, c52_bin, true, false, 32); - tk::dnn::Activation a52(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c53(&net, 512, 1, 1, 1, 1, 0, 0, c53_bin, true); - - tk::dnn::Shortcut s54(&net, &a50); - tk::dnn::Activation a54(&net, tk::dnn::ACTIVATION_LEAKY); - - //3-4 - tk::dnn::Conv2d c55(&net, 512, 1, 1, 1, 1, 0, 0, c55_bin, true); - tk::dnn::Activation a55(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c56(&net, 512, 3, 3, 1, 1, 1, 1, c56_bin, true, false, 32); - tk::dnn::Activation a56(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c57(&net, 512, 1, 1, 1, 1, 0, 0, c57_bin, true); - - tk::dnn::Shortcut s58(&net, &a54); - tk::dnn::Activation a58(&net, tk::dnn::ACTIVATION_LEAKY); - - //3-5 - tk::dnn::Conv2d c59(&net, 512, 1, 1, 1, 1, 0, 0, c59_bin, true); - tk::dnn::Activation a59(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c60(&net, 512, 3, 3, 1, 1, 1, 1, c60_bin, true, false, 32); - tk::dnn::Activation a60(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c61(&net, 512, 1, 1, 1, 1, 0, 0, c61_bin, true); - - tk::dnn::Shortcut s62(&net, &a58); - tk::dnn::Activation a62(&net, tk::dnn::ACTIVATION_LEAKY); - - //3-T - tk::dnn::Conv2d c63(&net, 512, 1, 1, 1, 1, 0, 0, c63_bin, true); - tk::dnn::Activation a63(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Layer *r64_layers[2] = {&a63, &c40}; - tk::dnn::Route r64(&net, r64_layers, 2); - - tk::dnn::Conv2d c65(&net, 1024, 1, 1, 1, 1, 0, 0, c65_bin, true); - tk::dnn::Activation a65(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c66(&net, 1024, 3, 3, 2, 2, 1, 1, c66_bin, true, false, 32); - tk::dnn::Activation a66(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c67(&net, 1024, 1, 1, 1, 1, 0, 0, c67_bin, true); - tk::dnn::Activation a67(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Layer *r68_layers[2] = {&a66}; - tk::dnn::Route r68(&net, r68_layers, 1); - - tk::dnn::Conv2d c69(&net, 1024, 1, 1, 1, 1, 0, 0, c69_bin, true); - tk::dnn::Activation a69(&net, tk::dnn::ACTIVATION_LEAKY); - - //4-1 - tk::dnn::Conv2d c70(&net, 1024, 1, 1, 1, 1, 0, 0, c70_bin, true); - tk::dnn::Activation a70(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c71(&net, 1024, 3, 3, 1, 1, 1, 1, c71_bin, true, false, 32); - tk::dnn::Activation a71(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c72(&net, 1024, 1, 1, 1, 1, 0, 0, c72_bin, true); - - tk::dnn::Shortcut s73(&net, &a69); - tk::dnn::Activation a73(&net, tk::dnn::ACTIVATION_LEAKY); - - //4-2 - tk::dnn::Conv2d c74(&net, 1024, 1, 1, 1, 1, 0, 0, c74_bin, true); - tk::dnn::Activation a74(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c75(&net, 1024, 3, 3, 1, 1, 1, 1, c75_bin, true, false, 32); - tk::dnn::Activation a75(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c76(&net, 1024, 1, 1, 1, 1, 0, 0, c76_bin, true); - - tk::dnn::Shortcut s77(&net, &a73); - tk::dnn::Activation a77(&net, tk::dnn::ACTIVATION_LEAKY); - - //4-T - tk::dnn::Conv2d c78(&net, 1024, 1, 1, 1, 1, 0, 0, c78_bin, true); - tk::dnn::Activation a78(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Layer *r79_layers[2] = {&a78, &a67}; - tk::dnn::Route r79(&net, r79_layers, 2); - - tk::dnn::Conv2d c80(&net, 2048, 1, 1, 1, 1, 0, 0, c80_bin, true); - tk::dnn::Activation a80(&net, tk::dnn::ACTIVATION_LEAKY); - - // //////////////////// - - tk::dnn::Conv2d c81(&net, 512, 1, 1, 1, 1, 0, 0, c81_bin, true); - tk::dnn::Activation a81(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c82(&net, 1024, 3, 3, 1, 1, 1, 1, c82_bin, true); - tk::dnn::Activation a82(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c83(&net, 512, 1, 1, 1, 1, 0, 0, c83_bin, true); - tk::dnn::Activation a83(&net, tk::dnn::ACTIVATION_LEAKY); - - //SPP - tk::dnn::Pooling p84(&net, 5, 5, 1, 1, 0, 0, tk::dnn::POOLING_MAX_FIXEDSIZE); - tk::dnn::Layer *r85_layers[1] = {&a83}; - tk::dnn::Route r85(&net, r85_layers, 1); - - tk::dnn::Pooling p86(&net, 9, 9, 1, 1, 0, 0, tk::dnn::POOLING_MAX_FIXEDSIZE); - tk::dnn::Layer *r87_layers[1] = {&a83}; - tk::dnn::Route r87(&net, r87_layers, 1); - - tk::dnn::Pooling p88(&net, 13, 13, 1, 1, 12, 12, tk::dnn::POOLING_MAX_FIXEDSIZE); - tk::dnn::Layer *r89_layers[4] = {&p88, &p86, &p84, &a83}; - tk::dnn::Route r89(&net, r89_layers, 4); - //END SPP - - tk::dnn::Conv2d c90(&net, 512, 1, 1, 1, 1, 0, 0, c90_bin, true); - tk::dnn::Activation a90(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c91(&net, 1024, 3, 3, 1, 1, 1, 1, c91_bin, true); - tk::dnn::Activation a91(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c92(&net, 512, 1, 1, 1, 1, 0, 0, c92_bin, true); - tk::dnn::Activation a92(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c93(&net, 256, 1, 1, 1, 1, 0, 0, c93_bin, true); - tk::dnn::Activation a93(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Upsample u94(&net, 2); - tk::dnn::Layer *r95_layers[1] = {&a65}; - tk::dnn::Route r95(&net, r95_layers, 1); - tk::dnn::Conv2d c96(&net, 256, 1, 1, 1, 1, 0, 0, c96_bin, true); - tk::dnn::Activation a96(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Layer *r97_layers[2] = {&a96,&u94}; - tk::dnn::Route r97(&net, r97_layers, 2); - - tk::dnn::Conv2d c98(&net, 256, 1, 1, 1, 1, 0, 0, c98_bin, true); - tk::dnn::Activation a98(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c99(&net, 512, 3, 3, 1, 1, 1, 1, c99_bin, true); - tk::dnn::Activation a99(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c100(&net, 256, 1, 1, 1, 1, 0, 0, c100_bin, true); - tk::dnn::Activation a100(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c101(&net, 512, 3, 3, 1, 1, 1, 1, c101_bin, true); - tk::dnn::Activation a101(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c102(&net, 256, 1, 1, 1, 1, 0, 0, c102_bin, true); - tk::dnn::Activation a102(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c103(&net, 128, 1, 1, 1, 1, 0, 0, c103_bin, true); - tk::dnn::Activation a103(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Upsample u104(&net, 2); - tk::dnn::Layer *r105_layers[1] = {&a38}; - tk::dnn::Route r105(&net, r105_layers, 1); - tk::dnn::Conv2d c106(&net, 128, 1, 1, 1, 1, 0, 0, c106_bin, true); - tk::dnn::Activation a106(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Layer *r107_layers[2] = {&a106,&u104}; - tk::dnn::Route r107(&net, r107_layers, 2); - - - tk::dnn::Conv2d c108(&net, 128, 1, 1, 1, 1, 0, 0, c108_bin, true); - tk::dnn::Activation a108(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c109(&net, 256, 3, 3, 1, 1, 1, 1, c109_bin, true); - tk::dnn::Activation a109(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c110(&net, 128, 1, 1, 1, 1, 0, 0, c110_bin, true); - tk::dnn::Activation a110(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c111(&net, 256, 3, 3, 1, 1, 1, 1, c111_bin, true); - tk::dnn::Activation a111(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c112(&net, 128, 1, 1, 1, 1, 0, 0, c112_bin, true); - tk::dnn::Activation a112(&net, tk::dnn::ACTIVATION_LEAKY); - - // ########################### - - tk::dnn::Conv2d c113(&net, 256, 3, 3, 1, 1, 1, 1, c113_bin, true); - tk::dnn::Activation a113(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c114(&net, 255, 1, 1, 1, 1, 0, 0, c114_bin, false); - tk::dnn::Yolo yolo115(&net, classes, 3, g115_bin); - - tk::dnn::Layer *r116_layers[1] = {&a112}; - tk::dnn::Route r116(&net, r116_layers, 1); - tk::dnn::Conv2d c117(&net, 256, 3, 3, 2, 2, 1, 1, c117_bin, true); - tk::dnn::Activation a117(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Layer *r118_layers[2] = {&a117,&a102}; - tk::dnn::Route r118(&net, r118_layers, 2); - - tk::dnn::Conv2d c119(&net, 256, 1, 1, 1, 1, 0, 0, c119_bin, true); - tk::dnn::Activation a119(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c120(&net, 512, 3, 3, 1, 1, 1, 1, c120_bin, true); - tk::dnn::Activation a120(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c121(&net, 256, 1, 1, 1, 1, 0, 0, c121_bin, true); - tk::dnn::Activation a121(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c122(&net, 512, 3, 3, 1, 1, 1, 1, c122_bin, true); - tk::dnn::Activation a122(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c123(&net, 256, 1, 1, 1, 1, 0, 0, c123_bin, true); - tk::dnn::Activation a123(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Conv2d c124(&net, 512, 3, 3, 1, 1, 1, 1, c124_bin, true); - tk::dnn::Activation a124(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c125(&net, 255, 1, 1, 1, 1, 0, 0, c125_bin, false); - tk::dnn::Yolo yolo126(&net, classes, 3, g126_bin); - - tk::dnn::Layer *r127_layers[1] = {&a123}; - tk::dnn::Route r127(&net, r127_layers, 1); - tk::dnn::Conv2d c128(&net, 512, 3, 3, 2, 2, 1, 1, c128_bin, true); - tk::dnn::Activation a128(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Layer *r129_layers[2] = {&a128,&a92}; - tk::dnn::Route r129(&net, r129_layers, 2); - - tk::dnn::Conv2d c130(&net, 512, 1, 1, 1, 1, 0, 0, c130_bin, true); - tk::dnn::Activation a130(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c131(&net, 1024, 3, 3, 1, 1, 1, 1, c131_bin, true); - tk::dnn::Activation a131(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c132(&net, 512, 1, 1, 1, 1, 0, 0, c132_bin, true); - tk::dnn::Activation a132(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c133(&net, 1024, 3, 3, 1, 1, 1, 1, c133_bin, true); - tk::dnn::Activation a133(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c134(&net, 512, 1, 1, 1, 1, 0, 0, c134_bin, true); - tk::dnn::Activation a134(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Conv2d c135(&net, 1024, 3, 3, 1, 1, 1, 1, c135_bin, true); - tk::dnn::Activation a135(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c136(&net, 255, 1, 1, 1, 1, 0, 0, c136_bin, false); - tk::dnn::Yolo yolo137(&net, classes, 3, g137_bin); - - yolo[0] = &yolo115; - yolo[1] = &yolo126; - yolo[2] = &yolo137; - - // fill classes names - for (int i = 0; i < 3; i++) - { - yolo[i]->classesNames = {"person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck", "boat", "traffic light", "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow", "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee", "skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard", "tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple", "sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "sofa", "pottedplant", "bed", "diningtable", "toilet", "tvmonitor", "laptop", "mouse", "remote", "keyboard", "cell phone", "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear", "hair drier", "toothbrush"}; - } - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - // //convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("csresnext50-panet-spp")); - - // the network have 3 outputs - tk::dnn::dataDim_t out_dim[3]; - for (int i = 0; i < 3; i++) - out_dim[i] = yolo[i]->output_dim; - dnnType *cudnn_out[3], *rt_out[3]; - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); - { - dim1.print(); - TIMER_START - net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - - for (int i = 0; i < 3; i++) - cudnn_out[i] = yolo[i]->dstData; - - printCenteredTitle(" compute detections ", '=', 30); - TIMER_START - int ndets = 0; - tk::dnn::Yolo::detection *dets = tk::dnn::Yolo::allocateDetections(tk::dnn::Yolo::MAX_DETECTIONS, classes); - for (int i = 0; i < 3; i++) - yolo[i]->computeDetections(dets, ndets, net.input_dim.w, net.input_dim.h, 0.5); - tk::dnn::Yolo::mergeDetections(dets, ndets, classes); - - for (int j = 0; j < ndets; j++) - { - tk::dnn::Yolo::box b = dets[j].bbox; - int x0 = (b.x - b.w / 2.); - int x1 = (b.x + b.w / 2.); - int y0 = (b.y - b.h / 2.); - int y1 = (b.y + b.h / 2.); - - int cl = 0; - for (int c = 0; c < classes; ++c) - { - float prob = dets[j].prob[c]; - if (prob > 0) - cl = c; - } - std::cout << cl << ": " << x0 << " " << y0 << " " << x1 << " " << y1 << "\n"; - } - TIMER_STOP - - tk::dnn::dataDim_t dim2 = dim; - printCenteredTitle(" TENSORRT inference ", '=', 30); - { - dim2.print(); - TIMER_START - netRT.infer(dim2, data); - TIMER_STOP - dim2.print(); - } - - for (int i = 0; i < 3; i++) - rt_out[i] = (dnnType *)netRT.buffersRT[i + 1]; - - int ret_cudnn = 0, ret_tensorrt = 0, ret_cudnn_tensorrt = 0; - for (int i = 0; i < 3; i++) - { - printCenteredTitle((std::string(" YOLO ") + std::to_string(i) + " CHECK RESULTS ").c_str(), '=', 30); - dnnType *out, *out_h; - int odim = out_dim[i].tot(); - readBinaryFile(output_bins[i], odim, &out_h, &out); - std::cout<<"CUDNN vs correct"; - ret_cudnn |= checkResult(odim, cudnn_out[i], out) == 0 ? 0: ERROR_CUDNN; - std::cout<<"TRT vs correct"; - ret_tensorrt |= checkResult(odim, rt_out[i], out) == 0 ? 0 : ERROR_TENSORRT; - std::cout<<"CUDNN vs TRT "; - ret_cudnn_tensorrt |= checkResult(odim, cudnn_out[i], rt_out[i]) == 0 ? 0 : ERROR_CUDNNvsTENSORRT; - } - return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; -} diff --git a/tests/csresnext50-panet-spp/csresnext50-panet-spp.cfg b/tests/darknet/cfg/csresnext50-panet-spp.cfg similarity index 100% rename from tests/csresnext50-panet-spp/csresnext50-panet-spp.cfg rename to tests/darknet/cfg/csresnext50-panet-spp.cfg diff --git a/tests/bdd-csresnext50-panet-spp/berkeleycsresnetx50.cfg b/tests/darknet/cfg/csresnext50-panet-spp_berkeley.cfg similarity index 100% rename from tests/bdd-csresnext50-panet-spp/berkeleycsresnetx50.cfg rename to tests/darknet/cfg/csresnext50-panet-spp_berkeley.cfg diff --git a/tests/yolo/yolo.cfg b/tests/darknet/cfg/yolo2.cfg similarity index 100% rename from tests/yolo/yolo.cfg rename to tests/darknet/cfg/yolo2.cfg diff --git a/tests/yolo_voc/yolo_voc.cfg b/tests/darknet/cfg/yolo2_voc.cfg similarity index 100% rename from tests/yolo_voc/yolo_voc.cfg rename to tests/darknet/cfg/yolo2_voc.cfg diff --git a/tests/yolo_tiny/tiny-yolo.cfg b/tests/darknet/cfg/yolo2tiny.cfg similarity index 100% rename from tests/yolo_tiny/tiny-yolo.cfg rename to tests/darknet/cfg/yolo2tiny.cfg diff --git a/tests/yolo3/yolov3.cfg b/tests/darknet/cfg/yolo3.cfg similarity index 100% rename from tests/yolo3/yolov3.cfg rename to tests/darknet/cfg/yolo3.cfg diff --git a/tests/yolo3_512tp/yolo3512.cfg b/tests/darknet/cfg/yolo3_512.cfg similarity index 93% rename from tests/yolo3_512tp/yolo3512.cfg rename to tests/darknet/cfg/yolo3_512.cfg index 00ea6e9..032d49a 100644 --- a/tests/yolo3_512tp/yolo3512.cfg +++ b/tests/darknet/cfg/yolo3_512.cfg @@ -1,10 +1,10 @@ [net] # Testing -#batch=1 -#subdivisions=1 +# batch=1 +# subdivisions=1 # Training -batch=16 -subdivisions=1 +batch=32 +subdivisions=32 width=512 height=512 channels=3 @@ -600,14 +600,14 @@ activation=leaky size=1 stride=1 pad=1 -filters=24 +filters=255 activation=linear [yolo] mask = 6,7,8 -anchors = 10.256,16.494, 11.724,18.558, 17.678,16.437, 25.619,14.985, 46.845,79.02, 58.643,81.204, 23.646,208.56, 30.837,211.57, 37.921,211.16 -classes=3 +anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326 +classes=80 num=9 jitter=.3 ignore_thresh = .7 @@ -633,6 +633,7 @@ stride=2 layers = -1, 61 + [convolutional] batch_normalize=1 filters=256 @@ -685,14 +686,14 @@ activation=leaky size=1 stride=1 pad=1 -filters=24 +filters=255 activation=linear [yolo] mask = 3,4,5 -anchors = 10.256,16.494, 11.724,18.558, 17.678,16.437, 25.619,14.985, 46.845,79.02, 58.643,81.204, 23.646,208.56, 30.837,211.57, 37.921,211.16 -classes=3 +anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326 +classes=80 num=9 jitter=.3 ignore_thresh = .7 @@ -772,16 +773,17 @@ activation=leaky size=1 stride=1 pad=1 -filters=24 +filters=255 activation=linear [yolo] mask = 0,1,2 -anchors = 10.256,16.494, 11.724,18.558, 17.678,16.437, 25.619,14.985, 46.845,79.02, 58.643,81.204, 23.646,208.56, 30.837,211.57, 37.921,211.16 -classes=3 +anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326 +classes=80 num=9 jitter=.3 ignore_thresh = .7 truth_thresh = 1 random=1 + diff --git a/tests/yolo3_berkeley/yolo3_berkeley.cfg b/tests/darknet/cfg/yolo3_berkeley.cfg similarity index 100% rename from tests/yolo3_berkeley/yolo3_berkeley.cfg rename to tests/darknet/cfg/yolo3_berkeley.cfg diff --git a/tests/yolo3_coco4/yolov3-coco4.cfg b/tests/darknet/cfg/yolo3_coco4.cfg similarity index 100% rename from tests/yolo3_coco4/yolov3-coco4.cfg rename to tests/darknet/cfg/yolo3_coco4.cfg diff --git a/tests/yolo3_flir/yolo3_flir.cfg b/tests/darknet/cfg/yolo3_flir.cfg similarity index 100% rename from tests/yolo3_flir/yolo3_flir.cfg rename to tests/darknet/cfg/yolo3_flir.cfg diff --git a/tests/yolo3_tiny/yolov3-tiny.cfg b/tests/darknet/cfg/yolo3tiny.cfg similarity index 100% rename from tests/yolo3_tiny/yolov3-tiny.cfg rename to tests/darknet/cfg/yolo3tiny.cfg diff --git a/tests/yolo3_tiny512tp/yolo3tiny512.cfg b/tests/darknet/cfg/yolo3tiny_512.cfg similarity index 87% rename from tests/yolo3_tiny512tp/yolo3tiny512.cfg rename to tests/darknet/cfg/yolo3tiny_512.cfg index baecead..049a3a6 100644 --- a/tests/yolo3_tiny512tp/yolo3tiny512.cfg +++ b/tests/darknet/cfg/yolo3tiny_512.cfg @@ -124,15 +124,15 @@ activation=leaky size=1 stride=1 pad=1 -filters=24 +filters=255 activation=linear [yolo] mask = 3,4,5 -anchors = 10.638,16.801, 13.183,19.091, 24.568,12.24, 54.462,77.421, 29.199,210.49, 37.495,212.21 -classes=3 +anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319 +classes=80 num=6 jitter=.3 ignore_thresh = .7 @@ -168,13 +168,13 @@ activation=leaky size=1 stride=1 pad=1 -filters=24 +filters=255 activation=linear [yolo] mask = 0,1,2 -anchors = 10.638,16.801, 13.183,19.091, 24.568,12.24, 54.462,77.421, 29.199,210.49, 37.495,212.21 -classes=3 +anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319 +classes=80 num=6 jitter=.3 ignore_thresh = .7 diff --git a/tests/yolo4/yolov4.cfg b/tests/darknet/cfg/yolo4.cfg similarity index 100% rename from tests/yolo4/yolov4.cfg rename to tests/darknet/cfg/yolo4.cfg diff --git a/tests/darknet/csresnext50-panet-spp.cpp b/tests/darknet/csresnext50-panet-spp.cpp new file mode 100644 index 0000000..f2f66f6 --- /dev/null +++ b/tests/darknet/csresnext50-panet-spp.cpp @@ -0,0 +1,33 @@ +#include +#include +#include "tkdnn.h" +#include "test.h" +#include "DarknetParser.h" + +int main() { + std::string bin_path = "csresnext50-panet-spp"; + std::vector input_bins = { + bin_path + "/layers/input.bin" + }; + std::vector output_bins = { + bin_path + "/debug/layer115_out.bin", + bin_path + "/debug/layer126_out.bin", + bin_path + "/debug/layer137_out.bin" + }; + std::string wgs_path = bin_path + "/layers"; + std::string cfg_path = "../tests/darknet/cfg/csresnext50-panet-spp.cfg"; + std::string name_path = "../tests/darknet/names/coco.names"; + downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/Kcs4xBozwY4wFx8/download"); + + // parse darknet network + tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path); + net->print(); + + //convert network to tensorRT + tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str())); + + int ret = testInference(input_bins, output_bins, net, netRT); + delete net; + delete netRT; + return ret; +} diff --git a/tests/darknet/csresnext50-panet-spp_berkeley.cpp b/tests/darknet/csresnext50-panet-spp_berkeley.cpp new file mode 100644 index 0000000..ca21399 --- /dev/null +++ b/tests/darknet/csresnext50-panet-spp_berkeley.cpp @@ -0,0 +1,33 @@ +#include +#include +#include "tkdnn.h" +#include "test.h" +#include "DarknetParser.h" + +int main() { + std::string bin_path = "bdd-csresnext50-panet-spp"; + std::vector input_bins = { + bin_path + "/layers/input.bin" + }; + std::vector output_bins = { + bin_path + "/debug/layer115_out.bin", + bin_path + "/debug/layer126_out.bin", + bin_path + "/debug/layer137_out.bin" + }; + std::string wgs_path = bin_path + "/layers"; + std::string cfg_path = "../tests/darknet/cfg/csresnext50-panet-spp_berkeley.cfg"; + std::string name_path = "../tests/darknet/names/berkeley.names"; + // downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s//download"); + + // parse darknet network + tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path); + net->print(); + + //convert network to tensorRT + tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str())); + + int ret = testInference(input_bins, output_bins, net, netRT); + delete net; + delete netRT; + return ret; +} diff --git a/tests/yolo3/berkeley.names b/tests/darknet/names/berkeley.names similarity index 100% rename from tests/yolo3/berkeley.names rename to tests/darknet/names/berkeley.names diff --git a/tests/yolo3/coco.names b/tests/darknet/names/coco.names similarity index 100% rename from tests/yolo3/coco.names rename to tests/darknet/names/coco.names diff --git a/tests/darknet/names/coco4.names b/tests/darknet/names/coco4.names new file mode 100644 index 0000000..82cb5c4 --- /dev/null +++ b/tests/darknet/names/coco4.names @@ -0,0 +1,4 @@ +person +bicycle +car +motorbike diff --git a/tests/darknet/names/flir.names b/tests/darknet/names/flir.names new file mode 100644 index 0000000..03f4d8a --- /dev/null +++ b/tests/darknet/names/flir.names @@ -0,0 +1,3 @@ +person +bike +car diff --git a/tests/yolo3/voc.names b/tests/darknet/names/voc.names similarity index 100% rename from tests/yolo3/voc.names rename to tests/darknet/names/voc.names diff --git a/tests/darknet/yolo2.cpp b/tests/darknet/yolo2.cpp new file mode 100644 index 0000000..e6b40a5 --- /dev/null +++ b/tests/darknet/yolo2.cpp @@ -0,0 +1,31 @@ +#include +#include +#include "tkdnn.h" +#include "test.h" +#include "DarknetParser.h" + +int main() { + std::string bin_path = "yolo2"; + std::vector input_bins = { + bin_path + "/layers/input.bin" + }; + std::vector output_bins = { + bin_path + "layers/output.bin" + }; + std::string wgs_path = bin_path + "/layers"; + std::string cfg_path = "../tests/darknet/cfg/yolo2.cfg"; + std::string name_path = "../tests/darknet/names/coco.names"; + downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/nf4PJ3k8bxBETwL/download"); + + // parse darknet network + tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path); + net->print(); + + //convert network to tensorRT + tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str())); + + int ret = testInference(input_bins, output_bins, net, netRT); + delete net; + delete netRT; + return ret; +} diff --git a/tests/darknet/yolo2_voc.cpp b/tests/darknet/yolo2_voc.cpp new file mode 100644 index 0000000..2efcbcb --- /dev/null +++ b/tests/darknet/yolo2_voc.cpp @@ -0,0 +1,32 @@ +#include +#include +#include "tkdnn.h" +#include "test.h" +#include "DarknetParser.h" + +int main() { + std::string bin_path = "yolo2_voc"; + std::vector input_bins = { + bin_path + "/layers/input.bin" + }; + std::vector output_bins = { + bin_path + "/layers/output.bin" + }; + std::string wgs_path = bin_path + "/layers"; + std::string cfg_path = "../tests/darknet/cfg/yolo2_voc.cfg"; + std::string name_path = "../tests/darknet/names/voc.names"; + downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/DJC5Fi2pEjfNDP9/download"); + + // parse darknet network + tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path); + net->print(); + + //convert network to tensorRT + tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str())); + + int ret = testInference(input_bins, output_bins, net, netRT); + delete net; + delete netRT; + return ret; +} + diff --git a/tests/darknet/yolo2tiny.cpp b/tests/darknet/yolo2tiny.cpp new file mode 100644 index 0000000..fefdaa5 --- /dev/null +++ b/tests/darknet/yolo2tiny.cpp @@ -0,0 +1,31 @@ +#include +#include +#include "tkdnn.h" +#include "test.h" +#include "DarknetParser.h" + +int main() { + std::string bin_path = "yolo2tiny"; + std::vector input_bins = { + bin_path + "/layers/input.bin" + }; + std::vector output_bins = { + bin_path + "layers/output.bin" + }; + std::string wgs_path = bin_path + "/layers"; + std::string cfg_path = "../tests/darknet/cfg/yolo2tiny.cfg"; + std::string name_path = "../tests/darknet/names/coco.names"; + downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/nf4PJ3k8bxBETwL/download"); + + // parse darknet network + tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path); + net->print(); + + //convert network to tensorRT + tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str())); + + int ret = testInference(input_bins, output_bins, net, netRT); + delete net; + delete netRT; + return ret; +} diff --git a/tests/darknet/yolo3.cpp b/tests/darknet/yolo3.cpp new file mode 100644 index 0000000..b96d79a --- /dev/null +++ b/tests/darknet/yolo3.cpp @@ -0,0 +1,33 @@ +#include +#include +#include "tkdnn.h" +#include "test.h" +#include "DarknetParser.h" + +int main() { + std::string bin_path = "yolo3"; + std::vector input_bins = { + bin_path + "/layers/input.bin" + }; + std::vector output_bins = { + bin_path + "/debug/layer82_out.bin", + bin_path + "/debug/layer94_out.bin", + bin_path + "/debug/layer106_out.bin" + }; + std::string wgs_path = bin_path + "/layers"; + std::string cfg_path = "../tests/darknet/cfg/yolo3.cfg"; + std::string name_path = "../tests/darknet/names/coco.names"; + downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/jPXmHyptpLoNdNR/download"); + + // parse darknet network + tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path); + net->print(); + + //convert network to tensorRT + tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str())); + + int ret = testInference(input_bins, output_bins, net, netRT); + delete net; + delete netRT; + return ret; +} diff --git a/tests/darknet/yolo3_512.cpp b/tests/darknet/yolo3_512.cpp new file mode 100644 index 0000000..11a7839 --- /dev/null +++ b/tests/darknet/yolo3_512.cpp @@ -0,0 +1,33 @@ +#include +#include +#include "tkdnn.h" +#include "test.h" +#include "DarknetParser.h" + +int main() { + std::string bin_path = "yolo3_512"; + std::vector input_bins = { + bin_path + "/layers/input.bin" + }; + std::vector output_bins = { + bin_path + "/debug/layer82_out.bin", + bin_path + "/debug/layer94_out.bin", + bin_path + "/debug/layer106_out.bin" + }; + std::string wgs_path = bin_path + "/layers"; + std::string cfg_path = "../tests/darknet/cfg/yolo3_512.cfg"; + std::string name_path = "../tests/darknet/names/coco.names"; + downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/RGecMeGLD4cXEWL/download"); + + // parse darknet network + tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path); + net->print(); + + //convert network to tensorRT + tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str())); + + int ret = testInference(input_bins, output_bins, net, netRT); + delete net; + delete netRT; + return ret; +} diff --git a/tests/darknet/yolo3_berkeley.cpp b/tests/darknet/yolo3_berkeley.cpp new file mode 100644 index 0000000..6c3512c --- /dev/null +++ b/tests/darknet/yolo3_berkeley.cpp @@ -0,0 +1,33 @@ +#include +#include +#include "tkdnn.h" +#include "test.h" +#include "DarknetParser.h" + +int main() { + std::string bin_path = "yolo3_berkeley"; + std::vector input_bins = { + bin_path + "/layers/input.bin" + }; + std::vector output_bins = { + bin_path + "/debug/layer82_out.bin", + bin_path + "/debug/layer94_out.bin", + bin_path + "/debug/layer106_out.bin" + }; + std::string wgs_path = bin_path + "/layers"; + std::string cfg_path = "../tests/darknet/cfg/yolo3_berkeley.cfg"; + std::string name_path = "../tests/darknet/names/barkeley.names"; + downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/o5cHa4AjTKS64oD/download"); + + // parse darknet network + tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path); + net->print(); + + //convert network to tensorRT + tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str())); + + int ret = testInference(input_bins, output_bins, net, netRT); + delete net; + delete netRT; + return ret; +} diff --git a/tests/darknet/yolo3_coco4.cpp b/tests/darknet/yolo3_coco4.cpp new file mode 100644 index 0000000..cf69a26 --- /dev/null +++ b/tests/darknet/yolo3_coco4.cpp @@ -0,0 +1,33 @@ +#include +#include +#include "tkdnn.h" +#include "test.h" +#include "DarknetParser.h" + +int main() { + std::string bin_path = "yolo3_coco4"; + std::vector input_bins = { + bin_path + "/layers/input.bin" + }; + std::vector output_bins = { + bin_path + "/debug/layer82_out.bin", + bin_path + "/debug/layer94_out.bin", + bin_path + "/debug/layer106_out.bin" + }; + std::string wgs_path = bin_path + "/layers"; + std::string cfg_path = "../tests/darknet/cfg/yolo3_coco4.cfg"; + std::string name_path = "../tests/darknet/names/coco4.names"; + downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/o27NDzSAartbyc4/download"); + + // parse darknet network + tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path); + net->print(); + + //convert network to tensorRT + tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str())); + + int ret = testInference(input_bins, output_bins, net, netRT); + delete net; + delete netRT; + return ret; +} diff --git a/tests/darknet/yolo3_flir.cpp b/tests/darknet/yolo3_flir.cpp new file mode 100644 index 0000000..fd5c1d5 --- /dev/null +++ b/tests/darknet/yolo3_flir.cpp @@ -0,0 +1,33 @@ +#include +#include +#include "tkdnn.h" +#include "test.h" +#include "DarknetParser.h" + +int main() { + std::string bin_path = "yolo3_flir"; + std::vector input_bins = { + bin_path + "/layers/input.bin" + }; + std::vector output_bins = { + bin_path + "/debug/layer82_out.bin", + bin_path + "/debug/layer94_out.bin", + bin_path + "/debug/layer106_out.bin" + }; + std::string wgs_path = bin_path + "/layers"; + std::string cfg_path = "../tests/darknet/cfg/yolo3_flir.cfg"; + std::string name_path = "../tests/darknet/names/flir.names"; + downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/62DECncmF6bMMiH/download"); + + // parse darknet network + tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path); + net->print(); + + //convert network to tensorRT + tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str())); + + int ret = testInference(input_bins, output_bins, net, netRT); + delete net; + delete netRT; + return ret; +} diff --git a/tests/darknet/yolo3tiny.cpp b/tests/darknet/yolo3tiny.cpp new file mode 100644 index 0000000..247b152 --- /dev/null +++ b/tests/darknet/yolo3tiny.cpp @@ -0,0 +1,31 @@ +#include +#include +#include "tkdnn.h" +#include "test.h" +#include "DarknetParser.h" + +int main() { + std::string bin_path = "yolo3tiny"; + std::vector input_bins = { + bin_path + "/layers/input.bin" + }; + std::vector output_bins = { + bin_path + "debug/layer23_out.bin", + }; + std::string wgs_path = bin_path + "/layers"; + std::string cfg_path = "../tests/darknet/cfg/yolo3tiny.cfg"; + std::string name_path = "../tests/darknet/names/coco.names"; + downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/LMcSHtWaLeps8yN/download"); + + // parse darknet network + tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path); + net->print(); + + //convert network to tensorRT + tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str())); + + int ret = testInference(input_bins, output_bins, net, netRT); + delete net; + delete netRT; + return ret; +} diff --git a/tests/darknet/yolo3tiny512.cpp b/tests/darknet/yolo3tiny512.cpp new file mode 100644 index 0000000..495033a --- /dev/null +++ b/tests/darknet/yolo3tiny512.cpp @@ -0,0 +1,31 @@ +#include +#include +#include "tkdnn.h" +#include "test.h" +#include "DarknetParser.h" + +int main() { + std::string bin_path = "yolo3tiny_512"; + std::vector input_bins = { + bin_path + "/layers/input.bin" + }; + std::vector output_bins = { + bin_path + "debug/layer23_out.bin", + }; + std::string wgs_path = bin_path + "/layers"; + std::string cfg_path = "../tests/darknet/cfg/yolo3tiny_512.cfg"; + std::string name_path = "../tests/darknet/names/coco.names"; + downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/8Zt6bHwHADqP4JC/download"); + + // parse darknet network + tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path); + net->print(); + + //convert network to tensorRT + tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str())); + + int ret = testInference(input_bins, output_bins, net, netRT); + delete net; + delete netRT; + return ret; +} diff --git a/tests/darknet/yolo4.cpp b/tests/darknet/yolo4.cpp new file mode 100644 index 0000000..70257d2 --- /dev/null +++ b/tests/darknet/yolo4.cpp @@ -0,0 +1,33 @@ +#include +#include +#include "tkdnn.h" +#include "test.h" +#include "DarknetParser.h" + +int main() { + std::string bin_path = "yolo4"; + std::vector input_bins = { + bin_path + "/layers/input.bin" + }; + std::vector output_bins = { + bin_path + "/debug/layer139_out.bin", + bin_path + "/debug/layer150_out.bin", + bin_path + "/debug/layer161_out.bin" + }; + std::string wgs_path = bin_path + "/layers"; + std::string cfg_path = "../tests/darknet/cfg/yolo4.cfg"; + std::string name_path = "../tests/darknet/names/coco.names"; + downloadWeightsifDoNotExist(input_bins[0], bin_path, "https://cloud.hipert.unimore.it/s/d97CFzYqCPCp5Hg/download"); + + // parse darknet network + tk::dnn::Network *net = tk::dnn::darknetParser(cfg_path, wgs_path, name_path); + net->print(); + + //convert network to tensorRT + tk::dnn::NetworkRT *netRT = new tk::dnn::NetworkRT(net, net->getNetworkRTName(bin_path.c_str())); + + int ret = testInference(input_bins, output_bins, net, netRT); + delete net; + delete netRT; + return ret; +} diff --git a/tests/caffe_weights_exporter.py b/tests/exporters/caffe_weights_exporter.py similarity index 100% rename from tests/caffe_weights_exporter.py rename to tests/exporters/caffe_weights_exporter.py diff --git a/tests/weights_exporter.py b/tests/exporters/keras_weights_exporter.py similarity index 100% rename from tests/weights_exporter.py rename to tests/exporters/keras_weights_exporter.py diff --git a/tests/bdd-mobilenetv2ssd/bdd-mobilenetv2ssd.cpp b/tests/mobilenet/bdd-mobilenetv2ssd/bdd-mobilenetv2ssd.cpp similarity index 100% rename from tests/bdd-mobilenetv2ssd/bdd-mobilenetv2ssd.cpp rename to tests/mobilenet/bdd-mobilenetv2ssd/bdd-mobilenetv2ssd.cpp diff --git a/tests/mobilenetv2ssd/mobilenetv2ssd.cpp b/tests/mobilenet/mobilenetv2ssd/mobilenetv2ssd.cpp similarity index 100% rename from tests/mobilenetv2ssd/mobilenetv2ssd.cpp rename to tests/mobilenet/mobilenetv2ssd/mobilenetv2ssd.cpp diff --git a/tests/mobilenetv2ssd512/mobilenetv2ssd512.cpp b/tests/mobilenet/mobilenetv2ssd512/mobilenetv2ssd512.cpp similarity index 100% rename from tests/mobilenetv2ssd512/mobilenetv2ssd512.cpp rename to tests/mobilenet/mobilenetv2ssd512/mobilenetv2ssd512.cpp diff --git a/tests/yolo/yolo.cpp b/tests/yolo/yolo.cpp deleted file mode 100644 index e47fd8f..0000000 --- a/tests/yolo/yolo.cpp +++ /dev/null @@ -1,157 +0,0 @@ -#include -#include "tkdnn.h" - -const char *input_bin = "yolo/layers/input.bin"; -const char *c0_bin = "yolo/layers/c0.bin"; -const char *c2_bin = "yolo/layers/c2.bin"; -const char *c4_bin = "yolo/layers/c4.bin"; -const char *c5_bin = "yolo/layers/c5.bin"; -const char *c6_bin = "yolo/layers/c6.bin"; -const char *c8_bin = "yolo/layers/c8.bin"; -const char *c9_bin = "yolo/layers/c9.bin"; -const char *c10_bin = "yolo/layers/c10.bin"; -const char *c12_bin = "yolo/layers/c12.bin"; -const char *c13_bin = "yolo/layers/c13.bin"; -const char *c14_bin = "yolo/layers/c14.bin"; -const char *c15_bin = "yolo/layers/c15.bin"; -const char *c16_bin = "yolo/layers/c16.bin"; -const char *c18_bin = "yolo/layers/c18.bin"; -const char *c19_bin = "yolo/layers/c19.bin"; -const char *c20_bin = "yolo/layers/c20.bin"; -const char *c21_bin = "yolo/layers/c21.bin"; -const char *c22_bin = "yolo/layers/c22.bin"; -const char *c23_bin = "yolo/layers/c23.bin"; -const char *c24_bin = "yolo/layers/c24.bin"; -const char *c26_bin = "yolo/layers/c26.bin"; -const char *c29_bin = "yolo/layers/c29.bin"; -const char *c30_bin = "yolo/layers/c30.bin"; -const char *g31_bin = "yolo/layers/g31.bin"; -const char *output_bin = "yolo/layers/output.bin"; - -int main() { - - downloadWeightsifDoNotExist(input_bin, "yolo", "https://cloud.hipert.unimore.it/s/nf4PJ3k8bxBETwL/download"); - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 608, 608, 1); - tk::dnn::Network net(dim); - - tk::dnn::Conv2d c0 (&net, 32, 3, 3, 1, 1, 1, 1, c0_bin, true); - tk::dnn::Activation a0 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p1 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c2 (&net, 64, 3, 3, 1, 1, 1, 1, c2_bin, true); - tk::dnn::Activation a2 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p3 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c4 (&net, 128, 3, 3, 1, 1, 1, 1, c4_bin, true); - tk::dnn::Activation a4 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c5 (&net, 64, 1, 1, 1, 1, 0, 0, c5_bin, true); - tk::dnn::Activation a5 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c6 (&net, 128, 3, 3, 1, 1, 1, 1, c6_bin, true); - tk::dnn::Activation a6 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p7 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c8 (&net, 256, 3, 3, 1, 1, 1, 1, c8_bin, true); - tk::dnn::Activation a8 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c9 (&net, 128, 1, 1, 1, 1, 0, 0, c9_bin, true); - tk::dnn::Activation a9 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c10(&net, 256, 3, 3, 1, 1, 1, 1, c10_bin, true); - tk::dnn::Activation a10(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p11(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c12(&net, 512, 3, 3, 1, 1, 1, 1, c12_bin, true); - tk::dnn::Activation a12(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c13(&net, 256, 1, 1, 1, 1, 0, 0, c13_bin, true); - tk::dnn::Activation a13(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c14(&net, 512, 3, 3, 1, 1, 1, 1, c14_bin, true); - tk::dnn::Activation a14(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c15(&net, 256, 1, 1, 1, 1, 0, 0, c15_bin, true); - tk::dnn::Activation a15(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c16(&net, 512, 3, 3, 1, 1, 1, 1, c16_bin, true); - tk::dnn::Activation a16(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p17(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c18(&net, 1024, 3, 3, 1, 1, 1, 1, c18_bin, true); - tk::dnn::Activation a18(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c19(&net, 512, 1, 1, 1, 1, 0, 0, c19_bin, true); - tk::dnn::Activation a19(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c20(&net, 1024, 3, 3, 1, 1, 1, 1, c20_bin, true); - tk::dnn::Activation a20(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c21(&net, 512, 1, 1, 1, 1, 0, 0, c21_bin, true); - tk::dnn::Activation a21(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c22(&net, 1024, 3, 3, 1, 1, 1, 1, c22_bin, true); - tk::dnn::Activation a22(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c23(&net, 1024, 3, 3, 1, 1, 1, 1, c23_bin, true); - tk::dnn::Activation a23(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c24(&net, 1024, 3, 3, 1, 1, 1, 1, c24_bin, true); - tk::dnn::Activation a24(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Layer *m25_layers[1] = { &a16 }; - tk::dnn::Route m25(&net, m25_layers, 1); - tk::dnn::Conv2d c26(&net, 64, 1, 1, 1, 1, 0, 0, c26_bin, true); - tk::dnn::Activation a26(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Reorg r27(&net, 2); - - tk::dnn::Layer *m28_layers[2] = { &r27, &a24 }; - tk::dnn::Route m28(&net, m28_layers, 2); - - tk::dnn::Conv2d c29(&net, 1024, 3, 3, 1, 1, 1, 1, c29_bin, true); - tk::dnn::Activation a29(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c30(&net, 425, 1, 1, 1, 1, 0, 0, c30_bin, false); - tk::dnn::Region g31(&net, 80, 4, 5); - - tk::dnn::RegionInterpret rI(dim, g31.output_dim, 80, 4, 5, 0.6f, g31_bin); - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - //convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo")); - - dnnType *out_data, *out_data2; // cudnn output, tensorRT output - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - out_data = net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - - tk::dnn::dataDim_t dim2 = dim; - printCenteredTitle(" TENSORRT inference ", '=', 30); { - dim2.print(); - TIMER_START - out_data2 = netRT.infer(dim2, data); - TIMER_STOP - dim2.print(); - } - - printCenteredTitle(" CHECK RESULTS ", '=', 30); - dnnType *out, *out_h; - int out_dim = net.getOutputDim().tot(); - readBinaryFile(output_bin, out_dim, &out_h, &out); - - // std::cout<<"\n\nDetected objects: \n"; - // dnnType *output_h = new dnnType[rI.output_dim.tot()]; - // checkCuda(cudaMemcpy(output_h, out_data2, - // rI.output_dim.tot()*sizeof(dnnType), cudaMemcpyDeviceToHost)); - // rI.interpretData(output_h); - // rI.showImageResult(input_h); - - std::cout<<"CUDNN vs correct"; - int ret_cudnn = checkResult(out_dim, out_data, out) == 0 ? 0: ERROR_CUDNN; - std::cout<<"TRT vs correct"; - int ret_tensorrt = checkResult(out_dim, out_data2, out) == 0 ? 0 : ERROR_TENSORRT; - std::cout<<"CUDNN vs TRT "; - int ret_cudnn_tensorrt = checkResult(out_dim, out_data, out_data2) == 0 ? 0 : ERROR_CUDNNvsTENSORRT; - - return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; -} diff --git a/tests/yolo3/yolo3.cpp b/tests/yolo3/yolo3.cpp deleted file mode 100644 index 89b8283..0000000 --- a/tests/yolo3/yolo3.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include -#include -#include "tkdnn.h" -#include "DarknetParser.h" - -int main() { - - // create yolo3 model - std::string bin_path = "yolo3"; - downloadWeightsifDoNotExist("yolo3/layers/input.bin", bin_path, "https://cloud.hipert.unimore.it/s/jPXmHyptpLoNdNR/download"); - - tk::dnn::Network *net = tk::dnn::darknetParser("../tests/yolo3/yolov3.cfg", "yolo3/layers", "../tests/yolo3/coco.names"); - net->print(); - - std::vector yolo; - for(int i=0; inum_layers; i++) { - if(net->layers[i]->getLayerType() == tk::dnn::layerType_t::LAYER_YOLO) - yolo.push_back((tk::dnn::Yolo*)net->layers[i]); - } - - //convert network to tensorRT - tk::dnn::NetworkRT netRT(net, net->getNetworkRTName("yolo3")); - - - std::string input_bin = bin_path + "/layers/input.bin"; - std::vector output_bins = { - bin_path + "/debug/layer82_out.bin", - bin_path + "/debug/layer94_out.bin", - bin_path + "/debug/layer106_out.bin" - }; - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, net->input_dim.tot(), &input_h, &data); - - // the network have 3 outputs - tk::dnn::dataDim_t out_dim[3]; - for(int i=0; i<3; i++) out_dim[i] = yolo[i]->output_dim; - dnnType *cudnn_out[3], *rt_out[3]; - - tk::dnn::dataDim_t dim1 = net->input_dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - net->infer(dim1, data); - TIMER_STOP - dim1.print(); - } - for(int i=0; i<3; i++) cudnn_out[i] = yolo[i]->dstData; - - - tk::dnn::dataDim_t dim2 = net->input_dim; - printCenteredTitle(" TENSORRT inference ", '=', 30); { - dim2.print(); - TIMER_START - netRT.infer(dim2, data); - TIMER_STOP - dim2.print(); - } - for(int i=0; i<3; i++) rt_out[i] = (dnnType*)netRT.buffersRT[i+1]; - - int ret_cudnn = 0, ret_tensorrt = 0, ret_cudnn_tensorrt = 0; - for(int i=0; i<3; i++) { - printCenteredTitle((std::string(" YOLO ") + std::to_string(i) + " CHECK RESULTS ").c_str(), '=', 30); - dnnType *out, *out_h; - int odim = out_dim[i].tot(); - readBinaryFile(output_bins[i], odim, &out_h, &out); - std::cout<<"CUDNN vs correct"; - ret_cudnn |= checkResult(odim, cudnn_out[i], out) == 0 ? 0: ERROR_CUDNN; - std::cout<<"TRT vs correct"; - ret_tensorrt |= checkResult(odim, rt_out[i], out) == 0 ? 0 : ERROR_TENSORRT; - std::cout<<"CUDNN vs TRT "; - ret_cudnn_tensorrt |= checkResult(odim, cudnn_out[i], rt_out[i]) == 0 ? 0 : ERROR_CUDNNvsTENSORRT; - } - return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; -} diff --git a/tests/yolo3_512/yolo3_512.cpp b/tests/yolo3_512/yolo3_512.cpp deleted file mode 100644 index 5e796c1..0000000 --- a/tests/yolo3_512/yolo3_512.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include -#include -#include "tkdnn.h" - -int main() { - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 512, 512, 1); - tk::dnn::Network net(dim); - - // create yolo3 model - std::string bin_path = "yolo3_512"; - downloadWeightsifDoNotExist("yolo3_512/layers/input.bin", bin_path, "https://cloud.hipert.unimore.it/s/RGecMeGLD4cXEWL/download"); - int classes = 80; - tk::dnn::Yolo *yolo [3]; - #include "models/Yolo3.h" - - - - // fill classes names - for(int i=0; i<3; i++) { - yolo[i]->classesNames = {"person" , "bicycle" , "car" , "motorbike" , "aeroplane" , "bus" , "train" , "truck" , "boat" , "traffic light" , "fire hydrant" , "stop sign" , "parking meter" , "bench" , "bird" , "cat" , "dog" , "horse" , "sheep" , "cow" , "elephant" , "bear" , "zebra" , "giraffe" , "backpack" , "umbrella" , "handbag" , "tie" , "suitcase" , "frisbee" , "skis" , "snowboard" , "sports ball" , "kite" , "baseball bat" , "baseball glove" , "skateboard" , "surfboard" , "tennis racket" , "bottle" , "wine glass" , "cup" , "fork" , "knife" , "spoon" , "bowl" , "banana" , "apple" , "sandwich" , "orange" , "broccoli" , "carrot" , "hot dog" , "pizza" , "donut" , "cake" , "chair" , "sofa" , "pottedplant" , "bed" , "diningtable" , "toilet" , "tvmonitor" , "laptop" , "mouse" , "remote" , "keyboard" , "cell phone" , "microwave" , "oven" , "toaster" , "sink" , "refrigerator" , "book" , "clock" , "vase" , "scissors" , "teddy bear" , "hair drier" , "toothbrush"}; - } - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - //convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo3_512")); - - // the network have 3 outputs - tk::dnn::dataDim_t out_dim[3]; - for(int i=0; i<3; i++) out_dim[i] = yolo[i]->output_dim; - dnnType *cudnn_out[3], *rt_out[3]; - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - for(int i=0; i<3; i++) cudnn_out[i] = yolo[i]->dstData; - - printCenteredTitle(" compute detections ", '=', 30); - TIMER_START - int ndets = 0; - tk::dnn::Yolo::detection *dets = tk::dnn::Yolo::allocateDetections(tk::dnn::Yolo::MAX_DETECTIONS, classes); - for(int i=0; i<3; i++) yolo[i]->computeDetections(dets, ndets, net.input_dim.w, net.input_dim.h, 0.5); - tk::dnn::Yolo::mergeDetections(dets, ndets, classes); - - for(int j=0; j 0) - cl = c; - } - std::cout< -#include -#include "tkdnn.h" - -int main() { - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 512, 512, 1); - tk::dnn::Network net(dim); - - // create yolo3 model - std::string bin_path = "yolo3_512tp"; - // downloadWeightsifDoNotExist("yolo3_512tp/layers/input.bin", bin_path, ); - int classes = 3; - tk::dnn::Yolo *yolo [3]; - #include "models/Yolo3.h" - - // fill classes names - for(int i=0; i<3; i++) { - yolo[i]->classesNames = {"Dent", "Wrinkle", "UnsealedFlaps"}; - } - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - //convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo3_512tp")); - - // the network have 3 outputs - tk::dnn::dataDim_t out_dim[3]; - for(int i=0; i<3; i++) out_dim[i] = yolo[i]->output_dim; - dnnType *cudnn_out[3], *rt_out[3]; - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - for(int i=0; i<3; i++) cudnn_out[i] = yolo[i]->dstData; - - printCenteredTitle(" compute detections ", '=', 30); - TIMER_START - int ndets = 0; - tk::dnn::Yolo::detection *dets = tk::dnn::Yolo::allocateDetections(tk::dnn::Yolo::MAX_DETECTIONS, classes); - for(int i=0; i<3; i++) yolo[i]->computeDetections(dets, ndets, net.input_dim.w, net.input_dim.h, 0.5); - tk::dnn::Yolo::mergeDetections(dets, ndets, classes); - - for(int j=0; j 0) - cl = c; - } - std::cout< -#include -#include "tkdnn.h" - -int main() { - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 320, 544, 1); - tk::dnn::Network net(dim); - - // create yolo3 model - std::string bin_path = "yolo3_berkeley"; - downloadWeightsifDoNotExist("yolo3_berkeley/layers/input.bin", bin_path, "https://cloud.hipert.unimore.it/s/o5cHa4AjTKS64oD/download"); - int classes = 10; - tk::dnn::Yolo *yolo [3]; - #include "models/Yolo3.h" - - - - // fill classes names - for(int i=0; i<3; i++) { - yolo[i]->classesNames = {"person", "car", "truck", "bus", "motor", "bike", "rider", "traffic light", "traffic sign", "train"}; - } - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - //convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo3_berkeley")); - - // the network have 3 outputs - tk::dnn::dataDim_t out_dim[3]; - for(int i=0; i<3; i++) out_dim[i] = yolo[i]->output_dim; - dnnType *cudnn_out[3], *rt_out[3]; - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - for(int i=0; i<3; i++) cudnn_out[i] = yolo[i]->dstData; - - printCenteredTitle(" compute detections ", '=', 30); - TIMER_START - int ndets = 0; - tk::dnn::Yolo::detection *dets = tk::dnn::Yolo::allocateDetections(tk::dnn::Yolo::MAX_DETECTIONS, classes); - for(int i=0; i<3; i++) yolo[i]->computeDetections(dets, ndets, net.input_dim.w, net.input_dim.h, 0.5); - tk::dnn::Yolo::mergeDetections(dets, ndets, classes); - - for(int j=0; j 0) - cl = c; - } - std::cout< -#include -#include "tkdnn.h" - -int main() { - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 416, 416, 1); - tk::dnn::Network net(dim); - - // create yolo3 model - std::string bin_path = "yolo3_coco4"; - downloadWeightsifDoNotExist("yolo3_coco4/layers/input.bin", bin_path, "https://cloud.hipert.unimore.it/s/o27NDzSAartbyc4/download"); - int classes = 4; - tk::dnn::Yolo *yolo [3]; - #include "models/Yolo3.h" - - // fill classes names - for(int i=0; i<3; i++) { - yolo[i]->classesNames = {"person" , "bicycle" , "car" , "motorbike" }; - } - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - //convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo3_coco4")); - - // the network have 3 outputs - tk::dnn::dataDim_t out_dim[3]; - for(int i=0; i<3; i++) out_dim[i] = yolo[i]->output_dim; - dnnType *cudnn_out[3], *rt_out[3]; - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - for(int i=0; i<3; i++) cudnn_out[i] = yolo[i]->dstData; - - printCenteredTitle(" compute detections ", '=', 30); - TIMER_START - int ndets = 0; - tk::dnn::Yolo::detection *dets = tk::dnn::Yolo::allocateDetections(tk::dnn::Yolo::MAX_DETECTIONS, classes); - for(int i=0; i<3; i++) yolo[i]->computeDetections(dets, ndets, net.input_dim.w, net.input_dim.h, 0.5); - tk::dnn::Yolo::mergeDetections(dets, ndets, classes); - - for(int j=0; j 0) - cl = c; - } - std::cout< -#include -#include "tkdnn.h" - - -int main() { - - // Network layout - tk::dnn::dataDim_t dim(1, 1, 320, 544, 1); - tk::dnn::Network net(dim); - - // create yolo3 model - std::string bin_path = "yolo3_flir"; - downloadWeightsifDoNotExist("yolo3_flir/layers/input.bin", bin_path, "https://cloud.hipert.unimore.it/s/62DECncmF6bMMiH/download"); - - int classes = 3; - tk::dnn::Yolo *yolo [3]; - #include "models/Yolo3.h" - - // fill classes names - for(int i=0; i<3; i++) { - yolo[i]->classesNames = {"person", "bike", "car"}; - } - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - //convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo3_flir")); - - // the network have 3 outputs - tk::dnn::dataDim_t out_dim[3]; - for(int i=0; i<3; i++) out_dim[i] = yolo[i]->output_dim; - dnnType *cudnn_out[3], *rt_out[3]; - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - for(int i=0; i<3; i++) cudnn_out[i] = yolo[i]->dstData; - - printCenteredTitle(" compute detections ", '=', 30); - TIMER_START - int ndets = 0; - tk::dnn::Yolo::detection *dets = tk::dnn::Yolo::allocateDetections(tk::dnn::Yolo::MAX_DETECTIONS, classes); - for(int i=0; i<3; i++) yolo[i]->computeDetections(dets, ndets, net.input_dim.w, net.input_dim.h, 0.5); - tk::dnn::Yolo::mergeDetections(dets, ndets, classes); - - for(int j=0; j 0) - cl = c; - } - std::cout< -// #include -#include "tkdnn.h" - -const char *input_bin = "yolo3_tiny/layers/input.bin"; -const char *c0_bin = "yolo3_tiny/layers/c0.bin"; -const char *c2_bin = "yolo3_tiny/layers/c2.bin"; -const char *c4_bin = "yolo3_tiny/layers/c4.bin"; -const char *c6_bin = "yolo3_tiny/layers/c6.bin"; -const char *c8_bin = "yolo3_tiny/layers/c8.bin"; -const char *c10_bin = "yolo3_tiny/layers/c10.bin"; -const char *c12_bin = "yolo3_tiny/layers/c12.bin"; -const char *c13_bin = "yolo3_tiny/layers/c13.bin"; -const char *c14_bin = "yolo3_tiny/layers/c14.bin"; -const char *c15_bin = "yolo3_tiny/layers/c15.bin"; -const char *c18_bin = "yolo3_tiny/layers/c18.bin"; -const char *c21_bin = "yolo3_tiny/layers/c21.bin"; -const char *c22_bin = "yolo3_tiny/layers/c22.bin"; -const char *g16_bin = "yolo3_tiny/layers/g16.bin"; -const char *g23_bin = "yolo3_tiny/layers/g23.bin"; -// const char *output_bin = "yolo3_tiny/layers/output.bin"; - -const char *output_bin = "yolo3_tiny/debug/layer23_out.bin"; - -int main() { - - downloadWeightsifDoNotExist(input_bin, "yolo3_tiny", "https://cloud.hipert.unimore.it/s/LMcSHtWaLeps8yN/download"); - - int classes = 80; - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 416, 416, 1); - tk::dnn::Network net(dim); - - - tk::dnn::Conv2d c0 (&net, 16, 3, 3, 1, 1, 1, 1, c0_bin, true); - tk::dnn::Activation a0 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p1 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c2 (&net, 32, 3, 3, 1, 1, 1, 1, c2_bin, true); - tk::dnn::Activation a2 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p3 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c4 (&net, 64, 3, 3, 1, 1, 1, 1, c4_bin, true); - tk::dnn::Activation a4 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p5 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c6 (&net, 128, 3, 3, 1, 1, 1, 1, c6_bin, true); - tk::dnn::Activation a6 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p7(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c8(&net, 256, 3, 3, 1, 1, 1, 1, c8_bin, true); - tk::dnn::Activation a8(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p9(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c10(&net, 512, 3, 3, 1, 1, 1, 1, c10_bin, true); - tk::dnn::Activation a10(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p11(&net, 2, 2, 1, 1, 0, 0, tk::dnn::POOLING_MAX_FIXEDSIZE); - - tk::dnn::Conv2d c12(&net, 1024, 3, 3, 1, 1, 1, 1, c12_bin, true); - tk::dnn::Activation a12(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Conv2d c13(&net, 256, 1, 1, 1, 1, 0, 0, c13_bin, true); - tk::dnn::Activation a13(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c14(&net, 512, 3, 3, 1, 1, 1, 1, c14_bin, true); - tk::dnn::Activation a14(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c15(&net, 255, 1, 1, 1, 1, 0, 0, c15_bin, false); - - tk::dnn::Yolo yolo0 (&net, classes, 2, g16_bin); - - tk::dnn::Layer *m17_layers[1] = { &a13 }; - tk::dnn::Route m17 (&net, m17_layers, 1); - tk::dnn::Conv2d c18(&net, 128, 1, 1, 1, 1, 0, 0, c18_bin, true); - tk::dnn::Activation a18(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Upsample u19 (&net, 2); - - tk::dnn::Layer *m20_layers[2] = { &u19, &a8 }; - tk::dnn::Route m20 (&net, m20_layers, 2); - - tk::dnn::Conv2d c21(&net, 256, 3, 3, 1, 1, 1, 1, c21_bin, true); - tk::dnn::Activation a21(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c22(&net, 255, 1, 1, 1, 1, 0, 0, c22_bin, false); - - tk::dnn::Yolo yolo1 (&net, classes, 2, g23_bin); - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - // convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo3_tiny")); - - dnnType *out_data, *out_data2; // cudnn output, tensorRT output - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - out_data = net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - - tk::dnn::dataDim_t dim2 = dim; - printCenteredTitle(" TENSORRT inference ", '=', 30); { - dim2.print(); - TIMER_START - out_data2 = netRT.infer(dim2, data); - TIMER_STOP - dim2.print(); - } - - printCenteredTitle(" CHECK RESULTS ", '=', 30); - dnnType *out, *out_h; - int out_dim = net.getOutputDim().tot(); - readBinaryFile(output_bin, out_dim, &out_h, &out); - - std::cout<<"CUDNN vs correct"; - int ret_cudnn = checkResult(out_dim, out_data, out) == 0 ? 0: ERROR_CUDNN; - std::cout<<"TRT vs correct"; - int ret_tensorrt = checkResult(out_dim, out_data2, out) == 0 ? 0 : ERROR_TENSORRT; - std::cout<<"CUDNN vs TRT "; - int ret_cudnn_tensorrt = checkResult(out_dim, out_data, out_data2) == 0 ? 0 : ERROR_CUDNNvsTENSORRT; - - return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; -} diff --git a/tests/yolo3_tiny512/yolo3_tiny512.cpp b/tests/yolo3_tiny512/yolo3_tiny512.cpp deleted file mode 100644 index 38816f9..0000000 --- a/tests/yolo3_tiny512/yolo3_tiny512.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include -#include "tkdnn.h" - -const char *input_bin = "yolo3_tiny512/layers/input.bin"; -const char *c0_bin = "yolo3_tiny512/layers/c0.bin"; -const char *c2_bin = "yolo3_tiny512/layers/c2.bin"; -const char *c4_bin = "yolo3_tiny512/layers/c4.bin"; -const char *c6_bin = "yolo3_tiny512/layers/c6.bin"; -const char *c8_bin = "yolo3_tiny512/layers/c8.bin"; -const char *c10_bin = "yolo3_tiny512/layers/c10.bin"; -const char *c12_bin = "yolo3_tiny512/layers/c12.bin"; -const char *c13_bin = "yolo3_tiny512/layers/c13.bin"; -const char *c14_bin = "yolo3_tiny512/layers/c14.bin"; -const char *c15_bin = "yolo3_tiny512/layers/c15.bin"; -const char *c18_bin = "yolo3_tiny512/layers/c18.bin"; -const char *c21_bin = "yolo3_tiny512/layers/c21.bin"; -const char *c22_bin = "yolo3_tiny512/layers/c22.bin"; -const char *g16_bin = "yolo3_tiny512/layers/g16.bin"; -const char *g23_bin = "yolo3_tiny512/layers/g23.bin"; -// const char *output_bin = "yolo3_tiny512/layers/output.bin"; - -const char *output_bin = "yolo3_tiny512/debug/layer23_out.bin"; - -int main() { - - downloadWeightsifDoNotExist(input_bin, "yolo3_tiny512", "https://cloud.hipert.unimore.it/s/8Zt6bHwHADqP4JC/download"); - - int classes = 80; - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 512, 512, 1); - tk::dnn::Network net(dim); - - - tk::dnn::Conv2d c0 (&net, 16, 3, 3, 1, 1, 1, 1, c0_bin, true); - tk::dnn::Activation a0 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p1 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c2 (&net, 32, 3, 3, 1, 1, 1, 1, c2_bin, true); - tk::dnn::Activation a2 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p3 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c4 (&net, 64, 3, 3, 1, 1, 1, 1, c4_bin, true); - tk::dnn::Activation a4 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p5 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c6 (&net, 128, 3, 3, 1, 1, 1, 1, c6_bin, true); - tk::dnn::Activation a6 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p7(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c8(&net, 256, 3, 3, 1, 1, 1, 1, c8_bin, true); - tk::dnn::Activation a8(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p9(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c10(&net, 512, 3, 3, 1, 1, 1, 1, c10_bin, true); - tk::dnn::Activation a10(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p11(&net, 2, 2, 1, 1, 0, 0, tk::dnn::POOLING_MAX_FIXEDSIZE); - - tk::dnn::Conv2d c12(&net, 1024, 3, 3, 1, 1, 1, 1, c12_bin, true); - tk::dnn::Activation a12(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Conv2d c13(&net, 256, 1, 1, 1, 1, 0, 0, c13_bin, true); - tk::dnn::Activation a13(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c14(&net, 512, 3, 3, 1, 1, 1, 1, c14_bin, true); - tk::dnn::Activation a14(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c15(&net, 255, 1, 1, 1, 1, 0, 0, c15_bin, false); - - tk::dnn::Yolo yolo0 (&net, classes, 2, g16_bin); - - tk::dnn::Layer *m17_layers[1] = { &a13 }; - tk::dnn::Route m17 (&net, m17_layers, 1); - tk::dnn::Conv2d c18(&net, 128, 1, 1, 1, 1, 0, 0, c18_bin, true); - tk::dnn::Activation a18(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Upsample u19 (&net, 2); - - tk::dnn::Layer *m20_layers[2] = { &u19, &a8 }; - tk::dnn::Route m20 (&net, m20_layers, 2); - - tk::dnn::Conv2d c21(&net, 256, 3, 3, 1, 1, 1, 1, c21_bin, true); - tk::dnn::Activation a21(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c22(&net, 255, 1, 1, 1, 1, 0, 0, c22_bin, false); - - tk::dnn::Yolo yolo1 (&net, classes, 2, g23_bin); - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - // convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo3_tiny512")); - - dnnType *out_data, *out_data2; // cudnn output, tensorRT output - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - out_data = net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - - tk::dnn::dataDim_t dim2 = dim; - printCenteredTitle(" TENSORRT inference ", '=', 30); { - dim2.print(); - TIMER_START - out_data2 = netRT.infer(dim2, data); - TIMER_STOP - dim2.print(); - } - - printCenteredTitle(" CHECK RESULTS ", '=', 30); - dnnType *out, *out_h; - int out_dim = net.getOutputDim().tot(); - readBinaryFile(output_bin, out_dim, &out_h, &out); - std::cout<<"CUDNN vs correct"; - int ret_cudnn = checkResult(out_dim, out_data, out) == 0 ? 0: ERROR_CUDNN; - std::cout<<"TRT vs correct"; - int ret_tensorrt = checkResult(out_dim, out_data2, out) == 0 ? 0 : ERROR_TENSORRT; - std::cout<<"CUDNN vs TRT "; - int ret_cudnn_tensorrt = checkResult(out_dim, out_data, out_data2) == 0 ? 0 : ERROR_CUDNNvsTENSORRT; - - return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; -} diff --git a/tests/yolo3_tiny512tp/yolo3_tiny512tp.cpp b/tests/yolo3_tiny512tp/yolo3_tiny512tp.cpp deleted file mode 100644 index 13a8b00..0000000 --- a/tests/yolo3_tiny512tp/yolo3_tiny512tp.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include -#include "tkdnn.h" - -const char *input_bin = "yolo3_tiny512tp/layers/input.bin"; -const char *c0_bin = "yolo3_tiny512tp/layers/c0.bin"; -const char *c2_bin = "yolo3_tiny512tp/layers/c2.bin"; -const char *c4_bin = "yolo3_tiny512tp/layers/c4.bin"; -const char *c6_bin = "yolo3_tiny512tp/layers/c6.bin"; -const char *c8_bin = "yolo3_tiny512tp/layers/c8.bin"; -const char *c10_bin = "yolo3_tiny512tp/layers/c10.bin"; -const char *c12_bin = "yolo3_tiny512tp/layers/c12.bin"; -const char *c13_bin = "yolo3_tiny512tp/layers/c13.bin"; -const char *c14_bin = "yolo3_tiny512tp/layers/c14.bin"; -const char *c15_bin = "yolo3_tiny512tp/layers/c15.bin"; -const char *c18_bin = "yolo3_tiny512tp/layers/c18.bin"; -const char *c21_bin = "yolo3_tiny512tp/layers/c21.bin"; -const char *c22_bin = "yolo3_tiny512tp/layers/c22.bin"; -const char *g16_bin = "yolo3_tiny512tp/layers/g16.bin"; -const char *g23_bin = "yolo3_tiny512tp/layers/g23.bin"; -// const char *output_bin = "yolo3_tiny512tp/layers/output.bin"; - -const char *output_bin = "yolo3_tiny512tp/debug/layer23_out.bin"; - -int main() { - - int classes = 3; - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 512, 512, 1); - tk::dnn::Network net(dim); - - - tk::dnn::Conv2d c0 (&net, 16, 3, 3, 1, 1, 1, 1, c0_bin, true); - tk::dnn::Activation a0 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p1 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c2 (&net, 32, 3, 3, 1, 1, 1, 1, c2_bin, true); - tk::dnn::Activation a2 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p3 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c4 (&net, 64, 3, 3, 1, 1, 1, 1, c4_bin, true); - tk::dnn::Activation a4 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p5 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c6 (&net, 128, 3, 3, 1, 1, 1, 1, c6_bin, true); - tk::dnn::Activation a6 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p7(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c8(&net, 256, 3, 3, 1, 1, 1, 1, c8_bin, true); - tk::dnn::Activation a8(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p9(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c10(&net, 512, 3, 3, 1, 1, 1, 1, c10_bin, true); - tk::dnn::Activation a10(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p11(&net, 2, 2, 1, 1, 0, 0, tk::dnn::POOLING_MAX_FIXEDSIZE); - - tk::dnn::Conv2d c12(&net, 1024, 3, 3, 1, 1, 1, 1, c12_bin, true); - tk::dnn::Activation a12(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Conv2d c13(&net, 256, 1, 1, 1, 1, 0, 0, c13_bin, true); - tk::dnn::Activation a13(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c14(&net, 512, 3, 3, 1, 1, 1, 1, c14_bin, true); - tk::dnn::Activation a14(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c15(&net, 24, 1, 1, 1, 1, 0, 0, c15_bin, false); - - tk::dnn::Yolo yolo0 (&net, classes, 2, g16_bin); - - tk::dnn::Layer *m17_layers[1] = { &a13 }; - tk::dnn::Route m17 (&net, m17_layers, 1); - tk::dnn::Conv2d c18(&net, 128, 1, 1, 1, 1, 0, 0, c18_bin, true); - tk::dnn::Activation a18(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Upsample u19 (&net, 2); - - tk::dnn::Layer *m20_layers[2] = { &u19, &a8 }; - tk::dnn::Route m20 (&net, m20_layers, 2); - - tk::dnn::Conv2d c21(&net, 256, 3, 3, 1, 1, 1, 1, c21_bin, true); - tk::dnn::Activation a21(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c22(&net, 24, 1, 1, 1, 1, 0, 0, c22_bin, false); - - tk::dnn::Yolo yolo1 (&net, classes, 2, g23_bin); - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - // convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo3_tiny512tp")); - - dnnType *out_data, *out_data2; // cudnn output, tensorRT output - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - out_data = net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - - tk::dnn::dataDim_t dim2 = dim; - printCenteredTitle(" TENSORRT inference ", '=', 30); { - dim2.print(); - TIMER_START - out_data2 = netRT.infer(dim2, data); - TIMER_STOP - dim2.print(); - } - - printCenteredTitle(" CHECK RESULTS ", '=', 30); - dnnType *out, *out_h; - int out_dim = net.getOutputDim().tot(); - readBinaryFile(output_bin, out_dim, &out_h, &out); - - std::cout<<"CUDNN vs correct"; - int ret_cudnn = checkResult(out_dim, out_data, out) == 0 ? 0: ERROR_CUDNN; - std::cout<<"TRT vs correct"; - int ret_tensorrt = checkResult(out_dim, out_data2, out) == 0 ? 0 : ERROR_TENSORRT; - std::cout<<"CUDNN vs TRT "; - int ret_cudnn_tensorrt = checkResult(out_dim, out_data, out_data2) == 0 ? 0 : ERROR_CUDNNvsTENSORRT; - - return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; -} diff --git a/tests/yolo3_tinyNM512/yolo3_tinyNM512.cpp b/tests/yolo3_tinyNM512/yolo3_tinyNM512.cpp deleted file mode 100644 index 7ffd603..0000000 --- a/tests/yolo3_tinyNM512/yolo3_tinyNM512.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include -#include "tkdnn.h" - -const char *input_bin = "yolo3_tinyNM512/layers/input.bin"; -const char *c0_bin = "yolo3_tinyNM512/layers/c0.bin"; -const char *c2_bin = "yolo3_tinyNM512/layers/c2.bin"; -const char *c4_bin = "yolo3_tinyNM512/layers/c4.bin"; -const char *c6_bin = "yolo3_tinyNM512/layers/c6.bin"; -const char *c8_bin = "yolo3_tinyNM512/layers/c8.bin"; -const char *c10_bin = "yolo3_tinyNM512/layers/c10.bin"; -const char *c11_bin = "yolo3_tinyNM512/layers/c11.bin"; -const char *c12_bin = "yolo3_tinyNM512/layers/c12.bin"; -const char *c13_bin = "yolo3_tinyNM512/layers/c13.bin"; -const char *c14_bin = "yolo3_tinyNM512/layers/c14.bin"; -const char *c17_bin = "yolo3_tinyNM512/layers/c17.bin"; -const char *c20_bin = "yolo3_tinyNM512/layers/c20.bin"; -const char *c21_bin = "yolo3_tinyNM512/layers/c21.bin"; -const char *g15_bin = "yolo3_tinyNM512/layers/g15.bin"; -const char *g22_bin = "yolo3_tinyNM512/layers/g22.bin"; -// const char *output_bin = "yolo3_tinyNM512/layers/output.bin"; - -const char *output_bin = "yolo3_tinyNM512/debug/layer22_out.bin"; - -int main() { - - // downloadWeightsifDoNotExist(input_bin, "yolo3_tinyNM512", "https://cloud.hipert.unimore.it/s/wRW9nmkibSe5HoS/download"); - - int classes = 80; - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 512, 512, 1); - tk::dnn::Network net(dim); - - - tk::dnn::Conv2d c0 (&net, 16, 3, 3, 1, 1, 1, 1, c0_bin, true); - tk::dnn::Activation a0 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p1 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c2 (&net, 32, 3, 3, 1, 1, 1, 1, c2_bin, true); - tk::dnn::Activation a2 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p3 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c4 (&net, 64, 3, 3, 1, 1, 1, 1, c4_bin, true); - tk::dnn::Activation a4 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p5 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c6 (&net, 128, 3, 3, 1, 1, 1, 1, c6_bin, true); - tk::dnn::Activation a6 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p7(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c8(&net, 256, 3, 3, 1, 1, 1, 1, c8_bin, true); - tk::dnn::Activation a8(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p9(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c10(&net, 512, 3, 3, 1, 1, 1, 1, c10_bin, true); - tk::dnn::Activation a10(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Conv2d c12(&net, 1024, 3, 3, 1, 1, 1, 1, c11_bin, true); - tk::dnn::Activation a12(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Conv2d c13(&net, 256, 1, 1, 1, 1, 0, 0, c12_bin, true); - tk::dnn::Activation a13(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c14(&net, 512, 3, 3, 1, 1, 1, 1, c13_bin, true); - tk::dnn::Activation a14(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c15(&net, 255, 1, 1, 1, 1, 0, 0, c14_bin, false); - - tk::dnn::Yolo yolo0 (&net, classes, 2, g15_bin); - - tk::dnn::Layer *m17_layers[1] = { &a13 }; - tk::dnn::Route m17 (&net, m17_layers, 1); - tk::dnn::Conv2d c18(&net, 128, 1, 1, 1, 1, 0, 0, c17_bin, true); - tk::dnn::Activation a18(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Upsample u19 (&net, 2); - - tk::dnn::Layer *m20_layers[2] = { &u19, &a8 }; - tk::dnn::Route m20 (&net, m20_layers, 2); - - tk::dnn::Conv2d c21(&net, 256, 3, 3, 1, 1, 1, 1, c20_bin, true); - tk::dnn::Activation a21(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c22(&net, 255, 1, 1, 1, 1, 0, 0, c21_bin, false); - - tk::dnn::Yolo yolo1 (&net, classes, 2, g22_bin); - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - // convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo3_tinyNM512")); - - dnnType *out_data, *out_data2; // cudnn output, tensorRT output - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - out_data = net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - - tk::dnn::dataDim_t dim2 = dim; - printCenteredTitle(" TENSORRT inference ", '=', 30); { - dim2.print(); - TIMER_START - out_data2 = netRT.infer(dim2, data); - TIMER_STOP - dim2.print(); - } - - printCenteredTitle(" CHECK RESULTS ", '=', 30); - dnnType *out, *out_h; - int out_dim = net.getOutputDim().tot(); - readBinaryFile(output_bin, out_dim, &out_h, &out); - std::cout<<"CUDNN vs correct"; - int ret_cudnn = checkResult(out_dim, out_data, out) == 0 ? 0: ERROR_CUDNN; - std::cout<<"TRT vs correct"; - int ret_tensorrt = checkResult(out_dim, out_data2, out) == 0 ? 0 : ERROR_TENSORRT; - std::cout<<"CUDNN vs TRT "; - int ret_cudnn_tensorrt = checkResult(out_dim, out_data, out_data2) == 0 ? 0 : ERROR_CUDNNvsTENSORRT; - - return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; -} diff --git a/tests/yolo4/yolo4.cpp b/tests/yolo4/yolo4.cpp deleted file mode 100644 index 72ba205..0000000 --- a/tests/yolo4/yolo4.cpp +++ /dev/null @@ -1,666 +0,0 @@ -#include -#include -#include "tkdnn.h" - -int main() -{ - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 416, 416, 1); - tk::dnn::Network net(dim); - - // create yolo4 model - std::string bin_path = "yolo4"; - int classes = 80; - tk::dnn::Yolo *yolo[3]; - - std::string input_bin = bin_path + "/layers/input.bin"; - - std::vector output_bins = { - bin_path + "/debug/layer139_out.bin", - bin_path + "/debug/layer150_out.bin", - bin_path + "/debug/layer161_out.bin"}; - std::string c0_bin = bin_path + "/layers/c0.bin"; - std::string c1_bin = bin_path + "/layers/c1.bin"; - std::string c2_bin = bin_path + "/layers/c2.bin"; - std::string c3_bin = bin_path + "/layers/c3.bin"; - std::string c4_bin = bin_path + "/layers/c4.bin"; - std::string c5_bin = bin_path + "/layers/c5.bin"; - std::string c6_bin = bin_path + "/layers/c6.bin"; - std::string c7_bin = bin_path + "/layers/c7.bin"; - std::string c8_bin = bin_path + "/layers/c8.bin"; - std::string c10_bin = bin_path + "/layers/c10.bin"; - std::string c11_bin = bin_path + "/layers/c11.bin"; - std::string c12_bin = bin_path + "/layers/c12.bin"; - std::string c13_bin = bin_path + "/layers/c13.bin"; - std::string c14_bin = bin_path + "/layers/c14.bin"; - std::string c15_bin = bin_path + "/layers/c15.bin"; - std::string c16_bin = bin_path + "/layers/c16.bin"; - std::string c17_bin = bin_path + "/layers/c17.bin"; - std::string c18_bin = bin_path + "/layers/c18.bin"; - std::string c19_bin = bin_path + "/layers/c19.bin"; - std::string c20_bin = bin_path + "/layers/c20.bin"; - std::string c21_bin = bin_path + "/layers/c21.bin"; - std::string c23_bin = bin_path + "/layers/c23.bin"; - std::string c24_bin = bin_path + "/layers/c24.bin"; - std::string c25_bin = bin_path + "/layers/c25.bin"; - std::string c26_bin = bin_path + "/layers/c26.bin"; - std::string c27_bin = bin_path + "/layers/c27.bin"; - std::string c28_bin = bin_path + "/layers/c28.bin"; - std::string c29_bin = bin_path + "/layers/c29.bin"; - std::string c30_bin = bin_path + "/layers/c30.bin"; - std::string c31_bin = bin_path + "/layers/c31.bin"; - std::string c32_bin = bin_path + "/layers/c32.bin"; - std::string c33_bin = bin_path + "/layers/c33.bin"; - std::string c34_bin = bin_path + "/layers/c34.bin"; - std::string c35_bin = bin_path + "/layers/c35.bin"; - std::string c36_bin = bin_path + "/layers/c36.bin"; - std::string c37_bin = bin_path + "/layers/c37.bin"; - std::string c38_bin = bin_path + "/layers/c38.bin"; - std::string c39_bin = bin_path + "/layers/c39.bin"; - std::string c40_bin = bin_path + "/layers/c40.bin"; - std::string c41_bin = bin_path + "/layers/c41.bin"; - std::string c42_bin = bin_path + "/layers/c42.bin"; - std::string c43_bin = bin_path + "/layers/c43.bin"; - std::string c44_bin = bin_path + "/layers/c44.bin"; - std::string c45_bin = bin_path + "/layers/c45.bin"; - std::string c46_bin = bin_path + "/layers/c46.bin"; - std::string c47_bin = bin_path + "/layers/c47.bin"; - std::string c48_bin = bin_path + "/layers/c48.bin"; - std::string c49_bin = bin_path + "/layers/c49.bin"; - std::string c50_bin = bin_path + "/layers/c50.bin"; - std::string c51_bin = bin_path + "/layers/c51.bin"; - std::string c52_bin = bin_path + "/layers/c52.bin"; - std::string c53_bin = bin_path + "/layers/c53.bin"; - std::string c54_bin = bin_path + "/layers/c54.bin"; - std::string c55_bin = bin_path + "/layers/c55.bin"; - std::string c56_bin = bin_path + "/layers/c56.bin"; - std::string c57_bin = bin_path + "/layers/c57.bin"; - std::string c58_bin = bin_path + "/layers/c58.bin"; - std::string c59_bin = bin_path + "/layers/c59.bin"; - std::string c60_bin = bin_path + "/layers/c60.bin"; - std::string c61_bin = bin_path + "/layers/c61.bin"; - std::string c62_bin = bin_path + "/layers/c62.bin"; - std::string c63_bin = bin_path + "/layers/c63.bin"; - std::string c65_bin = bin_path + "/layers/c65.bin"; - std::string c66_bin = bin_path + "/layers/c66.bin"; - std::string c67_bin = bin_path + "/layers/c67.bin"; - std::string c68_bin = bin_path + "/layers/c68.bin"; - std::string c69_bin = bin_path + "/layers/c69.bin"; - std::string c70_bin = bin_path + "/layers/c70.bin"; - std::string c71_bin = bin_path + "/layers/c71.bin"; - std::string c72_bin = bin_path + "/layers/c72.bin"; - std::string c74_bin = bin_path + "/layers/c74.bin"; - std::string c75_bin = bin_path + "/layers/c75.bin"; - std::string c76_bin = bin_path + "/layers/c76.bin"; - std::string c77_bin = bin_path + "/layers/c77.bin"; - std::string c78_bin = bin_path + "/layers/c78.bin"; - std::string c80_bin = bin_path + "/layers/c80.bin"; - std::string c81_bin = bin_path + "/layers/c81.bin"; - std::string c82_bin = bin_path + "/layers/c82.bin"; - std::string c83_bin = bin_path + "/layers/c83.bin"; - std::string c85_bin = bin_path + "/layers/c85.bin"; - std::string c86_bin = bin_path + "/layers/c86.bin"; - std::string c87_bin = bin_path + "/layers/c87.bin"; - std::string c89_bin = bin_path + "/layers/c89.bin"; - std::string c90_bin = bin_path + "/layers/c90.bin"; - std::string c91_bin = bin_path + "/layers/c91.bin"; - std::string c92_bin = bin_path + "/layers/c92.bin"; - std::string c93_bin = bin_path + "/layers/c93.bin"; - std::string c94_bin = bin_path + "/layers/c94.bin"; - std::string c96_bin = bin_path + "/layers/c96.bin"; - std::string c97_bin = bin_path + "/layers/c97.bin"; - std::string c98_bin = bin_path + "/layers/c98.bin"; - std::string c99_bin = bin_path + "/layers/c99.bin"; - std::string c100_bin = bin_path + "/layers/c100.bin"; - std::string c101_bin = bin_path + "/layers/c101.bin"; - std::string c102_bin = bin_path + "/layers/c102.bin"; - std::string c103_bin = bin_path + "/layers/c103.bin"; - std::string c104_bin = bin_path + "/layers/c104.bin"; - std::string c105_bin = bin_path + "/layers/c105.bin"; - std::string c106_bin = bin_path + "/layers/c106.bin"; - std::string c107_bin = bin_path + "/layers/c107.bin"; - std::string c108_bin = bin_path + "/layers/c108.bin"; - std::string c109_bin = bin_path + "/layers/c109.bin"; - std::string c110_bin = bin_path + "/layers/c110.bin"; - std::string c111_bin = bin_path + "/layers/c111.bin"; - std::string c112_bin = bin_path + "/layers/c112.bin"; - std::string c113_bin = bin_path + "/layers/c113.bin"; - std::string c114_bin = bin_path + "/layers/c114.bin"; - std::string c115_bin = bin_path + "/layers/c115.bin"; - std::string c116_bin = bin_path + "/layers/c116.bin"; - std::string c117_bin = bin_path + "/layers/c117.bin"; - std::string c119_bin = bin_path + "/layers/c119.bin"; - std::string c120_bin = bin_path + "/layers/c120.bin"; - std::string c121_bin = bin_path + "/layers/c121.bin"; - std::string c122_bin = bin_path + "/layers/c122.bin"; - std::string c123_bin = bin_path + "/layers/c123.bin"; - std::string c124_bin = bin_path + "/layers/c124.bin"; - std::string c125_bin = bin_path + "/layers/c125.bin"; - std::string c126_bin = bin_path + "/layers/c126.bin"; - std::string c127_bin = bin_path + "/layers/c127.bin"; - std::string c128_bin = bin_path + "/layers/c128.bin"; - std::string c130_bin = bin_path + "/layers/c130.bin"; - std::string c131_bin = bin_path + "/layers/c131.bin"; - std::string c132_bin = bin_path + "/layers/c132.bin"; - std::string c133_bin = bin_path + "/layers/c133.bin"; - std::string c134_bin = bin_path + "/layers/c134.bin"; - std::string c135_bin = bin_path + "/layers/c135.bin"; - std::string c136_bin = bin_path + "/layers/c136.bin"; - std::string c137_bin = bin_path + "/layers/c137.bin"; - std::string c138_bin = bin_path + "/layers/c138.bin"; - std::string c141_bin = bin_path + "/layers/c141.bin"; - std::string c142_bin = bin_path + "/layers/c142.bin"; - std::string c143_bin = bin_path + "/layers/c143.bin"; - std::string c144_bin = bin_path + "/layers/c144.bin"; - std::string c145_bin = bin_path + "/layers/c145.bin"; - std::string c146_bin = bin_path + "/layers/c146.bin"; - std::string c147_bin = bin_path + "/layers/c147.bin"; - std::string c148_bin = bin_path + "/layers/c148.bin"; - std::string c149_bin = bin_path + "/layers/c149.bin"; - std::string c150_bin = bin_path + "/layers/c150.bin"; - std::string c151_bin = bin_path + "/layers/c151.bin"; - std::string c152_bin = bin_path + "/layers/c152.bin"; - std::string c153_bin = bin_path + "/layers/c153.bin"; - std::string c154_bin = bin_path + "/layers/c154.bin"; - std::string c155_bin = bin_path + "/layers/c155.bin"; - std::string c156_bin = bin_path + "/layers/c156.bin"; - std::string c157_bin = bin_path + "/layers/c157.bin"; - std::string c158_bin = bin_path + "/layers/c158.bin"; - std::string c159_bin = bin_path + "/layers/c159.bin"; - std::string c160_bin = bin_path + "/layers/c160.bin"; - std::string g139_bin = bin_path + "/layers/g139.bin"; - std::string g150_bin = bin_path + "/layers/g150.bin"; - std::string g161_bin = bin_path + "/layers/g161.bin"; - - - downloadWeightsifDoNotExist(input_bin, bin_path, "https://cloud.hipert.unimore.it/s/d97CFzYqCPCp5Hg/download"); - - tk::dnn::Conv2d c0(&net, 32, 3, 3, 1, 1, 1, 1, c0_bin, true); - tk::dnn::Activation a0(&net, tk::dnn::ACTIVATION_MISH); - - // downsample - tk::dnn::Conv2d c1(&net, 64, 3, 3, 2, 2, 1, 1, c1_bin, true); - tk::dnn::Activation a1(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c2(&net, 64, 1, 1, 1, 1, 0, 0, c2_bin, true); - tk::dnn::Activation a2(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Layer *r3_layers[1] = {&a1}; - tk::dnn::Route r3(&net, r3_layers, 1); - - tk::dnn::Conv2d c4(&net, 64, 1, 1, 1, 1, 0, 0, c4_bin, true); - tk::dnn::Activation a4(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c5(&net, 32, 1, 1, 1, 1, 0, 0, c5_bin, true); - tk::dnn::Activation a5(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c6(&net, 64, 3, 3, 1, 1, 1, 1, c6_bin, true); - tk::dnn::Activation a6(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s7(&net, &a4); - - tk::dnn::Conv2d c8(&net, 64, 1, 1, 1, 1, 0, 0, c8_bin, true); - tk::dnn::Activation a8(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Layer *r9_layers[2] = {&a8, &a2}; - tk::dnn::Route r9(&net, r9_layers, 2); - - tk::dnn::Conv2d c10(&net, 64, 1, 1, 1, 1, 0, 0, c10_bin, true); - tk::dnn::Activation a10(&net, tk::dnn::ACTIVATION_MISH); - - // downsample - tk::dnn::Conv2d c11(&net, 128, 3, 3, 2, 2, 1, 1, c11_bin, true); - tk::dnn::Activation a11(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c12(&net, 64, 1, 1, 1, 1, 0, 0, c12_bin, true); - tk::dnn::Activation a12(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Layer *r13_layers[1] = {&a11}; - tk::dnn::Route r13(&net, r13_layers, 1); - - tk::dnn::Conv2d c14(&net, 64, 1, 1, 1, 1, 0, 0, c14_bin, true); - tk::dnn::Activation a14(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c15(&net, 64, 1, 1, 1, 1, 0, 0, c15_bin, true); - tk::dnn::Activation a15(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c16(&net, 64, 3, 3, 1, 1, 1, 1, c16_bin, true); - tk::dnn::Activation a16(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s17(&net, &a14); - - tk::dnn::Conv2d c18(&net, 64, 1, 1, 1, 1, 0, 0, c18_bin, true); - tk::dnn::Activation a18(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c19(&net, 64, 3, 3, 1, 1, 1, 1, c19_bin, true); - tk::dnn::Activation a19(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s20(&net, &s17); - - tk::dnn::Conv2d c21(&net, 64, 1, 1, 1, 1, 0, 0, c21_bin, true); - tk::dnn::Activation a21(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Layer *r22_layers[2] = {&a21, &a12}; - tk::dnn::Route r22(&net, r22_layers, 2); - - tk::dnn::Conv2d c23(&net, 128, 1, 1, 1, 1, 0, 0, c23_bin, true); - tk::dnn::Activation a23(&net, tk::dnn::ACTIVATION_MISH); - - //downsample - tk::dnn::Conv2d c24(&net, 256, 3, 3, 2, 2, 1, 1, c24_bin, true); - tk::dnn::Activation a24(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c25(&net, 128, 1, 1, 1, 1, 0, 0, c25_bin, true); - tk::dnn::Activation a25(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Layer *r26_layers[1] = {&a24}; - tk::dnn::Route r26(&net, r26_layers, 1); - - tk::dnn::Conv2d c27(&net, 128, 1, 1, 1, 1, 0, 0, c27_bin, true); - tk::dnn::Activation a27(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c28(&net, 128, 1, 1, 1, 1, 0, 0, c28_bin, true); - tk::dnn::Activation a28(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c29(&net, 128, 3, 3, 1, 1, 1, 1, c29_bin, true); - tk::dnn::Activation a29(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s30(&net, &a27); - - tk::dnn::Conv2d c31(&net, 128, 1, 1, 1, 1, 0, 0, c31_bin, true); - tk::dnn::Activation a31(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c32(&net, 128, 3, 3, 1, 1, 1, 1, c32_bin, true); - tk::dnn::Activation a32(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s33(&net, &s30); - - tk::dnn::Conv2d c34(&net, 128, 1, 1, 1, 1, 0, 0, c34_bin, true); - tk::dnn::Activation a34(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c35(&net, 128, 3, 3, 1, 1, 1, 1, c35_bin, true); - tk::dnn::Activation a35(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s36(&net, &s33); - - tk::dnn::Conv2d c37(&net, 128, 1, 1, 1, 1, 0, 0, c37_bin, true); - tk::dnn::Activation a37(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c38(&net, 128, 3, 3, 1, 1, 1, 1, c38_bin, true); - tk::dnn::Activation a38(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s39(&net, &s36); - - tk::dnn::Conv2d c40(&net, 128, 1, 1, 1, 1, 0, 0, c40_bin, true); - tk::dnn::Activation a40(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c41(&net, 128, 3, 3, 1, 1, 1, 1, c41_bin, true); - tk::dnn::Activation a41(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s42(&net, &s39); - - tk::dnn::Conv2d c43(&net, 128, 1, 1, 1, 1, 0, 0, c43_bin, true); - tk::dnn::Activation a43(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c44(&net, 128, 3, 3, 1, 1, 1, 1, c44_bin, true); - tk::dnn::Activation a44(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s45(&net, &s42); - - tk::dnn::Conv2d c46(&net, 128, 1, 1, 1, 1, 0, 0, c46_bin, true); - tk::dnn::Activation a46(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c47(&net, 128, 3, 3, 1, 1, 1, 1, c47_bin, true); - tk::dnn::Activation a47(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s48(&net, &s45); - - tk::dnn::Conv2d c49(&net, 128, 1, 1, 1, 1, 0, 0, c49_bin, true); - tk::dnn::Activation a49(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c50(&net, 128, 3, 3, 1, 1, 1, 1, c50_bin, true); - tk::dnn::Activation a50(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s51(&net, &s48); - - tk::dnn::Conv2d c52(&net, 128, 1, 1, 1, 1, 0, 0, c52_bin, true); - tk::dnn::Activation a52(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Layer *r53_layers[2] = {&a52, &a25}; - tk::dnn::Route r53(&net, r53_layers, 2); - - tk::dnn::Conv2d c54(&net, 256, 1, 1, 1, 1, 0, 0, c54_bin, true); - tk::dnn::Activation a54(&net, tk::dnn::ACTIVATION_MISH); - - //downsample - tk::dnn::Conv2d c55(&net, 512, 3, 3, 2, 2, 1, 1, c55_bin, true); - tk::dnn::Activation a55(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c56(&net, 256, 1, 1, 1, 1, 0, 0, c56_bin, true); - tk::dnn::Activation a56(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Layer *r57_layers[1] = {&a55}; - tk::dnn::Route r57(&net, r57_layers, 1); - - tk::dnn::Conv2d c58(&net, 256, 1, 1, 1, 1, 0, 0, c58_bin, true); - tk::dnn::Activation a58(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c59(&net, 256, 1, 1, 1, 1, 0, 0, c59_bin, true); - tk::dnn::Activation a59(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c60(&net, 256, 3, 3, 1, 1, 1, 1, c60_bin, true); - tk::dnn::Activation a60(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s61(&net, &a58); - - tk::dnn::Conv2d c62(&net, 256, 1, 1, 1, 1, 0, 0, c62_bin, true); - tk::dnn::Activation a62(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c63(&net, 256, 3, 3, 1, 1, 1, 1, c63_bin, true); - tk::dnn::Activation a63(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s64(&net, &s61); - - tk::dnn::Conv2d c65(&net, 256, 1, 1, 1, 1, 0, 0, c65_bin, true); - tk::dnn::Activation a65(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c66(&net, 256, 3, 3, 1, 1, 1, 1, c66_bin, true); - tk::dnn::Activation a66(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s67(&net, &s64); - - tk::dnn::Conv2d c68(&net, 256, 1, 1, 1, 1, 0, 0, c68_bin, true); - tk::dnn::Activation a68(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c69(&net, 256, 3, 3, 1, 1, 1, 1, c69_bin, true); - tk::dnn::Activation a69(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s70(&net, &s67); - - tk::dnn::Conv2d c71(&net, 256, 1, 1, 1, 1, 0, 0, c71_bin, true); - tk::dnn::Activation a71(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c72(&net, 256, 3, 3, 1, 1, 1, 1, c72_bin, true); - tk::dnn::Activation a72(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s73(&net, &s70); - - tk::dnn::Conv2d c74(&net, 256, 1, 1, 1, 1, 0, 0, c74_bin, true); - tk::dnn::Activation a74(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c75(&net, 256, 3, 3, 1, 1, 1, 1, c75_bin, true); - tk::dnn::Activation a75(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s76(&net, &s73); - - tk::dnn::Conv2d c77(&net, 256, 1, 1, 1, 1, 0, 0, c77_bin, true); - tk::dnn::Activation a77(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c78(&net, 256, 3, 3, 1, 1, 1, 1, c78_bin, true); - tk::dnn::Activation a78(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s79(&net, &s76); - - tk::dnn::Conv2d c80(&net, 256, 1, 1, 1, 1, 0, 0, c80_bin, true); - tk::dnn::Activation a80(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c81(&net, 256, 3, 3, 1, 1, 1, 1, c81_bin, true); - tk::dnn::Activation a81(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s82(&net, &s79); - - tk::dnn::Conv2d c83(&net, 256, 1, 1, 1, 1, 0, 0, c83_bin, true); - tk::dnn::Activation a83(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Layer *r84_layers[2] = {&a83, &a56}; - tk::dnn::Route r84(&net, r84_layers, 2); - - tk::dnn::Conv2d c85(&net, 512, 1, 1, 1, 1, 0, 0, c85_bin, true); - tk::dnn::Activation a85(&net, tk::dnn::ACTIVATION_MISH); - - //downsample - tk::dnn::Conv2d c86(&net, 1024, 3, 3, 2, 2, 1, 1, c86_bin, true); - tk::dnn::Activation a86(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c87(&net, 512, 1, 1, 1, 1, 0, 0, c87_bin, true); - tk::dnn::Activation a87(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Layer *r88_layers[1] = {&a86}; - tk::dnn::Route r88(&net, r88_layers, 1); - - tk::dnn::Conv2d c89(&net, 512, 1, 1, 1, 1, 0, 0, c89_bin, true); - tk::dnn::Activation a89(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c90(&net, 512, 1, 1, 1, 1, 0, 0, c90_bin, true); - tk::dnn::Activation a90(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c91(&net, 512, 3, 3, 1, 1, 1, 1, c91_bin, true); - tk::dnn::Activation a91(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s92(&net, &a89); - - tk::dnn::Conv2d c93(&net, 512, 1, 1, 1, 1, 0, 0, c93_bin, true); - tk::dnn::Activation a93(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c94(&net, 512, 3, 3, 1, 1, 1, 1, c94_bin, true); - tk::dnn::Activation a94(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s95(&net, &s92); - - tk::dnn::Conv2d c96(&net, 512, 1, 1, 1, 1, 0, 0, c96_bin, true); - tk::dnn::Activation a96(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c97(&net, 512, 3, 3, 1, 1, 1, 1, c97_bin, true); - tk::dnn::Activation a97(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s98(&net, &s95); - - tk::dnn::Conv2d c99(&net, 512, 1, 1, 1, 1, 0, 0, c99_bin, true); - tk::dnn::Activation a99(&net, tk::dnn::ACTIVATION_MISH); - tk::dnn::Conv2d c100(&net, 512, 3, 3, 1, 1, 1, 1, c100_bin, true); - tk::dnn::Activation a100(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Shortcut s101(&net, &s98); - - tk::dnn::Conv2d c102(&net, 512, 1, 1, 1, 1, 0, 0, c102_bin, true); - tk::dnn::Activation a102(&net, tk::dnn::ACTIVATION_MISH); - - tk::dnn::Layer *r103_layers[2] = {&a102, &a87}; - tk::dnn::Route r103(&net, r103_layers, 2); - - tk::dnn::Conv2d c104(&net, 1024, 1, 1, 1, 1, 0, 0, c104_bin, true); - tk::dnn::Activation a104(&net, tk::dnn::ACTIVATION_MISH); - - - //################ - tk::dnn::Conv2d c105(&net, 512, 1, 1, 1, 1, 0, 0, c105_bin, true); - tk::dnn::Activation a105(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c106(&net, 1024, 3, 3, 1, 1, 1, 1, c106_bin, true); - tk::dnn::Activation a106(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c107(&net, 512, 1, 1, 1, 1, 0, 0, c107_bin, true); - tk::dnn::Activation a107(&net, tk::dnn::ACTIVATION_LEAKY); - - //SPP - tk::dnn::Pooling p108(&net, 5, 5, 1, 1, 0, 0, tk::dnn::POOLING_MAX_FIXEDSIZE); - tk::dnn::Layer *r109_layers[1] = {&a107}; - tk::dnn::Route r109(&net, r109_layers, 1); - - tk::dnn::Pooling p110(&net, 9, 9, 1, 1, 0, 0, tk::dnn::POOLING_MAX_FIXEDSIZE); - tk::dnn::Layer *r111_layers[1] = {&a107}; - tk::dnn::Route r111(&net, r111_layers, 1); - - tk::dnn::Pooling p112(&net, 13, 13, 1, 1, 12, 12, tk::dnn::POOLING_MAX_FIXEDSIZE); - tk::dnn::Layer *r113_layers[4] = {&p112, &p110, &p108, &a107}; - tk::dnn::Route r113(&net, r113_layers, 4); - //END SPP - - tk::dnn::Conv2d c114(&net, 512, 1, 1, 1, 1, 0, 0, c114_bin, true); - tk::dnn::Activation a114(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c115(&net, 1024, 3, 3, 1, 1, 1, 1, c115_bin, true); - tk::dnn::Activation a115(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c116(&net, 512, 1, 1, 1, 1, 0, 0, c116_bin, true); - tk::dnn::Activation a116(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c117(&net, 256, 1, 1, 1, 1, 0, 0, c117_bin, true); - tk::dnn::Activation a117(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Upsample u118(&net, 2); - tk::dnn::Layer *r119_layers[1] = {&a85}; - tk::dnn::Route r119(&net, r119_layers, 1); - tk::dnn::Conv2d c120(&net, 256, 1, 1, 1, 1, 0, 0, c120_bin, true); - tk::dnn::Activation a120(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Layer *r121_layers[2] = {&a120,&u118}; - tk::dnn::Route r121(&net, r121_layers, 2); - - tk::dnn::Conv2d c122(&net, 256, 1, 1, 1, 1, 0, 0, c122_bin, true); - tk::dnn::Activation a122(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c123(&net, 512, 3, 3, 1, 1, 1, 1, c123_bin, true); - tk::dnn::Activation a123(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c124(&net, 256, 1, 1, 1, 1, 0, 0, c124_bin, true); - tk::dnn::Activation a124(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c125(&net, 512, 3, 3, 1, 1, 1, 1, c125_bin, true); - tk::dnn::Activation a125(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c126(&net, 256, 1, 1, 1, 1, 0, 0, c126_bin, true); - tk::dnn::Activation a126(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c127(&net, 128, 1, 1, 1, 1, 0, 0, c127_bin, true); - tk::dnn::Activation a127(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Upsample u128(&net, 2); - tk::dnn::Layer *r129_layers[1] = {&a54}; - tk::dnn::Route r129(&net, r129_layers, 1); - tk::dnn::Conv2d c130(&net, 128, 1, 1, 1, 1, 0, 0, c130_bin, true); - tk::dnn::Activation a130(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Layer *r131_layers[2] = {&a130,&u128}; - tk::dnn::Route r131(&net, r131_layers, 2); - - - tk::dnn::Conv2d c132(&net, 128, 1, 1, 1, 1, 0, 0, c132_bin, true); - tk::dnn::Activation a132(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c133(&net, 256, 3, 3, 1, 1, 1, 1, c133_bin, true); - tk::dnn::Activation a133(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c134(&net, 128, 1, 1, 1, 1, 0, 0, c134_bin, true); - tk::dnn::Activation a134(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c135(&net, 256, 3, 3, 1, 1, 1, 1, c135_bin, true); - tk::dnn::Activation a135(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c136(&net, 128, 1, 1, 1, 1, 0, 0, c136_bin, true); - tk::dnn::Activation a136(&net, tk::dnn::ACTIVATION_LEAKY); - - - tk::dnn::Conv2d c137(&net, 256, 3, 3, 1, 1, 1, 1, c137_bin, true); - tk::dnn::Activation a137(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c138(&net, 255, 1, 1, 1, 1, 0, 0, c138_bin, false); - tk::dnn::Yolo yolo139(&net, classes, 3, g139_bin, 3, 1.2); - - tk::dnn::Layer *r140_layers[1] = {&a136}; - tk::dnn::Route r140(&net, r140_layers, 1); - tk::dnn::Conv2d c141(&net, 256, 3, 3, 2, 2, 1, 1, c141_bin, true); - tk::dnn::Activation a141(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Layer *r142_layers[2] = {&a141,&a126}; - tk::dnn::Route r142(&net, r142_layers, 2); - - tk::dnn::Conv2d c143(&net, 256, 1, 1, 1, 1, 0, 0, c143_bin, true); - tk::dnn::Activation a143(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c144(&net, 512, 3, 3, 1, 1, 1, 1, c144_bin, true); - tk::dnn::Activation a144(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c145(&net, 256, 1, 1, 1, 1, 0, 0, c145_bin, true); - tk::dnn::Activation a145(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c146(&net, 512, 3, 3, 1, 1, 1, 1, c146_bin, true); - tk::dnn::Activation a146(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c147(&net, 256, 1, 1, 1, 1, 0, 0, c147_bin, true); - tk::dnn::Activation a147(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Conv2d c148(&net, 512, 3, 3, 1, 1, 1, 1, c148_bin, true); - tk::dnn::Activation a148(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c149(&net, 255, 1, 1, 1, 1, 0, 0, c149_bin, false); - tk::dnn::Yolo yolo150(&net, classes, 3, g150_bin, 3, 1.1); - - tk::dnn::Layer *r151_layers[1] = {&a147}; - tk::dnn::Route r151(&net, r151_layers, 1); - tk::dnn::Conv2d c152(&net, 512, 3, 3, 2, 2, 1, 1, c152_bin, true); - tk::dnn::Activation a152(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Layer *r153_layers[2] = {&a152,&a116}; - tk::dnn::Route r153(&net, r153_layers, 2); - - tk::dnn::Conv2d c154(&net, 512, 1, 1, 1, 1, 0, 0, c154_bin, true); - tk::dnn::Activation a154(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c155(&net, 1024, 3, 3, 1, 1, 1, 1, c155_bin, true); - tk::dnn::Activation a155(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c156(&net, 512, 1, 1, 1, 1, 0, 0, c156_bin, true); - tk::dnn::Activation a156(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c157(&net, 1024, 3, 3, 1, 1, 1, 1, c157_bin, true); - tk::dnn::Activation a157(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c158(&net, 512, 1, 1, 1, 1, 0, 0, c158_bin, true); - tk::dnn::Activation a158(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Conv2d c159(&net, 1024, 3, 3, 1, 1, 1, 1, c159_bin, true); - tk::dnn::Activation a159(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c160(&net, 255, 1, 1, 1, 1, 0, 0, c160_bin, false); - tk::dnn::Yolo yolo161(&net, classes, 3, g161_bin, 3, 1.05); - - - - - - - yolo[0] = &yolo139; - yolo[1] = &yolo150; - yolo[2] = &yolo161; - - // fill classes names - for (int i = 0; i < 3; i++) - { - yolo[i]->classesNames = {"person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck", "boat", "traffic light", "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow", "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee", "skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard", "tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple", "sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "sofa", "pottedplant", "bed", "diningtable", "toilet", "tvmonitor", "laptop", "mouse", "remote", "keyboard", "cell phone", "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear", "hair drier", "toothbrush"}; - } - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - // //convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo4")); - - // the network have 3 outputs - tk::dnn::dataDim_t out_dim[3]; - for (int i = 0; i < 3; i++) - out_dim[i] = yolo[i]->output_dim; - dnnType *cudnn_out[3], *rt_out[3]; - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); - { - dim1.print(); - TIMER_START - net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - - for (int i = 0; i < 3; i++) - cudnn_out[i] = yolo[i]->dstData; - - printCenteredTitle(" compute detections ", '=', 30); - TIMER_START - int ndets = 0; - tk::dnn::Yolo::detection *dets = tk::dnn::Yolo::allocateDetections(tk::dnn::Yolo::MAX_DETECTIONS, classes); - for (int i = 0; i < 3; i++) - yolo[i]->computeDetections(dets, ndets, net.input_dim.w, net.input_dim.h, 0.5); - tk::dnn::Yolo::mergeDetections(dets, ndets, classes); - - for (int j = 0; j < ndets; j++) - { - tk::dnn::Yolo::box b = dets[j].bbox; - int x0 = (b.x - b.w / 2.); - int x1 = (b.x + b.w / 2.); - int y0 = (b.y - b.h / 2.); - int y1 = (b.y + b.h / 2.); - - int cl = 0; - for (int c = 0; c < classes; ++c) - { - float prob = dets[j].prob[c]; - if (prob > 0) - cl = c; - } - std::cout << cl << ": " << x0 << " " << y0 << " " << x1 << " " << y1 << "\n"; - } - TIMER_STOP - - tk::dnn::dataDim_t dim2 = dim; - printCenteredTitle(" TENSORRT inference ", '=', 30); - { - dim2.print(); - TIMER_START - netRT.infer(dim2, data); - TIMER_STOP - dim2.print(); - } - - for (int i = 0; i < 3; i++) - rt_out[i] = (dnnType *)netRT.buffersRT[i + 1]; - - int ret_cudnn = 0, ret_tensorrt = 0, ret_cudnn_tensorrt = 0; - for (int i = 0; i < 3; i++) - { - printCenteredTitle((std::string(" YOLO ") + std::to_string(i) + " CHECK RESULTS ").c_str(), '=', 30); - dnnType *out, *out_h; - int odim = out_dim[i].tot(); - readBinaryFile(output_bins[i], odim, &out_h, &out); - std::cout<<"CUDNN vs correct"; - ret_cudnn |= checkResult(odim, cudnn_out[i], out) == 0 ? 0: ERROR_CUDNN; - std::cout<<"TRT vs correct"; - ret_tensorrt |= checkResult(odim, rt_out[i], out) == 0 ? 0 : ERROR_TENSORRT; - std::cout<<"CUDNN vs TRT "; - ret_cudnn_tensorrt |= checkResult(odim, cudnn_out[i], rt_out[i]) == 0 ? 0 : ERROR_CUDNNvsTENSORRT; - } - return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; -} diff --git a/tests/yolo_224/yolo_224.cfg b/tests/yolo_224/yolo_224.cfg deleted file mode 100644 index dd9206c..0000000 --- a/tests/yolo_224/yolo_224.cfg +++ /dev/null @@ -1,258 +0,0 @@ -[net] -# Testing -#batch=1 -#subdivisions=1 -# Training - batch=64 - subdivisions=16 -width=224 -height=224 -channels=3 -momentum=0.9 -decay=0.0005 -angle=0 -saturation = 1.5 -exposure = 1.5 -hue=.1 - -learning_rate=0.001 -burn_in=1000 -max_batches = 500200 -policy=steps -steps=400000,450000 -scales=.1,.1 - -[convolutional] -batch_normalize=1 -filters=32 -size=3 -stride=1 -pad=1 -activation=leaky - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=64 -size=3 -stride=1 -pad=1 -activation=leaky - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=128 -size=3 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=64 -size=1 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=128 -size=3 -stride=1 -pad=1 -activation=leaky - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=256 -size=3 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=128 -size=1 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=256 -size=3 -stride=1 -pad=1 -activation=leaky - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=512 -size=3 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=256 -size=1 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=512 -size=3 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=256 -size=1 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=512 -size=3 -stride=1 -pad=1 -activation=leaky - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=1024 -size=3 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=512 -size=1 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=1024 -size=3 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=512 -size=1 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=1024 -size=3 -stride=1 -pad=1 -activation=leaky - - -####### - -[convolutional] -batch_normalize=1 -size=3 -stride=1 -pad=1 -filters=1024 -activation=leaky - -[convolutional] -batch_normalize=1 -size=3 -stride=1 -pad=1 -filters=1024 -activation=leaky - -[route] -layers=-9 - -[convolutional] -batch_normalize=1 -size=1 -stride=1 -pad=1 -filters=64 -activation=leaky - -[reorg] -stride=2 - -[route] -layers=-1,-4 - -[convolutional] -batch_normalize=1 -size=3 -stride=1 -pad=1 -filters=1024 -activation=leaky - -[convolutional] -size=1 -stride=1 -pad=1 -filters=425 -activation=linear - - -[region] -anchors = 0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828 -bias_match=1 -classes=80 -coords=4 -num=5 -softmax=1 -jitter=.3 -rescore=1 - -object_scale=5 -noobject_scale=1 -class_scale=1 -coord_scale=1 - -absolute=1 -thresh = .6 -random=1 diff --git a/tests/yolo_224/yolo_224.cpp b/tests/yolo_224/yolo_224.cpp deleted file mode 100644 index c6d75ae..0000000 --- a/tests/yolo_224/yolo_224.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#include -#include "tkdnn.h" - -const char *input_bin = "yolo_224/layers/input.bin"; -const char *c0_bin = "yolo_224/layers/c0.bin"; -const char *c2_bin = "yolo_224/layers/c2.bin"; -const char *c4_bin = "yolo_224/layers/c4.bin"; -const char *c5_bin = "yolo_224/layers/c5.bin"; -const char *c6_bin = "yolo_224/layers/c6.bin"; -const char *c8_bin = "yolo_224/layers/c8.bin"; -const char *c9_bin = "yolo_224/layers/c9.bin"; -const char *c10_bin = "yolo_224/layers/c10.bin"; -const char *c12_bin = "yolo_224/layers/c12.bin"; -const char *c13_bin = "yolo_224/layers/c13.bin"; -const char *c14_bin = "yolo_224/layers/c14.bin"; -const char *c15_bin = "yolo_224/layers/c15.bin"; -const char *c16_bin = "yolo_224/layers/c16.bin"; -const char *c18_bin = "yolo_224/layers/c18.bin"; -const char *c19_bin = "yolo_224/layers/c19.bin"; -const char *c20_bin = "yolo_224/layers/c20.bin"; -const char *c21_bin = "yolo_224/layers/c21.bin"; -const char *c22_bin = "yolo_224/layers/c22.bin"; -const char *c23_bin = "yolo_224/layers/c23.bin"; -const char *c24_bin = "yolo_224/layers/c24.bin"; -const char *c26_bin = "yolo_224/layers/c26.bin"; -const char *c29_bin = "yolo_224/layers/c29.bin"; -const char *c30_bin = "yolo_224/layers/c30.bin"; -const char *g31_bin = "yolo_224/layers/g31.bin"; -const char *output_bin = "yolo_224/layers/output.bin"; - -int main() { - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 224, 224, 1); - tk::dnn::Network net(dim); - - tk::dnn::Conv2d c0 (&net, 32, 3, 3, 1, 1, 1, 1, c0_bin, true); - tk::dnn::Activation a0 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p1 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c2 (&net, 64, 3, 3, 1, 1, 1, 1, c2_bin, true); - tk::dnn::Activation a2 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p3 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c4 (&net, 128, 3, 3, 1, 1, 1, 1, c4_bin, true); - tk::dnn::Activation a4 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c5 (&net, 64, 1, 1, 1, 1, 0, 0, c5_bin, true); - tk::dnn::Activation a5 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c6 (&net, 128, 3, 3, 1, 1, 1, 1, c6_bin, true); - tk::dnn::Activation a6 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p7 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c8 (&net, 256, 3, 3, 1, 1, 1, 1, c8_bin, true); - tk::dnn::Activation a8 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c9 (&net, 128, 1, 1, 1, 1, 0, 0, c9_bin, true); - tk::dnn::Activation a9 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c10(&net, 256, 3, 3, 1, 1, 1, 1, c10_bin, true); - tk::dnn::Activation a10(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p11(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c12(&net, 512, 3, 3, 1, 1, 1, 1, c12_bin, true); - tk::dnn::Activation a12(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c13(&net, 256, 1, 1, 1, 1, 0, 0, c13_bin, true); - tk::dnn::Activation a13(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c14(&net, 512, 3, 3, 1, 1, 1, 1, c14_bin, true); - tk::dnn::Activation a14(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c15(&net, 256, 1, 1, 1, 1, 0, 0, c15_bin, true); - tk::dnn::Activation a15(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c16(&net, 512, 3, 3, 1, 1, 1, 1, c16_bin, true); - tk::dnn::Activation a16(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p17(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c18(&net, 1024, 3, 3, 1, 1, 1, 1, c18_bin, true); - tk::dnn::Activation a18(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c19(&net, 512, 1, 1, 1, 1, 0, 0, c19_bin, true); - tk::dnn::Activation a19(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c20(&net, 1024, 3, 3, 1, 1, 1, 1, c20_bin, true); - tk::dnn::Activation a20(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c21(&net, 512, 1, 1, 1, 1, 0, 0, c21_bin, true); - tk::dnn::Activation a21(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c22(&net, 1024, 3, 3, 1, 1, 1, 1, c22_bin, true); - tk::dnn::Activation a22(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c23(&net, 1024, 3, 3, 1, 1, 1, 1, c23_bin, true); - tk::dnn::Activation a23(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c24(&net, 1024, 3, 3, 1, 1, 1, 1, c24_bin, true); - tk::dnn::Activation a24(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Layer *m25_layers[1] = { &a16 }; - tk::dnn::Route m25(&net, m25_layers, 1); - tk::dnn::Conv2d c26(&net, 64, 1, 1, 1, 1, 0, 0, c26_bin, true); - tk::dnn::Activation a26(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Reorg r27(&net, 2); - - tk::dnn::Layer *m28_layers[2] = { &r27, &a24 }; - tk::dnn::Route m28(&net, m28_layers, 2); - - tk::dnn::Conv2d c29(&net, 1024, 3, 3, 1, 1, 1, 1, c29_bin, true); - tk::dnn::Activation a29(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c30(&net, 425, 1, 1, 1, 1, 0, 0, c30_bin, false); - tk::dnn::Region g31(&net, 80, 4, 5); - - tk::dnn::RegionInterpret rI(dim, g31.output_dim, 80, 4, 5, 0.6f, g31_bin); - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - //convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo_224")); - - dnnType *out_data, *out_data2; // cudnn output, tensorRT output - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - out_data = net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - - tk::dnn::dataDim_t dim2 = dim; - printCenteredTitle(" TENSORRT inference ", '=', 30); { - dim2.print(); - TIMER_START - out_data2 = netRT.infer(dim2, data); - TIMER_STOP - dim2.print(); - } - - printCenteredTitle(" CHECK RESULTS ", '=', 30); - dnnType *out, *out_h; - int out_dim = net.getOutputDim().tot(); - readBinaryFile(output_bin, out_dim, &out_h, &out); - - // std::cout<<"\n\nDetected objects: \n"; - // dnnType *output_h = new dnnType[rI.output_dim.tot()]; - // checkCuda(cudaMemcpy(output_h, out_data2, - // rI.output_dim.tot()*sizeof(dnnType), cudaMemcpyDeviceToHost)); - // rI.interpretData(output_h); - // rI.showImageResult(input_h); - - - std::cout<<"CUDNN vs correct"; - int ret_cudnn = checkResult(out_dim, out_data, out) == 0 ? 0: ERROR_CUDNN; - std::cout<<"TRT vs correct"; - int ret_tensorrt = checkResult(out_dim, out_data2, out) == 0 ? 0 : ERROR_TENSORRT; - std::cout<<"CUDNN vs TRT "; - int ret_cudnn_tensorrt = checkResult(out_dim, out_data, out_data2) == 0 ? 0 : ERROR_CUDNNvsTENSORRT; - - return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; -} diff --git a/tests/yolo_berkeley/yolo_berkeley.cpp b/tests/yolo_berkeley/yolo_berkeley.cpp deleted file mode 100644 index 1d40c15..0000000 --- a/tests/yolo_berkeley/yolo_berkeley.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#include -#include "tkdnn.h" - -const char *input_bin = "yolo_berkeley/layers/input.bin"; -const char *c0_bin = "yolo_berkeley/layers/c0.bin"; -const char *c2_bin = "yolo_berkeley/layers/c2.bin"; -const char *c4_bin = "yolo_berkeley/layers/c4.bin"; -const char *c5_bin = "yolo_berkeley/layers/c5.bin"; -const char *c6_bin = "yolo_berkeley/layers/c6.bin"; -const char *c8_bin = "yolo_berkeley/layers/c8.bin"; -const char *c9_bin = "yolo_berkeley/layers/c9.bin"; -const char *c10_bin = "yolo_berkeley/layers/c10.bin"; -const char *c12_bin = "yolo_berkeley/layers/c12.bin"; -const char *c13_bin = "yolo_berkeley/layers/c13.bin"; -const char *c14_bin = "yolo_berkeley/layers/c14.bin"; -const char *c15_bin = "yolo_berkeley/layers/c15.bin"; -const char *c16_bin = "yolo_berkeley/layers/c16.bin"; -const char *c18_bin = "yolo_berkeley/layers/c18.bin"; -const char *c19_bin = "yolo_berkeley/layers/c19.bin"; -const char *c20_bin = "yolo_berkeley/layers/c20.bin"; -const char *c21_bin = "yolo_berkeley/layers/c21.bin"; -const char *c22_bin = "yolo_berkeley/layers/c22.bin"; -const char *c23_bin = "yolo_berkeley/layers/c23.bin"; -const char *c24_bin = "yolo_berkeley/layers/c24.bin"; -const char *c26_bin = "yolo_berkeley/layers/c26.bin"; -const char *c29_bin = "yolo_berkeley/layers/c29.bin"; -const char *c30_bin = "yolo_berkeley/layers/c30.bin"; -const char *g31_bin = "yolo_berkeley/layers/g31.bin"; -const char *output_bin = "yolo_berkeley/layers/output.bin"; - -int main() { - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 416, 736, 1); - tk::dnn::Network net(dim); - - tk::dnn::Conv2d c0 (&net, 32, 3, 3, 1, 1, 1, 1, c0_bin, true); - tk::dnn::Activation a0 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p1 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c2 (&net, 64, 3, 3, 1, 1, 1, 1, c2_bin, true); - tk::dnn::Activation a2 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p3 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c4 (&net, 128, 3, 3, 1, 1, 1, 1, c4_bin, true); - tk::dnn::Activation a4 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c5 (&net, 64, 1, 1, 1, 1, 0, 0, c5_bin, true); - tk::dnn::Activation a5 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c6 (&net, 128, 3, 3, 1, 1, 1, 1, c6_bin, true); - tk::dnn::Activation a6 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p7 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c8 (&net, 256, 3, 3, 1, 1, 1, 1, c8_bin, true); - tk::dnn::Activation a8 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c9 (&net, 128, 1, 1, 1, 1, 0, 0, c9_bin, true); - tk::dnn::Activation a9 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c10(&net, 256, 3, 3, 1, 1, 1, 1, c10_bin, true); - tk::dnn::Activation a10(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p11(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c12(&net, 512, 3, 3, 1, 1, 1, 1, c12_bin, true); - tk::dnn::Activation a12(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c13(&net, 256, 1, 1, 1, 1, 0, 0, c13_bin, true); - tk::dnn::Activation a13(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c14(&net, 512, 3, 3, 1, 1, 1, 1, c14_bin, true); - tk::dnn::Activation a14(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c15(&net, 256, 1, 1, 1, 1, 0, 0, c15_bin, true); - tk::dnn::Activation a15(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c16(&net, 512, 3, 3, 1, 1, 1, 1, c16_bin, true); - tk::dnn::Activation a16(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p17(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c18(&net, 1024, 3, 3, 1, 1, 1, 1, c18_bin, true); - tk::dnn::Activation a18(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c19(&net, 512, 1, 1, 1, 1, 0, 0, c19_bin, true); - tk::dnn::Activation a19(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c20(&net, 1024, 3, 3, 1, 1, 1, 1, c20_bin, true); - tk::dnn::Activation a20(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c21(&net, 512, 1, 1, 1, 1, 0, 0, c21_bin, true); - tk::dnn::Activation a21(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c22(&net, 1024, 3, 3, 1, 1, 1, 1, c22_bin, true); - tk::dnn::Activation a22(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c23(&net, 1024, 3, 3, 1, 1, 1, 1, c23_bin, true); - tk::dnn::Activation a23(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c24(&net, 1024, 3, 3, 1, 1, 1, 1, c24_bin, true); - tk::dnn::Activation a24(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Layer *m25_layers[1] = { &a16 }; - tk::dnn::Route m25(&net, m25_layers, 1); - tk::dnn::Conv2d c26(&net, 64, 1, 1, 1, 1, 0, 0, c26_bin, true); - tk::dnn::Activation a26(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Reorg r27(&net, 2); - - tk::dnn::Layer *m28_layers[2] = { &r27, &a24 }; - tk::dnn::Route m28(&net, m28_layers, 2); - - tk::dnn::Conv2d c29(&net, 1024, 3, 3, 1, 1, 1, 1, c29_bin, true); - tk::dnn::Activation a29(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c30(&net, 75, 1, 1, 1, 1, 0, 0, c30_bin, false); - tk::dnn::Region g31(&net, 10, 4, 5); - - tk::dnn::RegionInterpret rI(dim, g31.output_dim, 10, 4, 5, 0.3f, g31_bin); - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - //convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo_berkeley")); - - dnnType *out_data, *out_data2; // cudnn output, tensorRT output - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - out_data = net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - - tk::dnn::dataDim_t dim2 = dim; - printCenteredTitle(" TENSORRT inference ", '=', 30); { - dim2.print(); - TIMER_START - out_data2 = netRT.infer(dim2, data); - TIMER_STOP - dim2.print(); - } - - printCenteredTitle(" CHECK RESULTS ", '=', 30); - dnnType *out, *out_h; - int out_dim = net.getOutputDim().tot(); - readBinaryFile(output_bin, out_dim, &out_h, &out); - - // std::cout<<"\n\nDetected objects: \n"; - // dnnType *output_h = new dnnType[rI.output_dim.tot()]; - // checkCuda(cudaMemcpy(output_h, out_data2, - // rI.output_dim.tot()*sizeof(dnnType), cudaMemcpyDeviceToHost)); - // rI.interpretData(output_h); - // rI.showImageResult(input_h); - - - std::cout<<"CUDNN vs correct"; - int ret_cudnn = checkResult(out_dim, out_data, out) == 0 ? 0: ERROR_CUDNN; - std::cout<<"TRT vs correct"; - int ret_tensorrt = checkResult(out_dim, out_data2, out) == 0 ? 0 : ERROR_TENSORRT; - std::cout<<"CUDNN vs TRT "; - int ret_cudnn_tensorrt = checkResult(out_dim, out_data, out_data2) == 0 ? 0 : ERROR_CUDNNvsTENSORRT; - - return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; -} diff --git a/tests/yolo_berkeley/yolov2-voc-10-resize-test.cfg b/tests/yolo_berkeley/yolov2-voc-10-resize-test.cfg deleted file mode 100644 index 184b32c..0000000 --- a/tests/yolo_berkeley/yolov2-voc-10-resize-test.cfg +++ /dev/null @@ -1,259 +0,0 @@ -[net] -# Testing -batch=1 -subdivisions=1 -# Training -#batch=64 -#subdivisions=8 -height=416 -width=736 -channels=3 -momentum=0.9 -decay=0.0005 -angle=0 -saturation = 1.5 -exposure = 1.5 -hue=.1 - -learning_rate=0.001 -burn_in=1000 -max_batches = 80200 -policy=steps -steps=40000,60000 -scales=.1,.1 - -[convolutional] -batch_normalize=1 -filters=32 -size=3 -stride=1 -pad=1 -activation=leaky - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=64 -size=3 -stride=1 -pad=1 -activation=leaky - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=128 -size=3 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=64 -size=1 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=128 -size=3 -stride=1 -pad=1 -activation=leaky - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=256 -size=3 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=128 -size=1 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=256 -size=3 -stride=1 -pad=1 -activation=leaky - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=512 -size=3 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=256 -size=1 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=512 -size=3 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=256 -size=1 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=512 -size=3 -stride=1 -pad=1 -activation=leaky - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=1024 -size=3 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=512 -size=1 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=1024 -size=3 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=512 -size=1 -stride=1 -pad=1 -activation=leaky - -[convolutional] -batch_normalize=1 -filters=1024 -size=3 -stride=1 -pad=1 -activation=leaky - - -####### - -[convolutional] -batch_normalize=1 -size=3 -stride=1 -pad=1 -filters=1024 -activation=leaky - -[convolutional] -batch_normalize=1 -size=3 -stride=1 -pad=1 -filters=1024 -activation=leaky - -[route] -layers=-9 - -[convolutional] -batch_normalize=1 -size=1 -stride=1 -pad=1 -filters=64 -activation=leaky - -[reorg] -stride=2 - -[route] -layers=-1,-4 - -[convolutional] -batch_normalize=1 -size=3 -stride=1 -pad=1 -filters=1024 -activation=leaky - -[convolutional] -size=1 -stride=1 -pad=1 -filters=75 -activation=linear - - -[region] -anchors = 0.4043,0.4167, 1.2109,1.1018, 2.7258,2.1215, 4.9477,3.9132, 7.9508,6.6806 -bias_match=1 -classes=10 -coords=4 -num=5 -softmax=1 -jitter=.3 -rescore=1 - -object_scale=5 -noobject_scale=1 -class_scale=1 -coord_scale=1 - -absolute=1 -thresh = .6 -random=0 -flip=1 diff --git a/tests/yolo_relu/yolo_relu.cfg b/tests/yolo_relu/yolo_relu.cfg deleted file mode 100644 index 0abab4e..0000000 --- a/tests/yolo_relu/yolo_relu.cfg +++ /dev/null @@ -1,258 +0,0 @@ -[net] -# Testing -#batch=1 -#subdivisions=1 -# Training - batch=64 - subdivisions=16 -width=608 -height=608 -channels=3 -momentum=0.9 -decay=0.0005 -angle=0 -saturation = 1.5 -exposure = 1.5 -hue=.1 - -learning_rate=0.001 -burn_in=1000 -max_batches = 500200 -policy=steps -steps=400000,450000 -scales=.1,.1 - -[convolutional] -batch_normalize=1 -filters=32 -size=3 -stride=1 -pad=1 -activation=relu - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=64 -size=3 -stride=1 -pad=1 -activation=relu - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=128 -size=3 -stride=1 -pad=1 -activation=relu - -[convolutional] -batch_normalize=1 -filters=64 -size=1 -stride=1 -pad=1 -activation=relu - -[convolutional] -batch_normalize=1 -filters=128 -size=3 -stride=1 -pad=1 -activation=relu - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=256 -size=3 -stride=1 -pad=1 -activation=relu - -[convolutional] -batch_normalize=1 -filters=128 -size=1 -stride=1 -pad=1 -activation=relu - -[convolutional] -batch_normalize=1 -filters=256 -size=3 -stride=1 -pad=1 -activation=relu - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=512 -size=3 -stride=1 -pad=1 -activation=relu - -[convolutional] -batch_normalize=1 -filters=256 -size=1 -stride=1 -pad=1 -activation=relu - -[convolutional] -batch_normalize=1 -filters=512 -size=3 -stride=1 -pad=1 -activation=relu - -[convolutional] -batch_normalize=1 -filters=256 -size=1 -stride=1 -pad=1 -activation=relu - -[convolutional] -batch_normalize=1 -filters=512 -size=3 -stride=1 -pad=1 -activation=relu - -[maxpool] -size=2 -stride=2 - -[convolutional] -batch_normalize=1 -filters=1024 -size=3 -stride=1 -pad=1 -activation=relu - -[convolutional] -batch_normalize=1 -filters=512 -size=1 -stride=1 -pad=1 -activation=relu - -[convolutional] -batch_normalize=1 -filters=1024 -size=3 -stride=1 -pad=1 -activation=relu - -[convolutional] -batch_normalize=1 -filters=512 -size=1 -stride=1 -pad=1 -activation=relu - -[convolutional] -batch_normalize=1 -filters=1024 -size=3 -stride=1 -pad=1 -activation=relu - - -####### - -[convolutional] -batch_normalize=1 -size=3 -stride=1 -pad=1 -filters=1024 -activation=relu - -[convolutional] -batch_normalize=1 -size=3 -stride=1 -pad=1 -filters=1024 -activation=relu - -[route] -layers=-9 - -[convolutional] -batch_normalize=1 -size=1 -stride=1 -pad=1 -filters=64 -activation=relu - -[reorg] -stride=2 - -[route] -layers=-1,-4 - -[convolutional] -batch_normalize=1 -size=3 -stride=1 -pad=1 -filters=1024 -activation=relu - -[convolutional] -size=1 -stride=1 -pad=1 -filters=425 -activation=linear - - -[region] -anchors = 0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828 -bias_match=1 -classes=80 -coords=4 -num=5 -softmax=1 -jitter=.3 -rescore=1 - -object_scale=5 -noobject_scale=1 -class_scale=1 -coord_scale=1 - -absolute=1 -thresh = .6 -random=1 diff --git a/tests/yolo_relu/yolo_relu.cpp b/tests/yolo_relu/yolo_relu.cpp deleted file mode 100644 index 30f9f3e..0000000 --- a/tests/yolo_relu/yolo_relu.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include -#include "tkdnn.h" - -const char *input_bin = "yolo_relu/layers/input.bin"; -const char *c0_bin = "yolo_relu/layers/c0.bin"; -const char *c2_bin = "yolo_relu/layers/c2.bin"; -const char *c4_bin = "yolo_relu/layers/c4.bin"; -const char *c5_bin = "yolo_relu/layers/c5.bin"; -const char *c6_bin = "yolo_relu/layers/c6.bin"; -const char *c8_bin = "yolo_relu/layers/c8.bin"; -const char *c9_bin = "yolo_relu/layers/c9.bin"; -const char *c10_bin = "yolo_relu/layers/c10.bin"; -const char *c12_bin = "yolo_relu/layers/c12.bin"; -const char *c13_bin = "yolo_relu/layers/c13.bin"; -const char *c14_bin = "yolo_relu/layers/c14.bin"; -const char *c15_bin = "yolo_relu/layers/c15.bin"; -const char *c16_bin = "yolo_relu/layers/c16.bin"; -const char *c18_bin = "yolo_relu/layers/c18.bin"; -const char *c19_bin = "yolo_relu/layers/c19.bin"; -const char *c20_bin = "yolo_relu/layers/c20.bin"; -const char *c21_bin = "yolo_relu/layers/c21.bin"; -const char *c22_bin = "yolo_relu/layers/c22.bin"; -const char *c23_bin = "yolo_relu/layers/c23.bin"; -const char *c24_bin = "yolo_relu/layers/c24.bin"; -const char *c26_bin = "yolo_relu/layers/c26.bin"; -const char *c29_bin = "yolo_relu/layers/c29.bin"; -const char *c30_bin = "yolo_relu/layers/c30.bin"; -const char *g31_bin = "yolo_relu/layers/g31.bin"; -const char *output_bin = "yolo_relu/layers/output.bin"; - -int main() { - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 608, 608, 1); - tk::dnn::Network net(dim); - - tk::dnn::Conv2d c0 (&net, 32, 3, 3, 1, 1, 1, 1, c0_bin, true); - tk::dnn::Activation a0 (&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Pooling p1 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c2 (&net, 64, 3, 3, 1, 1, 1, 1, c2_bin, true); - tk::dnn::Activation a2 (&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Pooling p3 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c4 (&net, 128, 3, 3, 1, 1, 1, 1, c4_bin, true); - tk::dnn::Activation a4 (&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c5 (&net, 64, 1, 1, 1, 1, 0, 0, c5_bin, true); - tk::dnn::Activation a5 (&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c6 (&net, 128, 3, 3, 1, 1, 1, 1, c6_bin, true); - tk::dnn::Activation a6 (&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Pooling p7 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c8 (&net, 256, 3, 3, 1, 1, 1, 1, c8_bin, true); - tk::dnn::Activation a8 (&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c9 (&net, 128, 1, 1, 1, 1, 0, 0, c9_bin, true); - tk::dnn::Activation a9 (&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c10(&net, 256, 3, 3, 1, 1, 1, 1, c10_bin, true); - tk::dnn::Activation a10(&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Pooling p11(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c12(&net, 512, 3, 3, 1, 1, 1, 1, c12_bin, true); - tk::dnn::Activation a12(&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c13(&net, 256, 1, 1, 1, 1, 0, 0, c13_bin, true); - tk::dnn::Activation a13(&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c14(&net, 512, 3, 3, 1, 1, 1, 1, c14_bin, true); - tk::dnn::Activation a14(&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c15(&net, 256, 1, 1, 1, 1, 0, 0, c15_bin, true); - tk::dnn::Activation a15(&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c16(&net, 512, 3, 3, 1, 1, 1, 1, c16_bin, true); - tk::dnn::Activation a16(&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Pooling p17(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c18(&net, 1024, 3, 3, 1, 1, 1, 1, c18_bin, true); - tk::dnn::Activation a18(&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c19(&net, 512, 1, 1, 1, 1, 0, 0, c19_bin, true); - tk::dnn::Activation a19(&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c20(&net, 1024, 3, 3, 1, 1, 1, 1, c20_bin, true); - tk::dnn::Activation a20(&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c21(&net, 512, 1, 1, 1, 1, 0, 0, c21_bin, true); - tk::dnn::Activation a21(&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c22(&net, 1024, 3, 3, 1, 1, 1, 1, c22_bin, true); - tk::dnn::Activation a22(&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c23(&net, 1024, 3, 3, 1, 1, 1, 1, c23_bin, true); - tk::dnn::Activation a23(&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c24(&net, 1024, 3, 3, 1, 1, 1, 1, c24_bin, true); - tk::dnn::Activation a24(&net, CUDNN_ACTIVATION_RELU); - - tk::dnn::Layer *m25_layers[1] = { &a16 }; - tk::dnn::Route m25(&net, m25_layers, 1); - tk::dnn::Conv2d c26(&net, 64, 1, 1, 1, 1, 0, 0, c26_bin, true); - tk::dnn::Activation a26(&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Reorg r27(&net, 2); - - tk::dnn::Layer *m28_layers[2] = { &r27, &a24 }; - tk::dnn::Route m28(&net, m28_layers, 2); - - tk::dnn::Conv2d c29(&net, 1024, 3, 3, 1, 1, 1, 1, c29_bin, true); - tk::dnn::Activation a29(&net, CUDNN_ACTIVATION_RELU); - tk::dnn::Conv2d c30(&net, 425, 1, 1, 1, 1, 0, 0, c30_bin, false); - tk::dnn::Region g31(&net, 80, 4, 5); - - tk::dnn::RegionInterpret rI(dim, g31.output_dim, 80, 4, 5, 0.3f, g31_bin); - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - //convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo_relu")); - - dnnType *out_data, *out_data2; // cudnn output, tensorRT output - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - out_data = net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - - tk::dnn::dataDim_t dim2 = dim; - printCenteredTitle(" TENSORRT inference ", '=', 30); { - dim2.print(); - TIMER_START - out_data2 = netRT.infer(dim2, data); - TIMER_STOP - dim2.print(); - } - - printCenteredTitle(" CHECK RESULTS ", '=', 30); - dnnType *out, *out_h; - int out_dim = net.getOutputDim().tot(); - readBinaryFile(output_bin, out_dim, &out_h, &out); - - // std::cout<<"\n\nDetected objects: \n"; - // dnnType *output_h = new dnnType[rI.output_dim.tot()]; - // checkCuda(cudaMemcpy(output_h, out_data2, - // rI.output_dim.tot()*sizeof(dnnType), cudaMemcpyDeviceToHost)); - // rI.interpretData(output_h, 608, 608); - // rI.showImageResult(input_h); - - std::cout<<"CUDNN vs correct"; - int ret_cudnn = checkResult(out_dim, out_data, out) == 0 ? 0: ERROR_CUDNN; - std::cout<<"TRT vs correct"; - int ret_tensorrt = checkResult(out_dim, out_data2, out) == 0 ? 0 : ERROR_TENSORRT; - std::cout<<"CUDNN vs TRT "; - int ret_cudnn_tensorrt = checkResult(out_dim, out_data, out_data2) == 0 ? 0 : ERROR_CUDNNvsTENSORRT; - - return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; -} diff --git a/tests/yolo_tiny/yolo_tiny.cpp b/tests/yolo_tiny/yolo_tiny.cpp deleted file mode 100644 index dd6857e..0000000 --- a/tests/yolo_tiny/yolo_tiny.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include "tkdnn.h" - -const char *input_bin = "yolo_tiny/layers/input.bin"; -const char *c0_bin = "yolo_tiny/layers/c0.bin"; -const char *c2_bin = "yolo_tiny/layers/c2.bin"; -const char *c4_bin = "yolo_tiny/layers/c4.bin"; -const char *c5_bin = "yolo_tiny/layers/c5.bin"; -const char *c6_bin = "yolo_tiny/layers/c6.bin"; -const char *c8_bin = "yolo_tiny/layers/c8.bin"; -const char *c10_bin = "yolo_tiny/layers/c10.bin"; -const char *c11_bin = "yolo_tiny/layers/c11.bin"; -const char *c12_bin = "yolo_tiny/layers/c12.bin"; -const char *c13_bin = "yolo_tiny/layers/c13.bin"; -const char *g14_bin = "yolo_tiny/layers/g14.bin"; -const char *output_bin = "yolo_tiny/layers/output.bin"; - -int main() { - - downloadWeightsifDoNotExist(input_bin, "yolo_tiny", "https://cloud.hipert.unimore.it/s/m3orfJr8pGrN5mQ/download"); - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 416, 416, 1); - tk::dnn::Network net(dim); - - tk::dnn::Conv2d c0 (&net, 16, 3, 3, 1, 1, 1, 1, c0_bin, true); - tk::dnn::Activation a0 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p1 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c2 (&net, 32, 3, 3, 1, 1, 1, 1, c2_bin, true); - tk::dnn::Activation a2 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p3 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c4 (&net, 64, 3, 3, 1, 1, 1, 1, c4_bin, true); - tk::dnn::Activation a4 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p5 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c6 (&net, 128, 3, 3, 1, 1, 1, 1, c6_bin, true); - tk::dnn::Activation a6 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p7(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c8(&net, 256, 3, 3, 1, 1, 1, 1, c8_bin, true); - tk::dnn::Activation a8(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p9(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c10(&net, 512, 3, 3, 1, 1, 1, 1, c10_bin, true); - tk::dnn::Activation a10(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Conv2d c11(&net, 1024, 3, 3, 1, 1, 1, 1, c11_bin, true); - tk::dnn::Activation a11(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c12(&net, 512, 3, 3, 1, 1, 1, 1, c12_bin, true); - tk::dnn::Activation a12(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c13(&net, 425, 1, 1, 1, 1, 0, 0, c13_bin, false); - tk::dnn::Region g14(&net, 80, 4, 5); - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - //convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo_tiny")); - - dnnType *out_data, *out_data2; // cudnn output, tensorRT output - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - out_data = net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - - tk::dnn::dataDim_t dim2 = dim; - printCenteredTitle(" TENSORRT inference ", '=', 30); { - dim2.print(); - TIMER_START - out_data2 = netRT.infer(dim2, data); - TIMER_STOP - dim2.print(); - } - - printCenteredTitle(" CHECK RESULTS ", '=', 30); - dnnType *out, *out_h; - int out_dim = net.getOutputDim().tot(); - readBinaryFile(output_bin, out_dim, &out_h, &out); - - std::cout<<"CUDNN vs correct"; - int ret_cudnn = checkResult(out_dim, out_data, out) == 0 ? 0: ERROR_CUDNN; - std::cout<<"TRT vs correct"; - int ret_tensorrt = checkResult(out_dim, out_data2, out) == 0 ? 0 : ERROR_TENSORRT; - std::cout<<"CUDNN vs TRT "; - int ret_cudnn_tensorrt = checkResult(out_dim, out_data, out_data2) == 0 ? 0 : ERROR_CUDNNvsTENSORRT; - - return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; -} diff --git a/tests/yolo_voc/yolo_voc.cpp b/tests/yolo_voc/yolo_voc.cpp deleted file mode 100644 index 868128b..0000000 --- a/tests/yolo_voc/yolo_voc.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#include -#include "tkdnn.h" - -const char *input_bin = "yolo_voc/layers/input.bin"; -const char *c0_bin = "yolo_voc/layers/c0.bin"; -const char *c2_bin = "yolo_voc/layers/c2.bin"; -const char *c4_bin = "yolo_voc/layers/c4.bin"; -const char *c5_bin = "yolo_voc/layers/c5.bin"; -const char *c6_bin = "yolo_voc/layers/c6.bin"; -const char *c8_bin = "yolo_voc/layers/c8.bin"; -const char *c9_bin = "yolo_voc/layers/c9.bin"; -const char *c10_bin = "yolo_voc/layers/c10.bin"; -const char *c12_bin = "yolo_voc/layers/c12.bin"; -const char *c13_bin = "yolo_voc/layers/c13.bin"; -const char *c14_bin = "yolo_voc/layers/c14.bin"; -const char *c15_bin = "yolo_voc/layers/c15.bin"; -const char *c16_bin = "yolo_voc/layers/c16.bin"; -const char *c18_bin = "yolo_voc/layers/c18.bin"; -const char *c19_bin = "yolo_voc/layers/c19.bin"; -const char *c20_bin = "yolo_voc/layers/c20.bin"; -const char *c21_bin = "yolo_voc/layers/c21.bin"; -const char *c22_bin = "yolo_voc/layers/c22.bin"; -const char *c23_bin = "yolo_voc/layers/c23.bin"; -const char *c24_bin = "yolo_voc/layers/c24.bin"; -const char *c26_bin = "yolo_voc/layers/c26.bin"; -const char *c29_bin = "yolo_voc/layers/c29.bin"; -const char *c30_bin = "yolo_voc/layers/c30.bin"; -const char *g31_bin = "yolo_voc/layers/g31.bin"; -const char *output_bin = "yolo_voc/layers/output.bin"; - -int main() { - - downloadWeightsifDoNotExist(input_bin, "yolo_voc", "https://cloud.hipert.unimore.it/s/DJC5Fi2pEjfNDP9/download"); - - // Network layout - tk::dnn::dataDim_t dim(1, 3, 416, 416, 1); - tk::dnn::Network net(dim); - - tk::dnn::Conv2d c0 (&net, 32, 3, 3, 1, 1, 1, 1, c0_bin, true); - tk::dnn::Activation a0 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p1 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c2 (&net, 64, 3, 3, 1, 1, 1, 1, c2_bin, true); - tk::dnn::Activation a2 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p3 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c4 (&net, 128, 3, 3, 1, 1, 1, 1, c4_bin, true); - tk::dnn::Activation a4 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c5 (&net, 64, 1, 1, 1, 1, 0, 0, c5_bin, true); - tk::dnn::Activation a5 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c6 (&net, 128, 3, 3, 1, 1, 1, 1, c6_bin, true); - tk::dnn::Activation a6 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p7 (&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c8 (&net, 256, 3, 3, 1, 1, 1, 1, c8_bin, true); - tk::dnn::Activation a8 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c9 (&net, 128, 1, 1, 1, 1, 0, 0, c9_bin, true); - tk::dnn::Activation a9 (&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c10(&net, 256, 3, 3, 1, 1, 1, 1, c10_bin, true); - tk::dnn::Activation a10(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p11(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c12(&net, 512, 3, 3, 1, 1, 1, 1, c12_bin, true); - tk::dnn::Activation a12(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c13(&net, 256, 1, 1, 1, 1, 0, 0, c13_bin, true); - tk::dnn::Activation a13(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c14(&net, 512, 3, 3, 1, 1, 1, 1, c14_bin, true); - tk::dnn::Activation a14(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c15(&net, 256, 1, 1, 1, 1, 0, 0, c15_bin, true); - tk::dnn::Activation a15(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c16(&net, 512, 3, 3, 1, 1, 1, 1, c16_bin, true); - tk::dnn::Activation a16(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Pooling p17(&net, 2, 2, 2, 2, 0, 0, tk::dnn::POOLING_MAX); - - tk::dnn::Conv2d c18(&net, 1024, 3, 3, 1, 1, 1, 1, c18_bin, true); - tk::dnn::Activation a18(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c19(&net, 512, 1, 1, 1, 1, 0, 0, c19_bin, true); - tk::dnn::Activation a19(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c20(&net, 1024, 3, 3, 1, 1, 1, 1, c20_bin, true); - tk::dnn::Activation a20(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c21(&net, 512, 1, 1, 1, 1, 0, 0, c21_bin, true); - tk::dnn::Activation a21(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c22(&net, 1024, 3, 3, 1, 1, 1, 1, c22_bin, true); - tk::dnn::Activation a22(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c23(&net, 1024, 3, 3, 1, 1, 1, 1, c23_bin, true); - tk::dnn::Activation a23(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c24(&net, 1024, 3, 3, 1, 1, 1, 1, c24_bin, true); - tk::dnn::Activation a24(&net, tk::dnn::ACTIVATION_LEAKY); - - tk::dnn::Layer *m25_layers[1] = { &a16 }; - tk::dnn::Route m25(&net, m25_layers, 1); - tk::dnn::Conv2d c26(&net, 64, 1, 1, 1, 1, 0, 0, c26_bin, true); - tk::dnn::Activation a26(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Reorg r27(&net, 2); - - tk::dnn::Layer *m28_layers[2] = { &r27, &a24 }; - tk::dnn::Route m28(&net, m28_layers, 2); - - tk::dnn::Conv2d c29(&net, 1024, 3, 3, 1, 1, 1, 1, c29_bin, true); - tk::dnn::Activation a29(&net, tk::dnn::ACTIVATION_LEAKY); - tk::dnn::Conv2d c30(&net, 125, 1, 1, 1, 1, 0, 0, c30_bin, false); - tk::dnn::Region g31(&net, 20, 4, 5); - - tk::dnn::RegionInterpret rI(dim, g31.output_dim, 20, 4, 5, 0.6f, g31_bin); - - // Load input - dnnType *data; - dnnType *input_h; - readBinaryFile(input_bin, dim.tot(), &input_h, &data); - - //print network model - net.print(); - - //convert network to tensorRT - tk::dnn::NetworkRT netRT(&net, net.getNetworkRTName("yolo_voc")); - - dnnType *out_data, *out_data2; // cudnn output, tensorRT output - - tk::dnn::dataDim_t dim1 = dim; //input dim - printCenteredTitle(" CUDNN inference ", '=', 30); { - dim1.print(); - TIMER_START - out_data = net.infer(dim1, data); - TIMER_STOP - dim1.print(); - } - - tk::dnn::dataDim_t dim2 = dim; - printCenteredTitle(" TENSORRT inference ", '=', 30); { - dim2.print(); - TIMER_START - out_data2 = netRT.infer(dim2, data); - TIMER_STOP - dim2.print(); - } - - printCenteredTitle(" CHECK RESULTS ", '=', 30); - dnnType *out, *out_h; - int out_dim = net.getOutputDim().tot(); - readBinaryFile(output_bin, out_dim, &out_h, &out); - std::cout<<"CUDNN vs correct"; - int ret_cudnn = checkResult(out_dim, out_data, out) == 0 ? 0: ERROR_CUDNN; - std::cout<<"TRT vs correct"; - int ret_tensorrt = checkResult(out_dim, out_data2, out) == 0 ? 0 : ERROR_TENSORRT; - std::cout<<"CUDNN vs TRT "; - int ret_cudnn_tensorrt = checkResult(out_dim, out_data, out_data2) == 0 ? 0 : ERROR_CUDNNvsTENSORRT; - - // std::cout<<"\n\nDetected objects: \n"; - // dnnType *output_h = new dnnType[rI.output_dim.tot()]; - // checkCuda(cudaMemcpy(output_h, out_data2, - // rI.output_dim.tot()*sizeof(dnnType), cudaMemcpyDeviceToHost)); - // rI.interpretData(output_h); - // rI.showImageResult(input_h); - - return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt; -}