Skip to content

Commit

Permalink
coverage never works without proper unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Mar 20, 2019
1 parent e9ac5f2 commit 20fb006
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 30 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE release CACHE STRING "Choose the type of build" FORCE)
endif()

set(COVERAGE OFF CACHE BOOL "Coverage")

project(ncnn)

option(NCNN_OPENMP "openmp support" ON)
Expand Down Expand Up @@ -52,6 +50,7 @@ endif()

if(NCNN_VULKAN)
find_package(Vulkan REQUIRED)
include_directories(${Vulkan_INCLUDE_DIR})
endif()

if(WIN32)
Expand Down
9 changes: 2 additions & 7 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src)

if(NCNN_VULKAN)
include_directories(${Vulkan_INCLUDE_DIR})
endif()

add_executable(benchncnn benchncnn.cpp)
set_property(TARGET benchncnn PROPERTY COMPILE_FLAGS "-fpie")
set_property(TARGET benchncnn PROPERTY LINK_FLAGS "-pie")
target_link_libraries(benchncnn PRIVATE ncnn)

if(NCNN_VULKAN)
target_link_libraries(benchncnn ncnn ${Vulkan_LIBRARY})
else()
target_link_libraries(benchncnn ncnn)
target_link_libraries(benchncnn PRIVATE ${Vulkan_LIBRARY})
endif()
32 changes: 25 additions & 7 deletions benchmark/benchncnn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,6 @@ void benchmark(const char* comment, void (*init)(ncnn::Net&), void (*run)(const
run(net);
run(net);

run(net);
run(net);
run(net);
run(net);
run(net);

double time_min = DBL_MAX;
double time_max = -DBL_MAX;
double time_avg = 0;
Expand All @@ -166,7 +160,7 @@ void benchmark(const char* comment, void (*init)(ncnn::Net&), void (*run)(const

time_avg /= g_loop_count;

fprintf(stderr, "%-20s min = %7.2f max = %7.2f avg = %7.2f\n", comment, time_min, time_max, time_avg);
fprintf(stderr, "%20s min = %7.2f max = %7.2f avg = %7.2f\n", comment, time_min, time_max, time_avg);
}

void squeezenet_init(ncnn::Net& net)
Expand Down Expand Up @@ -522,14 +516,23 @@ int main(int argc, char** argv)
// run
benchmark("squeezenet", squeezenet_init, squeezenet_run);

#if NCNN_VULKAN
if (!g_use_vulkan_compute)
#endif // NCNN_VULKAN
benchmark("squeezenet-int8", squeezenet_int8_init, squeezenet_run);

benchmark("mobilenet", mobilenet_init, mobilenet_run);

#if NCNN_VULKAN
if (!g_use_vulkan_compute)
#endif // NCNN_VULKAN
benchmark("mobilenet-int8", mobilenet_int8_init, mobilenet_run);

benchmark("mobilenet_v2", mobilenet_v2_init, mobilenet_v2_run);

// #if NCNN_VULKAN
// if (!g_use_vulkan_compute)
// #endif // NCNN_VULKAN
// benchmark("mobilenet_v2-int8", mobilenet_v2_int8_init, mobilenet_v2_run);

benchmark("shufflenet", shufflenet_init, shufflenet_run);
Expand All @@ -540,10 +543,16 @@ int main(int argc, char** argv)

benchmark("googlenet", googlenet_init, googlenet_run);

#if NCNN_VULKAN
if (!g_use_vulkan_compute)
#endif // NCNN_VULKAN
benchmark("googlenet-int8", googlenet_int8_init, googlenet_run);

benchmark("resnet18", resnet18_init, resnet18_run);

#if NCNN_VULKAN
if (!g_use_vulkan_compute)
#endif // NCNN_VULKAN
benchmark("resnet18-int8", resnet18_int8_init, resnet18_run);

benchmark("alexnet", alexnet_init, alexnet_run);
Expand All @@ -552,14 +561,23 @@ int main(int argc, char** argv)

benchmark("resnet50", resnet50_init, resnet50_run);

#if NCNN_VULKAN
if (!g_use_vulkan_compute)
#endif // NCNN_VULKAN
benchmark("resnet50-int8", resnet50_int8_init, resnet50_run);

benchmark("squeezenet-ssd", squeezenet_ssd_init, squeezenet_ssd_run);

#if NCNN_VULKAN
if (!g_use_vulkan_compute)
#endif // NCNN_VULKAN
benchmark("squeezenet-ssd-int8", squeezenet_ssd_int8_init, squeezenet_ssd_run);

benchmark("mobilenet-ssd", mobilenet_ssd_init, mobilenet_ssd_run);

#if NCNN_VULKAN
if (!g_use_vulkan_compute)
#endif // NCNN_VULKAN
benchmark("mobilenet-ssd-int8", mobilenet_ssd_int8_init, mobilenet_ssd_run);

benchmark("mobilenet-yolo", mobilenet_yolo_init, mobilenet_yolo_run);
Expand Down
6 changes: 0 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/layer)
if(NCNN_VULKAN)
find_program(GLSLANGVALIDATOR_EXECUTABLE NAMES glslangValidator PATHS $ENV{VULKAN_SDK}/bin NO_CMAKE_FIND_ROOT_PATH)
message(STATUS "Found glslangValidator: ${GLSLANGVALIDATOR_EXECUTABLE}")
include_directories(${Vulkan_INCLUDE_DIR})
endif()

set(ncnn_SRCS
Expand Down Expand Up @@ -185,7 +184,6 @@ ncnn_add_layer(ROIAlign OFF)
ncnn_add_layer(Packing)
ncnn_add_layer(Requantize)

# message("SHADER_SPV_HEX_FILES = ${SHADER_SPV_HEX_FILES}")
add_custom_target(generate-spirv DEPENDS ${SHADER_SPV_HEX_FILES})

# create new
Expand All @@ -206,10 +204,6 @@ if(NCNN_OPENMP AND OpenMP_CXX_FOUND)
target_link_libraries(ncnn PUBLIC OpenMP::OpenMP_CXX)
endif()

if(COVERAGE)
target_compile_options(ncnn PRIVATE --coverage)
endif()

if(NCNN_INSTALL_SDK)
install(TARGETS ncnn ARCHIVE DESTINATION lib)
install(FILES
Expand Down
8 changes: 0 additions & 8 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,10 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src)

include_directories(${CMAKE_SOURCE_DIR}/src)

if(NCNN_VULKAN)
include_directories(${Vulkan_INCLUDE_DIR})
endif()

add_executable(ncnn2mem ncnn2mem.cpp)

target_link_libraries(ncnn2mem PRIVATE ncnn)

if(COVERAGE)
target_link_libraries(ncnn2mem PRIVATE --coverage)
endif()

if(NCNN_VULKAN)
target_link_libraries(ncnn2mem PRIVATE ${Vulkan_LIBRARY})
endif()

0 comments on commit 20fb006

Please sign in to comment.