|
|
|
@@ -98,8 +98,6 @@ public: |
|
|
|
static int g_warmup_loop_count = 3; |
|
|
|
static int g_loop_count = 4; |
|
|
|
|
|
|
|
static ncnn::Option g_default_option; |
|
|
|
|
|
|
|
static ncnn::UnlockedPoolAllocator g_blob_pool_allocator; |
|
|
|
static ncnn::PoolAllocator g_workspace_pool_allocator; |
|
|
|
|
|
|
|
@@ -109,11 +107,11 @@ static ncnn::VkAllocator* g_blob_vkallocator = 0; |
|
|
|
static ncnn::VkAllocator* g_staging_vkallocator = 0; |
|
|
|
#endif // NCNN_VULKAN |
|
|
|
|
|
|
|
void benchmark(const char* comment, const ncnn::Mat& in) |
|
|
|
void benchmark(const char* comment, const ncnn::Mat& in, const ncnn::Option& opt) |
|
|
|
{ |
|
|
|
ncnn::BenchNet net; |
|
|
|
|
|
|
|
net.opt = g_default_option; |
|
|
|
net.opt = opt; |
|
|
|
|
|
|
|
#if NCNN_VULKAN |
|
|
|
if (net.opt.use_vulkan_compute) |
|
|
|
@@ -228,24 +226,26 @@ int main(int argc, char** argv) |
|
|
|
#endif // NCNN_VULKAN |
|
|
|
|
|
|
|
// default option |
|
|
|
g_default_option.lightmode = true; |
|
|
|
g_default_option.num_threads = num_threads; |
|
|
|
g_default_option.blob_allocator = &g_blob_pool_allocator; |
|
|
|
g_default_option.workspace_allocator = &g_workspace_pool_allocator; |
|
|
|
ncnn::Option opt; |
|
|
|
opt.lightmode = true; |
|
|
|
opt.num_threads = num_threads; |
|
|
|
opt.blob_allocator = &g_blob_pool_allocator; |
|
|
|
opt.workspace_allocator = &g_workspace_pool_allocator; |
|
|
|
#if NCNN_VULKAN |
|
|
|
g_default_option.blob_vkallocator = g_blob_vkallocator; |
|
|
|
g_default_option.workspace_vkallocator = g_blob_vkallocator; |
|
|
|
g_default_option.staging_vkallocator = g_staging_vkallocator; |
|
|
|
opt.blob_vkallocator = g_blob_vkallocator; |
|
|
|
opt.workspace_vkallocator = g_blob_vkallocator; |
|
|
|
opt.staging_vkallocator = g_staging_vkallocator; |
|
|
|
#endif // NCNN_VULKAN |
|
|
|
g_default_option.use_winograd_convolution = true; |
|
|
|
g_default_option.use_sgemm_convolution = true; |
|
|
|
g_default_option.use_int8_inference = true; |
|
|
|
g_default_option.use_vulkan_compute = use_vulkan_compute; |
|
|
|
g_default_option.use_fp16_packed = true; |
|
|
|
g_default_option.use_fp16_storage = true; |
|
|
|
g_default_option.use_fp16_arithmetic = true; |
|
|
|
g_default_option.use_int8_storage = true; |
|
|
|
g_default_option.use_int8_arithmetic = true; |
|
|
|
opt.use_winograd_convolution = true; |
|
|
|
opt.use_sgemm_convolution = true; |
|
|
|
opt.use_int8_inference = true; |
|
|
|
opt.use_vulkan_compute = use_vulkan_compute; |
|
|
|
opt.use_fp16_packed = true; |
|
|
|
opt.use_fp16_storage = true; |
|
|
|
opt.use_fp16_arithmetic = true; |
|
|
|
opt.use_int8_storage = true; |
|
|
|
opt.use_int8_arithmetic = true; |
|
|
|
opt.use_packing_layout = true; |
|
|
|
|
|
|
|
ncnn::set_cpu_powersave(powersave); |
|
|
|
|
|
|
|
@@ -258,84 +258,116 @@ int main(int argc, char** argv) |
|
|
|
fprintf(stderr, "gpu_device = %d\n", gpu_device); |
|
|
|
|
|
|
|
// run |
|
|
|
benchmark("squeezenet", ncnn::Mat(227, 227, 3)); |
|
|
|
benchmark("squeezenet", ncnn::Mat(227, 227, 3), opt); |
|
|
|
|
|
|
|
#if NCNN_VULKAN |
|
|
|
if (!use_vulkan_compute) |
|
|
|
#endif // NCNN_VULKAN |
|
|
|
benchmark("squeezenet_int8", ncnn::Mat(227, 227, 3)); |
|
|
|
{ |
|
|
|
opt.use_packing_layout = false; |
|
|
|
benchmark("squeezenet_int8", ncnn::Mat(227, 227, 3), opt); |
|
|
|
opt.use_packing_layout = true; |
|
|
|
} |
|
|
|
|
|
|
|
benchmark("mobilenet", ncnn::Mat(224, 224, 3)); |
|
|
|
benchmark("mobilenet", ncnn::Mat(224, 224, 3), opt); |
|
|
|
|
|
|
|
#if NCNN_VULKAN |
|
|
|
if (!use_vulkan_compute) |
|
|
|
#endif // NCNN_VULKAN |
|
|
|
benchmark("mobilenet_int8", ncnn::Mat(224, 224, 3)); |
|
|
|
{ |
|
|
|
opt.use_packing_layout = false; |
|
|
|
benchmark("mobilenet_int8", ncnn::Mat(224, 224, 3), opt); |
|
|
|
opt.use_packing_layout = true; |
|
|
|
} |
|
|
|
|
|
|
|
benchmark("mobilenet_v2", ncnn::Mat(224, 224, 3)); |
|
|
|
benchmark("mobilenet_v2", ncnn::Mat(224, 224, 3), opt); |
|
|
|
|
|
|
|
// #if NCNN_VULKAN |
|
|
|
// if (!use_vulkan_compute) |
|
|
|
// #endif // NCNN_VULKAN |
|
|
|
// benchmark("mobilenet_v2_int8", ncnn::Mat(224, 224, 3)); |
|
|
|
// benchmark("mobilenet_v2_int8", ncnn::Mat(224, 224, 3), opt); |
|
|
|
|
|
|
|
benchmark("mobilenet_v3", ncnn::Mat(224, 224, 3)); |
|
|
|
benchmark("mobilenet_v3", ncnn::Mat(224, 224, 3), opt); |
|
|
|
|
|
|
|
benchmark("shufflenet", ncnn::Mat(224, 224, 3)); |
|
|
|
benchmark("shufflenet", ncnn::Mat(224, 224, 3), opt); |
|
|
|
|
|
|
|
benchmark("shufflenet_v2", ncnn::Mat(224, 224, 3)); |
|
|
|
benchmark("shufflenet_v2", ncnn::Mat(224, 224, 3), opt); |
|
|
|
|
|
|
|
benchmark("mnasnet", ncnn::Mat(224, 224, 3)); |
|
|
|
benchmark("mnasnet", ncnn::Mat(224, 224, 3), opt); |
|
|
|
|
|
|
|
benchmark("proxylessnasnet", ncnn::Mat(224, 224, 3)); |
|
|
|
benchmark("proxylessnasnet", ncnn::Mat(224, 224, 3), opt); |
|
|
|
|
|
|
|
benchmark("googlenet", ncnn::Mat(224, 224, 3)); |
|
|
|
benchmark("googlenet", ncnn::Mat(224, 224, 3), opt); |
|
|
|
|
|
|
|
#if NCNN_VULKAN |
|
|
|
if (!use_vulkan_compute) |
|
|
|
#endif // NCNN_VULKAN |
|
|
|
benchmark("googlenet_int8", ncnn::Mat(224, 224, 3)); |
|
|
|
{ |
|
|
|
opt.use_packing_layout = false; |
|
|
|
benchmark("googlenet_int8", ncnn::Mat(224, 224, 3), opt); |
|
|
|
opt.use_packing_layout = true; |
|
|
|
} |
|
|
|
|
|
|
|
benchmark("resnet18", ncnn::Mat(224, 224, 3)); |
|
|
|
benchmark("resnet18", ncnn::Mat(224, 224, 3), opt); |
|
|
|
|
|
|
|
#if NCNN_VULKAN |
|
|
|
if (!use_vulkan_compute) |
|
|
|
#endif // NCNN_VULKAN |
|
|
|
benchmark("resnet18_int8", ncnn::Mat(224, 224, 3)); |
|
|
|
{ |
|
|
|
opt.use_packing_layout = false; |
|
|
|
benchmark("resnet18_int8", ncnn::Mat(224, 224, 3), opt); |
|
|
|
opt.use_packing_layout = true; |
|
|
|
} |
|
|
|
|
|
|
|
benchmark("alexnet", ncnn::Mat(227, 227, 3)); |
|
|
|
benchmark("alexnet", ncnn::Mat(227, 227, 3), opt); |
|
|
|
|
|
|
|
benchmark("vgg16", ncnn::Mat(224, 224, 3)); |
|
|
|
benchmark("vgg16", ncnn::Mat(224, 224, 3), opt); |
|
|
|
|
|
|
|
#if NCNN_VULKAN |
|
|
|
if (!use_vulkan_compute) |
|
|
|
#endif // NCNN_VULKAN |
|
|
|
benchmark("vgg16_int8", ncnn::Mat(224, 224, 3)); |
|
|
|
{ |
|
|
|
opt.use_packing_layout = false; |
|
|
|
benchmark("vgg16_int8", ncnn::Mat(224, 224, 3), opt); |
|
|
|
opt.use_packing_layout = true; |
|
|
|
} |
|
|
|
|
|
|
|
benchmark("resnet50", ncnn::Mat(224, 224, 3)); |
|
|
|
benchmark("resnet50", ncnn::Mat(224, 224, 3), opt); |
|
|
|
|
|
|
|
#if NCNN_VULKAN |
|
|
|
if (!use_vulkan_compute) |
|
|
|
#endif // NCNN_VULKAN |
|
|
|
benchmark("resnet50_int8", ncnn::Mat(224, 224, 3)); |
|
|
|
{ |
|
|
|
opt.use_packing_layout = false; |
|
|
|
benchmark("resnet50_int8", ncnn::Mat(224, 224, 3), opt); |
|
|
|
opt.use_packing_layout = true; |
|
|
|
} |
|
|
|
|
|
|
|
benchmark("squeezenet_ssd", ncnn::Mat(300, 300, 3)); |
|
|
|
benchmark("squeezenet_ssd", ncnn::Mat(300, 300, 3), opt); |
|
|
|
|
|
|
|
#if NCNN_VULKAN |
|
|
|
if (!use_vulkan_compute) |
|
|
|
#endif // NCNN_VULKAN |
|
|
|
benchmark("squeezenet_ssd_int8", ncnn::Mat(300, 300, 3)); |
|
|
|
{ |
|
|
|
opt.use_packing_layout = false; |
|
|
|
benchmark("squeezenet_ssd_int8", ncnn::Mat(300, 300, 3), opt); |
|
|
|
opt.use_packing_layout = true; |
|
|
|
} |
|
|
|
|
|
|
|
benchmark("mobilenet_ssd", ncnn::Mat(300, 300, 3)); |
|
|
|
benchmark("mobilenet_ssd", ncnn::Mat(300, 300, 3), opt); |
|
|
|
|
|
|
|
#if NCNN_VULKAN |
|
|
|
if (!use_vulkan_compute) |
|
|
|
#endif // NCNN_VULKAN |
|
|
|
benchmark("mobilenet_ssd_int8", ncnn::Mat(300, 300, 3)); |
|
|
|
{ |
|
|
|
opt.use_packing_layout = false; |
|
|
|
benchmark("mobilenet_ssd_int8", ncnn::Mat(300, 300, 3), opt); |
|
|
|
opt.use_packing_layout = true; |
|
|
|
} |
|
|
|
|
|
|
|
benchmark("mobilenet_yolo", ncnn::Mat(416, 416, 3)); |
|
|
|
benchmark("mobilenet_yolo", ncnn::Mat(416, 416, 3), opt); |
|
|
|
|
|
|
|
benchmark("mobilenetv2_yolov3", ncnn::Mat(352, 352, 3)); |
|
|
|
benchmark("mobilenetv2_yolov3", ncnn::Mat(352, 352, 3), opt); |
|
|
|
|
|
|
|
#if NCNN_VULKAN |
|
|
|
delete g_blob_vkallocator; |
|
|
|
|