From ceef2470a5420ec2d51cffc62b6c732650d8264e Mon Sep 17 00:00:00 2001 From: Naiyang Lin Date: Tue, 12 May 2020 06:33:21 -0500 Subject: [PATCH] Add logger.h (#1753) --- examples/CMakeLists.txt | 1 - src/allocator.cpp | 111 ++++++++++++----------- src/command.cpp | 129 ++++++++++++++------------- src/cpu.cpp | 12 +-- src/datareader.h | 4 +- src/gpu.cpp | 111 ++++++++++++----------- src/layer.cpp | 1 - src/layer.h | 1 - src/layer/arm/convolution_arm.cpp | 6 +- src/layer/arm/deconvolution_arm.cpp | 2 +- src/layer/arm/pooling_arm.cpp | 4 +- src/layer/convolution.cpp | 4 +- src/layer/convolutiondepthwise.cpp | 4 +- src/layer/deconvolution.cpp | 2 +- src/layer/interp.cpp | 2 +- src/layer/pooling.cpp | 2 +- src/layer/softmax.cpp | 3 +- src/layer/vulkan/packing_vulkan.cpp | 12 +-- src/layer/yolodetectionoutput.cpp | 2 +- src/mat.cpp | 4 +- src/mat.h | 1 - src/modelbin.cpp | 19 ++-- src/net.cpp | 131 ++++++++++++++-------------- src/net.h | 1 - src/paramdict.cpp | 24 ++--- src/pipeline.cpp | 25 +++--- src/platform.h.in | 7 ++ tools/CMakeLists.txt | 14 +-- tools/caffe/CMakeLists.txt | 1 - tools/darknet/CMakeLists.txt | 1 - tools/onnx/CMakeLists.txt | 1 - tools/quantize/CMakeLists.txt | 1 - 32 files changed, 323 insertions(+), 320 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 7cc3e97020c..ecb70885b7f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,7 +1,6 @@ macro(ncnn_add_example name) add_executable(${name} ${name}.cpp) - target_compile_options(${name} PRIVATE -std=c++11) target_link_libraries(${name} PRIVATE ncnn ${OpenCV_LIBS}) # add test to a virtual project group diff --git a/src/allocator.cpp b/src/allocator.cpp index 31d500812ea..42464633cf3 100644 --- a/src/allocator.cpp +++ b/src/allocator.cpp @@ -14,7 +14,6 @@ #include "allocator.h" -#include #include #include "gpu.h" #include "pipeline.h" @@ -41,12 +40,12 @@ PoolAllocator::~PoolAllocator() if (!payouts.empty()) { - fprintf(stderr, "FATAL ERROR! pool allocator destroyed too early\n"); + NCNN_LOGE("FATAL ERROR! pool allocator destroyed too early"); std::list< std::pair >::iterator it = payouts.begin(); for (; it != payouts.end(); it++) { void* ptr = it->second; - fprintf(stderr, "%p still in use\n", ptr); + NCNN_LOGE("%p still in use", ptr); } } } @@ -70,7 +69,7 @@ void PoolAllocator::set_size_compare_ratio(float scr) { if (scr < 0.f || scr > 1.f) { - fprintf(stderr, "invalid size compare ratio %f\n", scr); + NCNN_LOGE("invalid size compare ratio %f", scr); return; } @@ -148,7 +147,7 @@ void PoolAllocator::fastFree(void* ptr) payouts_lock.unlock(); - fprintf(stderr, "FATAL ERROR! pool allocator get wild %p\n", ptr); + NCNN_LOGE("FATAL ERROR! pool allocator get wild %p", ptr); ncnn::fastFree(ptr); } @@ -163,12 +162,12 @@ UnlockedPoolAllocator::~UnlockedPoolAllocator() if (!payouts.empty()) { - fprintf(stderr, "FATAL ERROR! unlocked pool allocator destroyed too early\n"); + NCNN_LOGE("FATAL ERROR! unlocked pool allocator destroyed too early"); std::list< std::pair >::iterator it = payouts.begin(); for (; it != payouts.end(); it++) { void* ptr = it->second; - fprintf(stderr, "%p still in use\n", ptr); + NCNN_LOGE("%p still in use", ptr); } } } @@ -188,7 +187,7 @@ void UnlockedPoolAllocator::set_size_compare_ratio(float scr) { if (scr < 0.f || scr > 1.f) { - fprintf(stderr, "invalid size compare ratio %f\n", scr); + NCNN_LOGE("invalid size compare ratio %f", scr); return; } @@ -242,7 +241,7 @@ void UnlockedPoolAllocator::fastFree(void* ptr) } } - fprintf(stderr, "FATAL ERROR! unlocked pool allocator get wild %p\n", ptr); + NCNN_LOGE("FATAL ERROR! unlocked pool allocator get wild %p", ptr); ncnn::fastFree(ptr); } @@ -279,7 +278,7 @@ int VkAllocator::flush(VkBufferMemory* ptr) VkResult ret = vkFlushMappedMemoryRanges(vkdev->vkdevice(), 1, &mappedMemoryRange); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkFlushMappedMemoryRanges failed %d\n", ret); + NCNN_LOGE("vkFlushMappedMemoryRanges failed %d", ret); return -1; } @@ -301,7 +300,7 @@ int VkAllocator::invalidate(VkBufferMemory* ptr) VkResult ret = vkInvalidateMappedMemoryRanges(vkdev->vkdevice(), 1, &mappedMemoryRange); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkInvalidateMappedMemoryRanges failed %d\n", ret); + NCNN_LOGE("vkInvalidateMappedMemoryRanges failed %d", ret); return -1; } @@ -324,7 +323,7 @@ VkBuffer VkAllocator::create_buffer(size_t size, VkBufferUsageFlags usage) VkResult ret = vkCreateBuffer(vkdev->vkdevice(), &bufferCreateInfo, 0, &buffer); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateBuffer failed %d\n", ret); + NCNN_LOGE("vkCreateBuffer failed %d", ret); return 0; } @@ -343,7 +342,7 @@ VkDeviceMemory VkAllocator::allocate_memory(size_t size) VkResult ret = vkAllocateMemory(vkdev->vkdevice(), &memoryAllocateInfo, 0, &memory); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkAllocateMemory failed %d\n", ret); + NCNN_LOGE("vkAllocateMemory failed %d", ret); return 0; } @@ -369,7 +368,7 @@ VkDeviceMemory VkAllocator::allocate_dedicated_memory(size_t size, VkImage image VkResult ret = vkAllocateMemory(vkdev->vkdevice(), &memoryAllocateInfo, 0, &memory); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkAllocateMemory failed %d\n", ret); + NCNN_LOGE("vkAllocateMemory failed %d", ret); return 0; } @@ -401,7 +400,7 @@ VkImage VkAllocator::create_image(VkImageType type, int width, int height, int d VkResult ret = vkCreateImage(vkdev->vkdevice(), &imageCreateInfo, 0, &image); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateImage failed %d %d %d %d %d %d %d %d\n", ret, type, width, height, depth, format, tiling, usage); + NCNN_LOGE("vkCreateImage failed %d %d %d %d %d %d %d %d", ret, type, width, height, depth, format, tiling, usage); return 0; } @@ -431,7 +430,7 @@ VkImageView VkAllocator::create_imageview(VkImageViewType type, VkImage image, V VkResult ret = vkCreateImageView(vkdev->vkdevice(), &imageViewCreateInfo, 0, &imageview); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateImageView failed %d\n", ret); + NCNN_LOGE("vkCreateImageView failed %d", ret); return 0; } @@ -480,7 +479,7 @@ VkBlobAllocator::~VkBlobAllocator() void VkBlobAllocator::clear() { -// fprintf(stderr, "VkBlobAllocator %lu\n", buffer_blocks.size()); +// NCNN_LOGE("VkBlobAllocator %lu", buffer_blocks.size()); for (size_t i=0; i >::iterator it = buffer_budgets[i].begin(); // while (it != buffer_budgets[i].end()) // { -// fprintf(stderr, "VkBlobAllocator budget %p %lu %lu\n", ptr->buffer, it->first, it->second); +// NCNN_LOGE("VkBlobAllocator budget %p %lu %lu", ptr->buffer, it->first, it->second); // it++; // } @@ -512,7 +511,7 @@ void VkBlobAllocator::clear() // std::list< std::pair >::iterator it = image_memory_budgets[i].begin(); // while (it != image_memory_budgets[i].end()) // { -// fprintf(stderr, "VkBlobAllocator budget %p %lu %lu\n", memory, it->first, it->second); +// NCNN_LOGE("VkBlobAllocator budget %p %lu %lu", memory, it->first, it->second); // it++; // } @@ -564,7 +563,7 @@ VkBufferMemory* VkBlobAllocator::fastMalloc(size_t size) it->second -= aligned_size; } -// fprintf(stderr, "VkBlobAllocator M %p +%lu %lu\n", ptr->buffer, ptr->offset, ptr->capacity); +// NCNN_LOGE("VkBlobAllocator M %p +%lu %lu", ptr->buffer, ptr->offset, ptr->capacity); return ptr; } @@ -633,14 +632,14 @@ VkBufferMemory* VkBlobAllocator::fastMalloc(size_t size) } buffer_budgets.push_back(budget); -// fprintf(stderr, "VkBlobAllocator M %p +%lu %lu\n", ptr->buffer, ptr->offset, ptr->capacity); +// NCNN_LOGE("VkBlobAllocator M %p +%lu %lu", ptr->buffer, ptr->offset, ptr->capacity); return ptr; } void VkBlobAllocator::fastFree(VkBufferMemory* ptr) { -// fprintf(stderr, "VkBlobAllocator F %p +%lu %lu\n", ptr->buffer, ptr->offset, ptr->capacity); +// NCNN_LOGE("VkBlobAllocator F %p +%lu %lu", ptr->buffer, ptr->offset, ptr->capacity); const int buffer_block_count = buffer_blocks.size(); @@ -656,7 +655,7 @@ void VkBlobAllocator::fastFree(VkBufferMemory* ptr) if (block_index == -1) { - fprintf(stderr, "FATAL ERROR! unlocked VkBlobAllocator get wild %p\n", ptr->buffer); + NCNN_LOGE("FATAL ERROR! unlocked VkBlobAllocator get wild %p", ptr->buffer); delete ptr; @@ -713,7 +712,7 @@ VkImageMemory* VkBlobAllocator::fastMalloc(int dims, int w, int h, int c, size_t { if (elempack != 1 && elempack != 4 && elempack != 8) { - fprintf(stderr, "elempack must be 1 4 8\n"); + NCNN_LOGE("elempack must be 1 4 8"); return 0; } @@ -752,7 +751,7 @@ VkImageMemory* VkBlobAllocator::fastMalloc(int dims, int w, int h, int c, size_t if (width > (int)vkdev->info.max_image_dimension_1d) { - fprintf(stderr, "image dimension too large %d > %d\n", width, (int)vkdev->info.max_image_dimension_1d); + NCNN_LOGE("image dimension too large %d > %d", width, (int)vkdev->info.max_image_dimension_1d); return 0; } } @@ -763,7 +762,7 @@ VkImageMemory* VkBlobAllocator::fastMalloc(int dims, int w, int h, int c, size_t if (width > (int)vkdev->info.max_image_dimension_2d || height > (int)vkdev->info.max_image_dimension_2d) { - fprintf(stderr, "image dimension too large %d %d > %d\n", width, height, (int)vkdev->info.max_image_dimension_2d); + NCNN_LOGE("image dimension too large %d %d > %d", width, height, (int)vkdev->info.max_image_dimension_2d); return 0; } } @@ -774,7 +773,7 @@ VkImageMemory* VkBlobAllocator::fastMalloc(int dims, int w, int h, int c, size_t if (width > (int)vkdev->info.max_image_dimension_3d || height > (int)vkdev->info.max_image_dimension_3d || depth > (int)vkdev->info.max_image_dimension_3d) { - fprintf(stderr, "image dimension too large %d %d %d > %d\n", width, height, depth, (int)vkdev->info.max_image_dimension_3d); + NCNN_LOGE("image dimension too large %d %d %d > %d", width, height, depth, (int)vkdev->info.max_image_dimension_3d); return 0; } } @@ -856,7 +855,7 @@ VkImageMemory* VkBlobAllocator::fastMalloc(int dims, int w, int h, int c, size_t it->second -= aligned_size; } -// fprintf(stderr, "VkBlobAllocator M %p +%lu %lu\n", ptr->memory, ptr->bind_offset, ptr->bind_capacity); +// NCNN_LOGE("VkBlobAllocator M %p +%lu %lu", ptr->memory, ptr->bind_offset, ptr->bind_capacity); return ptr; } @@ -911,14 +910,14 @@ VkImageMemory* VkBlobAllocator::fastMalloc(int dims, int w, int h, int c, size_t } image_memory_budgets.push_back(budget); -// fprintf(stderr, "VkBlobAllocator M %p +%lu %lu\n", ptr->memory, ptr->bind_offset, ptr->bind_capacity); +// NCNN_LOGE("VkBlobAllocator M %p +%lu %lu", ptr->memory, ptr->bind_offset, ptr->bind_capacity); return ptr; } void VkBlobAllocator::fastFree(VkImageMemory* ptr) { -// fprintf(stderr, "VkBlobAllocator F %p +%lu %lu\n", ptr->memory, ptr->bind_offset, ptr->bind_capacity); +// NCNN_LOGE("VkBlobAllocator F %p +%lu %lu", ptr->memory, ptr->bind_offset, ptr->bind_capacity); const int image_memory_block_count = image_memory_blocks.size(); @@ -934,7 +933,7 @@ void VkBlobAllocator::fastFree(VkImageMemory* ptr) if (block_index == -1) { - fprintf(stderr, "FATAL ERROR! unlocked VkBlobAllocator get wild %p\n", ptr->memory); + NCNN_LOGE("FATAL ERROR! unlocked VkBlobAllocator get wild %p", ptr->memory); if (!ptr->command_refcount) { @@ -1024,7 +1023,7 @@ VkWeightAllocator::~VkWeightAllocator() void VkWeightAllocator::clear() { -// fprintf(stderr, "VkWeightAllocator %lu %lu\n", buffer_blocks.size(), dedicated_buffer_blocks.size()); +// NCNN_LOGE("VkWeightAllocator %lu %lu", buffer_blocks.size(), dedicated_buffer_blocks.size()); buffer_block_free_spaces.clear(); @@ -1077,7 +1076,7 @@ void VkWeightAllocator::clear() VkBufferMemory* VkWeightAllocator::fastMalloc(size_t size) { -// fprintf(stderr, "VkWeightAllocator fastMalloc %lu\n", size); +// NCNN_LOGE("VkWeightAllocator fastMalloc %lu", size); size_t aligned_size = alignSize(size, buffer_offset_alignment); @@ -1210,7 +1209,7 @@ VkBufferMemory* VkWeightAllocator::fastMalloc(size_t size) // ignore memoryRequirements.alignment as we always bind at zero offset vkBindBufferMemory(vkdev->vkdevice(), block->buffer, block->memory, 0); -// fprintf(stderr, "VkWeightAllocator M %p\n", block->buffer); +// NCNN_LOGE("VkWeightAllocator M %p", block->buffer); block->mapped_ptr = 0; if (mappable) @@ -1238,7 +1237,7 @@ VkBufferMemory* VkWeightAllocator::fastMalloc(size_t size) void VkWeightAllocator::fastFree(VkBufferMemory* ptr) { -// fprintf(stderr, "VkWeightAllocator F %p\n", ptr->buffer); +// NCNN_LOGE("VkWeightAllocator F %p", ptr->buffer); delete ptr; } @@ -1247,7 +1246,7 @@ VkImageMemory* VkWeightAllocator::fastMalloc(int dims, int w, int h, int c, size { if (elempack != 1 && elempack != 4 && elempack != 8 && elempack != 16 && elempack != 32 && elempack != 64) { - fprintf(stderr, "elempack must be 1 4 8 16 32 64\n"); + NCNN_LOGE("elempack must be 1 4 8 16 32 64"); return 0; } @@ -1295,7 +1294,7 @@ VkImageMemory* VkWeightAllocator::fastMalloc(int dims, int w, int h, int c, size if (width > (int)vkdev->info.max_image_dimension_1d) { - fprintf(stderr, "image dimension too large %d > %d\n", width, (int)vkdev->info.max_image_dimension_1d); + NCNN_LOGE("image dimension too large %d > %d", width, (int)vkdev->info.max_image_dimension_1d); return 0; } } @@ -1306,7 +1305,7 @@ VkImageMemory* VkWeightAllocator::fastMalloc(int dims, int w, int h, int c, size if (width > (int)vkdev->info.max_image_dimension_2d || height > (int)vkdev->info.max_image_dimension_2d) { - fprintf(stderr, "image dimension too large %d %d > %d\n", width, height, (int)vkdev->info.max_image_dimension_2d); + NCNN_LOGE("image dimension too large %d %d > %d", width, height, (int)vkdev->info.max_image_dimension_2d); return 0; } } @@ -1317,7 +1316,7 @@ VkImageMemory* VkWeightAllocator::fastMalloc(int dims, int w, int h, int c, size if (width > (int)vkdev->info.max_image_dimension_3d || height > (int)vkdev->info.max_image_dimension_3d || depth > (int)vkdev->info.max_image_dimension_3d) { - fprintf(stderr, "image dimension too large %d %d %d > %d\n", width, height, depth, (int)vkdev->info.max_image_dimension_3d); + NCNN_LOGE("image dimension too large %d %d %d > %d", width, height, depth, (int)vkdev->info.max_image_dimension_3d); return 0; } } @@ -1496,7 +1495,7 @@ VkImageMemory* VkWeightAllocator::fastMalloc(int dims, int w, int h, int c, size void VkWeightAllocator::fastFree(VkImageMemory* ptr) { -// fprintf(stderr, "VkWeightAllocator F %p\n", ptr->memory); +// NCNN_LOGE("VkWeightAllocator F %p", ptr->memory); if (!ptr->command_refcount) { @@ -1524,7 +1523,7 @@ void VkStagingAllocator::set_size_compare_ratio(float scr) { if (scr < 0.f || scr > 1.f) { - fprintf(stderr, "invalid size compare ratio %f\n", scr); + NCNN_LOGE("invalid size compare ratio %f", scr); return; } @@ -1533,13 +1532,13 @@ void VkStagingAllocator::set_size_compare_ratio(float scr) void VkStagingAllocator::clear() { -// fprintf(stderr, "VkStagingAllocator %lu\n", buffer_budgets.size()); +// NCNN_LOGE("VkStagingAllocator %lu", buffer_budgets.size()); for (std::list::iterator it = buffer_budgets.begin(); it != buffer_budgets.end(); it++) { VkBufferMemory* ptr = *it; -// fprintf(stderr, "VkStagingAllocator F %p\n", ptr->buffer); +// NCNN_LOGE("VkStagingAllocator F %p", ptr->buffer); vkUnmapMemory(vkdev->vkdevice(), ptr->memory); vkDestroyBuffer(vkdev->vkdevice(), ptr->buffer, 0); @@ -1565,7 +1564,7 @@ VkBufferMemory* VkStagingAllocator::fastMalloc(size_t size) { buffer_budgets.erase(it); -// fprintf(stderr, "VkStagingAllocator M %p %lu reused %lu\n", ptr->buffer, size, capacity); +// NCNN_LOGE("VkStagingAllocator M %p %lu reused %lu", ptr->buffer, size, capacity); return ptr; } @@ -1597,14 +1596,14 @@ VkBufferMemory* VkStagingAllocator::fastMalloc(size_t size) ptr->access_flags = 0; ptr->stage_flags = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; -// fprintf(stderr, "VkStagingAllocator M %p %lu\n", ptr->buffer, size); +// NCNN_LOGE("VkStagingAllocator M %p %lu", ptr->buffer, size); return ptr; } void VkStagingAllocator::fastFree(VkBufferMemory* ptr) { -// fprintf(stderr, "VkStagingAllocator F %p\n", ptr->buffer); +// NCNN_LOGE("VkStagingAllocator F %p", ptr->buffer); // return to buffer_budgets buffer_budgets.push_back(ptr); @@ -1657,14 +1656,14 @@ VkImageMemory* VkStagingAllocator::fastMalloc(int dims, int w, int h, int c, siz ptr->stage_flags = VK_PIPELINE_STAGE_HOST_BIT; ptr->command_refcount = 0; -// fprintf(stderr, "VkStagingAllocator M %p %d %d %d %d %d\n", ptr->image, dims, width, height, depth, format); +// NCNN_LOGE("VkStagingAllocator M %p %d %d %d %d %d", ptr->image, dims, width, height, depth, format); return ptr; } void VkStagingAllocator::fastFree(VkImageMemory* ptr) { -// fprintf(stderr, "VkStagingAllocator F %p\n", ptr->image); +// NCNN_LOGE("VkStagingAllocator F %p", ptr->image); free(ptr->mapped_ptr); @@ -1709,14 +1708,14 @@ VkBufferMemory* VkWeightStagingAllocator::fastMalloc(size_t size) ptr->access_flags = 0; ptr->stage_flags = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; -// fprintf(stderr, "VkWeightStagingAllocator M %p %lu\n", ptr->buffer, size); +// NCNN_LOGE("VkWeightStagingAllocator M %p %lu", ptr->buffer, size); return ptr; } void VkWeightStagingAllocator::fastFree(VkBufferMemory* ptr) { -// fprintf(stderr, "VkWeightStagingAllocator F %p\n", ptr->buffer); +// NCNN_LOGE("VkWeightStagingAllocator F %p", ptr->buffer); vkUnmapMemory(vkdev->vkdevice(), ptr->memory); vkDestroyBuffer(vkdev->vkdevice(), ptr->buffer, 0); @@ -1779,7 +1778,7 @@ VkImageMemory* VkAndroidHardwareBufferImageAllocator::fastMalloc(int /*dims*/, i ret = vkCreateImage(vkdev->vkdevice(), &imageCreateInfo, 0, &image); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateImage failed %d\n", ret); + NCNN_LOGE("vkCreateImage failed %d", ret); return 0; } @@ -1810,7 +1809,7 @@ VkImageMemory* VkAndroidHardwareBufferImageAllocator::fastMalloc(int /*dims*/, i ret = vkAllocateMemory(vkdev->vkdevice(), &memoryAllocateInfo, 0, &memory); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkAllocateMemory failed %d\n", ret); + NCNN_LOGE("vkAllocateMemory failed %d", ret); return 0; } @@ -1823,7 +1822,7 @@ VkImageMemory* VkAndroidHardwareBufferImageAllocator::fastMalloc(int /*dims*/, i ret = vkdev->vkBindImageMemory2KHR(vkdev->vkdevice(), 1, &bindImageMemoryInfo); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkBindImageMemory2KHR failed %d\n", ret); + NCNN_LOGE("vkBindImageMemory2KHR failed %d", ret); vkDestroyImage(vkdev->vkdevice(), image, 0); return 0; } @@ -1854,7 +1853,7 @@ VkImageMemory* VkAndroidHardwareBufferImageAllocator::fastMalloc(int /*dims*/, i ret = vkCreateImageView(vkdev->vkdevice(), &imageViewCreateInfo, 0, &imageview); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateImageView failed %d\n", ret); + NCNN_LOGE("vkCreateImageView failed %d", ret); vkDestroyImage(vkdev->vkdevice(), image, 0); vkFreeMemory(vkdev->vkdevice(), memory, 0); return 0; @@ -1896,7 +1895,7 @@ int VkAndroidHardwareBufferImageAllocator::init() ret = vkGetAndroidHardwareBufferPropertiesANDROID(vkdev->vkdevice(), hb, &bufferProperties); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkGetAndroidHardwareBufferPropertiesANDROID failed %d\n", ret); + NCNN_LOGE("vkGetAndroidHardwareBufferPropertiesANDROID failed %d", ret); return -1; } @@ -1921,7 +1920,7 @@ int VkAndroidHardwareBufferImageAllocator::init() ret = vkdev->vkCreateSamplerYcbcrConversionKHR(vkdev->vkdevice(), &samplerYcbcrConversionCreateInfo, 0, &samplerYcbcrConversion); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateSamplerYcbcrConversionKHR failed %d\n", ret); + NCNN_LOGE("vkCreateSamplerYcbcrConversionKHR failed %d", ret); return -1; } diff --git a/src/command.cpp b/src/command.cpp index 593cf8c6759..81f556e6e8c 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -16,7 +16,6 @@ #if NCNN_VULKAN -#include #include #include "option.h" #include "pipeline.h" @@ -86,7 +85,7 @@ VkCompute::~VkCompute() void VkCompute::record_upload(const Mat& src, VkMat& dst, const Option& opt) { -// fprintf(stderr, "record_upload buffer\n"); +// NCNN_LOGE("record_upload buffer"); Mat src_fp16; if (src.elemsize == src.elempack * 4u) @@ -122,7 +121,7 @@ void VkCompute::record_upload(const Mat& src, VkMat& dst, const Option& opt) // stash staging upload_staging_buffers.push_back(dst_staging); -// fprintf(stderr, "upload_staging_buffer %p -> %p +%d ~%d\n", src_fp16.data, dst_staging.buffer(), dst_staging.buffer_offset(), dst_staging.buffer_capacity()); +// NCNN_LOGE("upload_staging_buffer %p -> %p +%d ~%d", src_fp16.data, dst_staging.buffer(), dst_staging.buffer_offset(), dst_staging.buffer_capacity()); // memcpy src to device memcpy(dst_staging.mapped_ptr(), src_fp16.data, src_fp16.total() * src_fp16.elemsize); @@ -150,7 +149,7 @@ void VkCompute::record_upload(const Mat& src, VkMat& dst, const Option& opt) void VkCompute::record_upload(const Mat& src, VkImageMat& dst, const Option& opt) { -// fprintf(stderr, "record_upload image\n"); +// NCNN_LOGE("record_upload image"); Mat src_fp16; if (src.elemsize == src.elempack * 4u) @@ -212,7 +211,7 @@ void VkCompute::record_upload(const Mat& src, VkImageMat& dst, const Option& opt void VkCompute::record_download(const VkMat& src, Mat& dst, const Option& opt) { -// fprintf(stderr, "record_download buffer\n"); +// NCNN_LOGE("record_download buffer"); // resolve dst_elempack int dims = src.dims; @@ -334,7 +333,7 @@ void VkCompute::record_download(const VkMat& src, Mat& dst, const Option& opt) void VkCompute::record_download(const VkImageMat& src, Mat& dst, const Option& opt) { -// fprintf(stderr, "record_download image\n"); +// NCNN_LOGE("record_download image"); // resolve dst_elempack int dims = src.dims; @@ -456,7 +455,7 @@ void VkCompute::record_download(const VkImageMat& src, Mat& dst, const Option& o void VkCompute::record_buffer_to_image(const VkMat& src, VkImageMat& dst, const Option& opt) { -// fprintf(stderr, "record_buffer_to_image\n"); +// NCNN_LOGE("record_buffer_to_image"); // resolve dst_elempack int dims = src.dims; @@ -476,7 +475,7 @@ void VkCompute::record_buffer_to_image(const VkMat& src, VkImageMat& dst, const void VkCompute::record_image_to_buffer(const VkImageMat& src, VkMat& dst, const Option& opt) { -// fprintf(stderr, "record_image_to_buffer\n"); +// NCNN_LOGE("record_image_to_buffer"); // resolve dst_elempack int dims = src.dims; @@ -496,7 +495,7 @@ void VkCompute::record_image_to_buffer(const VkImageMat& src, VkMat& dst, const void VkCompute::record_clone(const Mat& src, VkMat& dst, const Option& opt) { -// fprintf(stderr, "record_clone host to buffer\n"); +// NCNN_LOGE("record_clone host to buffer"); if (!opt.blob_vkallocator->mappable) { @@ -531,7 +530,7 @@ void VkCompute::record_clone(const Mat& src, VkMat& dst, const Option& opt) void VkCompute::record_clone(const Mat& src, VkImageMat& dst, const Option& opt) { -// fprintf(stderr, "record_clone host to image\n"); +// NCNN_LOGE("record_clone host to image"); // host to staging VkMat dst_staging; @@ -548,7 +547,7 @@ void VkCompute::record_clone(const Mat& src, VkImageMat& dst, const Option& opt) void VkCompute::record_clone(const VkMat& src, Mat& dst, const Option& opt) { -// fprintf(stderr, "record_clone buffer to host\n"); +// NCNN_LOGE("record_clone buffer to host"); if (!src.allocator->mappable) { @@ -625,7 +624,7 @@ void VkCompute::record_clone(const VkMat& src, Mat& dst, const Option& opt) void VkCompute::record_clone(const VkImageMat& src, Mat& dst, const Option& opt) { -// fprintf(stderr, "record_clone image to host\n"); +// NCNN_LOGE("record_clone image to host"); // image to staging VkMat src_staging; @@ -639,7 +638,7 @@ void VkCompute::record_clone(const VkImageMat& src, Mat& dst, const Option& opt) void VkCompute::record_clone(const VkMat& src, VkMat& dst, const Option& opt) { -// fprintf(stderr, "record_clone buffer to buffer\n"); +// NCNN_LOGE("record_clone buffer to buffer"); // create dst dst.create_like(src, opt.blob_vkallocator); @@ -721,7 +720,7 @@ void VkCompute::record_clone(const VkMat& src, VkMat& dst, const Option& opt) void VkCompute::record_clone(const VkImageMat& src, VkImageMat& dst, const Option& opt) { -// fprintf(stderr, "record_clone image to image\n"); +// NCNN_LOGE("record_clone image to image"); // create dst dst.create_like(src, opt.blob_vkallocator); @@ -867,7 +866,7 @@ void VkCompute::record_clone(const VkImageMat& src, VkImageMat& dst, const Optio void VkCompute::record_clone(const VkMat& src, VkImageMat& dst, const Option& opt) { -// fprintf(stderr, "record_clone buffer to image\n"); +// NCNN_LOGE("record_clone buffer to image"); // create dst dst.create_like(src, opt.blob_vkallocator); @@ -1027,7 +1026,7 @@ void VkCompute::record_clone(const VkMat& src, VkImageMat& dst, const Option& op void VkCompute::record_clone(const VkImageMat& src, VkMat& dst, const Option& opt) { -// fprintf(stderr, "record_clone image to buffer\n"); +// NCNN_LOGE("record_clone image to buffer"); // create dst dst.create_like(src, opt.blob_vkallocator); @@ -1181,7 +1180,7 @@ void VkCompute::record_pipeline(const Pipeline* pipeline, const std::vector& buffer_bindings, const std::vector& image_bindings, const std::vector& constants, const Mat& dispatcher) { -// fprintf(stderr, "record_pipeline %p\n", pipeline); +// NCNN_LOGE("record_pipeline %p", pipeline); const int buffer_binding_count = (int)buffer_bindings.size(); const int image_binding_count = (int)image_bindings.size(); @@ -1191,12 +1190,12 @@ void VkCompute::record_pipeline(const Pipeline* pipeline, const std::vectorshader_info.binding_count) { - fprintf(stderr, "binding_count not match, expect %d but got %d + %d\n", pipeline->shader_info.binding_count, buffer_binding_count, image_binding_count); + NCNN_LOGE("binding_count not match, expect %d but got %d + %d", pipeline->shader_info.binding_count, buffer_binding_count, image_binding_count); } if (constant_count != pipeline->shader_info.push_constant_count) { - fprintf(stderr, "push_constant_count not match, expect %d but got %d\n", pipeline->shader_info.push_constant_count, constant_count); + NCNN_LOGE("push_constant_count not match, expect %d but got %d", pipeline->shader_info.push_constant_count, constant_count); } int buffer_index = 0; @@ -1210,7 +1209,7 @@ void VkCompute::record_pipeline(const Pipeline* pipeline, const std::vectorget_dummy_buffer() : buffer_bindings[buffer_index]; buffer_index++; -// fprintf(stderr, "binding #%d buffer = %d %d %d %d @ %lu %d = %p +%ld ~%ld\n", i, binding.dims, binding.w, binding.h, binding.c, binding.elemsize, binding.elempack, binding.buffer(), binding.buffer_offset(), binding.buffer_capacity()); +// NCNN_LOGE("binding #%d buffer = %d %d %d %d @ %lu %d = %p +%ld ~%ld", i, binding.dims, binding.w, binding.h, binding.c, binding.elemsize, binding.elempack, binding.buffer(), binding.buffer_offset(), binding.buffer_capacity()); if (binding.data->access_flags & VK_ACCESS_SHADER_WRITE_BIT || binding.data->stage_flags != VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT) { @@ -1256,7 +1255,7 @@ void VkCompute::record_pipeline(const Pipeline* pipeline, const std::vectorget_dummy_image() : image_bindings[image_index]; image_index++; -// fprintf(stderr, "binding #%d image = %d %d %d %d @ %lu %d = %p +%ld ~%ld %p\n", i, binding.dims, binding.w, binding.h, binding.c, binding.elemsize, binding.elempack, binding.image(), binding.data->bind_offset, binding.data->bind_capacity, binding.imageview()); +// NCNN_LOGE("binding #%d image = %d %d %d %d @ %lu %d = %p +%ld ~%ld %p", i, binding.dims, binding.w, binding.h, binding.c, binding.elemsize, binding.elempack, binding.image(), binding.data->bind_offset, binding.data->bind_capacity, binding.imageview()); if (binding.data->access_flags & VK_ACCESS_SHADER_WRITE_BIT || binding.data->image_layout != VK_IMAGE_LAYOUT_GENERAL || binding.data->stage_flags != VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT) { @@ -1312,7 +1311,7 @@ void VkCompute::record_pipeline(const Pipeline* pipeline, const std::vectorget_dummy_image() : image_bindings[image_index]; image_index++; -// fprintf(stderr, "binding #%d sampler = %d %d %d %d @ %lu %d = %p +%ld ~%ld %p\n", i, binding.dims, binding.w, binding.h, binding.c, binding.elemsize, binding.elempack, binding.image(), binding.data->bind_offset, binding.data->bind_capacity, binding.imageview()); +// NCNN_LOGE("binding #%d sampler = %d %d %d %d @ %lu %d = %p +%ld ~%ld %p", i, binding.dims, binding.w, binding.h, binding.c, binding.elemsize, binding.elempack, binding.image(), binding.data->bind_offset, binding.data->bind_capacity, binding.imageview()); // if the same image used for both storage image and combined image sampler // only apply image layout transition to general @@ -1477,7 +1476,7 @@ void VkCompute::record_pipeline(const Pipeline* pipeline, const std::vectorvkdevice(), &descriptorPoolCreateInfo, 0, &descriptor_pool); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateDescriptorPool failed %d\n", ret); + NCNN_LOGE("vkCreateDescriptorPool failed %d", ret); return; } } @@ -1495,7 +1494,7 @@ void VkCompute::record_pipeline(const Pipeline* pipeline, const std::vectorvkdevice(), &descriptorSetAllocateInfo, &descriptorset); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkAllocateDescriptorSets failed %d\n", ret); + NCNN_LOGE("vkAllocateDescriptorSets failed %d", ret); return; } } @@ -1738,7 +1737,7 @@ void VkCompute::record_import_android_hardware_buffer(const ImportAndroidHardwar VkResult ret = vkCreateDescriptorPool(vkdev->vkdevice(), &descriptorPoolCreateInfo, 0, &descriptor_pool); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateDescriptorPool failed %d\n", ret); + NCNN_LOGE("vkCreateDescriptorPool failed %d", ret); return; } } @@ -1756,7 +1755,7 @@ void VkCompute::record_import_android_hardware_buffer(const ImportAndroidHardwar VkResult ret = vkAllocateDescriptorSets(vkdev->vkdevice(), &descriptorSetAllocateInfo, &descriptorset); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkAllocateDescriptorSets failed %d\n", ret); + NCNN_LOGE("vkAllocateDescriptorSets failed %d", ret); return; } } @@ -1960,7 +1959,7 @@ void VkCompute::record_import_android_hardware_buffer(const ImportAndroidHardwar VkResult ret = vkCreateDescriptorPool(vkdev->vkdevice(), &descriptorPoolCreateInfo, 0, &descriptor_pool); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateDescriptorPool failed %d\n", ret); + NCNN_LOGE("vkCreateDescriptorPool failed %d", ret); return; } } @@ -1978,7 +1977,7 @@ void VkCompute::record_import_android_hardware_buffer(const ImportAndroidHardwar VkResult ret = vkAllocateDescriptorSets(vkdev->vkdevice(), &descriptorSetAllocateInfo, &descriptorset); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkAllocateDescriptorSets failed %d\n", ret); + NCNN_LOGE("vkAllocateDescriptorSets failed %d", ret); return; } } @@ -2062,7 +2061,7 @@ void VkCompute::record_import_android_hardware_buffer(const ImportAndroidHardwar int VkCompute::submit_and_wait() { -// fprintf(stderr, "submit_and_wait\n"); +// NCNN_LOGE("submit_and_wait"); if (!vkdev->info.support_VK_KHR_push_descriptor) { @@ -2169,7 +2168,7 @@ int VkCompute::submit_and_wait() VkQueue compute_queue = vkdev->acquire_queue(vkdev->info.compute_queue_family_index); if (compute_queue == 0) { - fprintf(stderr, "out of compute queue\n"); + NCNN_LOGE("out of compute queue"); return -1; } @@ -2189,7 +2188,7 @@ int VkCompute::submit_and_wait() VkResult ret = vkQueueSubmit(compute_queue, 1, &submitInfo, compute_command_fence); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkQueueSubmit failed %d\n", ret); + NCNN_LOGE("vkQueueSubmit failed %d", ret); vkdev->reclaim_queue(vkdev->info.compute_queue_family_index, compute_queue); return -1; } @@ -2202,7 +2201,7 @@ int VkCompute::submit_and_wait() VkResult ret = vkWaitForFences(vkdev->vkdevice(), 1, &compute_command_fence, VK_TRUE, UINT64_MAX); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkWaitForFences failed %d\n", ret); + NCNN_LOGE("vkWaitForFences failed %d", ret); return -1; } } @@ -2219,7 +2218,7 @@ int VkCompute::submit_and_wait() const VkMat& src = download_post_buffers[r.post_download.download_post_buffer_mat_offset]; Mat& dst = download_post_mats_fp16[r.post_download.download_post_mat_fp16_offset]; -// fprintf(stderr, "post_download %p +%d ~%d -> %p\n", src.buffer(), src.buffer_offset(), src.buffer_capacity(), dst.data); +// NCNN_LOGE("post_download %p +%d ~%d -> %p", src.buffer(), src.buffer_offset(), src.buffer_capacity(), dst.data); src.allocator->invalidate(src.data); memcpy(dst.data, src.mapped_ptr(), dst.total() * dst.elemsize); @@ -2227,7 +2226,7 @@ int VkCompute::submit_and_wait() } case record::TYPE_post_cast_float16_to_float32: { -// fprintf(stderr, "post_cast_float16_to_float32\n"); +// NCNN_LOGE("post_cast_float16_to_float32"); const Mat& src = download_post_mats_fp16[r.post_cast_float16_to_float32.download_post_mat_fp16_offset]; Mat& dst = download_post_mats[r.post_cast_float16_to_float32.download_post_mat_offset]; @@ -2254,7 +2253,7 @@ int VkCompute::reset() VkResult ret = vkResetCommandBuffer(compute_command_buffer, 0); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkResetCommandBuffer failed %d\n", ret); + NCNN_LOGE("vkResetCommandBuffer failed %d", ret); return -1; } } @@ -2262,7 +2261,7 @@ int VkCompute::reset() VkResult ret = vkResetFences(vkdev->vkdevice(), 1, &compute_command_fence); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkResetFences failed %d\n", ret); + NCNN_LOGE("vkResetFences failed %d", ret); return -1; } } @@ -2296,7 +2295,7 @@ int VkCompute::create_query_pool(uint32_t _query_count) VkResult ret = vkCreateQueryPool(vkdev->vkdevice(), &queryPoolCreateInfo, 0, &query_pool); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateQueryPool failed %d\n", ret); + NCNN_LOGE("vkCreateQueryPool failed %d", ret); return -1; } @@ -2313,7 +2312,7 @@ int VkCompute::get_query_pool_results(uint32_t first_query, uint32_t query_count { if (results.size() < first_query + query_count) { - fprintf(stderr, "results not large enough\n"); + NCNN_LOGE("results not large enough"); return -1; } @@ -2321,7 +2320,7 @@ int VkCompute::get_query_pool_results(uint32_t first_query, uint32_t query_count query_count * sizeof(uint64_t), results.data() + first_query, sizeof(uint64_t), VK_QUERY_RESULT_64_BIT); if (ret != VK_SUCCESS && ret != VK_NOT_READY) { - fprintf(stderr, "vkGetQueryPoolResults failed %d\n", ret); + NCNN_LOGE("vkGetQueryPoolResults failed %d", ret); return -1; } @@ -2342,7 +2341,7 @@ int VkCompute::init() VkResult ret = vkCreateCommandPool(vkdev->vkdevice(), &commandPoolCreateInfo, 0, &compute_command_pool); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateCommandPool failed %d\n", ret); + NCNN_LOGE("vkCreateCommandPool failed %d", ret); return -1; } } @@ -2359,7 +2358,7 @@ int VkCompute::init() VkResult ret = vkAllocateCommandBuffers(vkdev->vkdevice(), &commandBufferAllocateInfo, &compute_command_buffer); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkAllocateCommandBuffers failed %d\n", ret); + NCNN_LOGE("vkAllocateCommandBuffers failed %d", ret); return -1; } } @@ -2374,7 +2373,7 @@ int VkCompute::init() VkResult ret = vkCreateFence(vkdev->vkdevice(), &fenceCreateInfo, 0, &compute_command_fence); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateFence failed %d\n", ret); + NCNN_LOGE("vkCreateFence failed %d", ret); return -1; } } @@ -2403,7 +2402,7 @@ int VkCompute::begin_command_buffer() VkResult ret = vkBeginCommandBuffer(compute_command_buffer, &commandBufferBeginInfo); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkBeginCommandBuffer failed %d\n", ret); + NCNN_LOGE("vkBeginCommandBuffer failed %d", ret); return -1; } @@ -2415,7 +2414,7 @@ int VkCompute::end_command_buffer() VkResult ret = vkEndCommandBuffer(compute_command_buffer); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkEndCommandBuffer failed %d\n", ret); + NCNN_LOGE("vkEndCommandBuffer failed %d", ret); return -1; } @@ -2458,7 +2457,7 @@ VkTransfer::~VkTransfer() void VkTransfer::record_upload(const Mat& src, VkMat& dst, const Option& opt) { -// fprintf(stderr, "record_upload src = %d | %d %d %d @ %d\n", src.dims, src.w, src.h, src.c, src.elempack); +// NCNN_LOGE("record_upload src = %d | %d %d %d @ %d", src.dims, src.w, src.h, src.c, src.elempack); // NOTE keep the hack here ? if (src.elemsize == src.elempack * 4u) @@ -2637,7 +2636,7 @@ void VkTransfer::record_upload(const Mat& src, VkMat& dst, const Option& opt) void VkTransfer::record_upload(const Mat& src, VkImageMat& dst, const Option& opt) { -// fprintf(stderr, "record_upload image src = %d | %d %d %d @ %d\n", src.dims, src.w, src.h, src.c, src.elempack); +// NCNN_LOGE("record_upload image src = %d | %d %d %d @ %d", src.dims, src.w, src.h, src.c, src.elempack); // NOTE keep the hack here ? if (src.elemsize == src.elempack * 4u) @@ -2834,7 +2833,7 @@ void VkTransfer::record_upload(const Mat& src, VkImageMat& dst, const Option& op int VkTransfer::submit_and_wait() { -// fprintf(stderr, "submit_and_wait\n"); +// NCNN_LOGE("submit_and_wait"); // end command buffer { @@ -2844,7 +2843,7 @@ int VkTransfer::submit_and_wait() VkQueue compute_queue = vkdev->acquire_queue(vkdev->info.compute_queue_family_index); if (compute_queue == 0) { - fprintf(stderr, "out of compute queue\n"); + NCNN_LOGE("out of compute queue"); return -1; } @@ -2866,7 +2865,7 @@ int VkTransfer::submit_and_wait() VkResult ret = vkQueueSubmit(compute_queue, 1, &submitInfo, compute_command_fence); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkQueueSubmit failed %d\n", ret); + NCNN_LOGE("vkQueueSubmit failed %d", ret); vkdev->reclaim_queue(vkdev->info.compute_queue_family_index, compute_queue); return -1; } @@ -2877,7 +2876,7 @@ int VkTransfer::submit_and_wait() VkQueue transfer_queue = vkdev->acquire_queue(vkdev->info.transfer_queue_family_index); if (transfer_queue == 0) { - fprintf(stderr, "out of transfer queue\n"); + NCNN_LOGE("out of transfer queue"); vkdev->reclaim_queue(vkdev->info.compute_queue_family_index, compute_queue); return -1; } @@ -2898,7 +2897,7 @@ int VkTransfer::submit_and_wait() VkResult ret = vkQueueSubmit(transfer_queue, 1, &submitInfo, upload_command_fence); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkQueueSubmit failed %d\n", ret); + NCNN_LOGE("vkQueueSubmit failed %d", ret); vkdev->reclaim_queue(vkdev->info.transfer_queue_family_index, transfer_queue); vkdev->reclaim_queue(vkdev->info.compute_queue_family_index, compute_queue); return -1; @@ -2921,7 +2920,7 @@ int VkTransfer::submit_and_wait() VkResult ret = vkQueueSubmit(compute_queue, 1, &submitInfo, compute_command_fence); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkQueueSubmit failed %d\n", ret); + NCNN_LOGE("vkQueueSubmit failed %d", ret); vkdev->reclaim_queue(vkdev->info.transfer_queue_family_index, transfer_queue); vkdev->reclaim_queue(vkdev->info.compute_queue_family_index, compute_queue); return -1; @@ -2939,7 +2938,7 @@ int VkTransfer::submit_and_wait() VkResult ret = vkWaitForFences(vkdev->vkdevice(), 1, &compute_command_fence, VK_TRUE, UINT64_MAX); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkWaitForFences failed %d\n", ret); + NCNN_LOGE("vkWaitForFences failed %d", ret); return -1; } } @@ -2950,7 +2949,7 @@ int VkTransfer::submit_and_wait() VkResult ret = vkWaitForFences(vkdev->vkdevice(), 2, fences, VK_TRUE, UINT64_MAX); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkWaitForFences failed %d\n", ret); + NCNN_LOGE("vkWaitForFences failed %d", ret); return -1; } } @@ -2971,7 +2970,7 @@ int VkTransfer::init() VkResult ret = vkCreateCommandPool(vkdev->vkdevice(), &commandPoolCreateInfo, 0, &compute_command_pool); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateCommandPool failed %d\n", ret); + NCNN_LOGE("vkCreateCommandPool failed %d", ret); return -1; } } @@ -2988,7 +2987,7 @@ int VkTransfer::init() VkResult ret = vkAllocateCommandBuffers(vkdev->vkdevice(), &commandBufferAllocateInfo, &compute_command_buffer); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkAllocateCommandBuffers failed %d\n", ret); + NCNN_LOGE("vkAllocateCommandBuffers failed %d", ret); return -1; } } @@ -3003,7 +3002,7 @@ int VkTransfer::init() VkResult ret = vkCreateFence(vkdev->vkdevice(), &fenceCreateInfo, 0, &compute_command_fence); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateFence failed %d\n", ret); + NCNN_LOGE("vkCreateFence failed %d", ret); return -1; } } @@ -3021,7 +3020,7 @@ int VkTransfer::init() VkResult ret = vkCreateCommandPool(vkdev->vkdevice(), &commandPoolCreateInfo, 0, &transfer_command_pool); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateCommandPool failed %d\n", ret); + NCNN_LOGE("vkCreateCommandPool failed %d", ret); return -1; } } @@ -3038,7 +3037,7 @@ int VkTransfer::init() VkResult ret = vkAllocateCommandBuffers(vkdev->vkdevice(), &commandBufferAllocateInfo, &upload_command_buffer); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkAllocateCommandBuffers failed %d\n", ret); + NCNN_LOGE("vkAllocateCommandBuffers failed %d", ret); return -1; } } @@ -3053,7 +3052,7 @@ int VkTransfer::init() VkResult ret = vkCreateSemaphore(vkdev->vkdevice(), &semaphoreCreateInfo, 0, &upload_compute_semaphore); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateSemaphore failed %d\n", ret); + NCNN_LOGE("vkCreateSemaphore failed %d", ret); return -1; } } @@ -3068,7 +3067,7 @@ int VkTransfer::init() VkResult ret = vkCreateFence(vkdev->vkdevice(), &fenceCreateInfo, 0, &upload_command_fence); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateFence failed %d\n", ret); + NCNN_LOGE("vkCreateFence failed %d", ret); return -1; } } @@ -3091,7 +3090,7 @@ int VkTransfer::begin_command_buffer() VkResult ret = vkBeginCommandBuffer(compute_command_buffer, &commandBufferBeginInfo); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkBeginCommandBuffer failed %d\n", ret); + NCNN_LOGE("vkBeginCommandBuffer failed %d", ret); return -1; } } @@ -3108,7 +3107,7 @@ int VkTransfer::begin_command_buffer() VkResult ret = vkBeginCommandBuffer(upload_command_buffer, &commandBufferBeginInfo); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkBeginCommandBuffer failed %d\n", ret); + NCNN_LOGE("vkBeginCommandBuffer failed %d", ret); return -1; } } @@ -3123,7 +3122,7 @@ int VkTransfer::end_command_buffer() VkResult ret = vkEndCommandBuffer(compute_command_buffer); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkEndCommandBuffer failed %d\n", ret); + NCNN_LOGE("vkEndCommandBuffer failed %d", ret); return -1; } } @@ -3134,7 +3133,7 @@ int VkTransfer::end_command_buffer() VkResult ret = vkEndCommandBuffer(upload_command_buffer); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkEndCommandBuffer failed %d\n", ret); + NCNN_LOGE("vkEndCommandBuffer failed %d", ret); return -1; } } diff --git a/src/cpu.cpp b/src/cpu.cpp index 46ec92cd4a0..6e96137b72b 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -13,9 +13,9 @@ // specific language governing permissions and limitations under the License. #include "cpu.h" +#include "platform.h" #include -#include #include #include @@ -231,7 +231,7 @@ static int get_cpucount() if (count > (int)sizeof(size_t) * 8) { - fprintf(stderr, "more than %d cpu detected, thread affinity may not work properly :(\n", (int)sizeof(size_t) * 8); + NCNN_LOGE("more than %d cpu detected, thread affinity may not work properly :(", (int)sizeof(size_t) * 8); } return count; @@ -354,7 +354,7 @@ typedef struct int syscallret = syscall(__NR_sched_setaffinity, pid, sizeof(mask), &mask); if (syscallret) { - fprintf(stderr, "syscall error %d\n", syscallret); + NCNN_LOGE("syscall error %d", syscallret); return -1; } @@ -373,7 +373,7 @@ int set_cpu_powersave(int powersave) { if (powersave < 0 || powersave > 2) { - fprintf(stderr, "powersave %d not supported\n", powersave); + NCNN_LOGE("powersave %d not supported", powersave); return -1; } @@ -404,7 +404,7 @@ static int setup_thread_affinity_masks() { int max_freq_khz = get_max_freq_khz(i); -// fprintf(stderr, "%d max freq = %d khz\n", i, max_freq_khz); +// NCNN_LOGE("%d max freq = %d khz", i, max_freq_khz); cpu_max_freq_khz[i] = max_freq_khz; @@ -461,7 +461,7 @@ size_t get_cpu_thread_affinity_mask(int powersave) if (powersave == 2) return g_thread_affinity_mask_big; - fprintf(stderr, "powersave %d not supported\n", powersave); + NCNN_LOGE("powersave %d not supported", powersave); // fallback to all cores anyway return g_thread_affinity_mask_all; diff --git a/src/datareader.h b/src/datareader.h index 401c460b870..5cdf3d7f1a9 100644 --- a/src/datareader.h +++ b/src/datareader.h @@ -15,8 +15,10 @@ #ifndef NCNN_DATAREADER_H #define NCNN_DATAREADER_H -#include #include "platform.h" +#if NCNN_STDIO || NCNN_STRING +#include +#endif #if __ANDROID_API__ >= 9 #include diff --git a/src/gpu.cpp b/src/gpu.cpp index f5f76669412..86f7aacf9e3 100644 --- a/src/gpu.cpp +++ b/src/gpu.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include @@ -184,7 +183,7 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback( const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* /*pUserData*/) { - fprintf(stderr, "validation layer: %s\n", pCallbackData->pMessage); + NCNN_LOGE("validation layer: %s", pCallbackData->pMessage); return VK_FALSE; } @@ -243,7 +242,7 @@ static uint32_t find_device_compute_queue(const std::vector 0) return 0; - fprintf(stderr, "no vulkan device\n"); + NCNN_LOGE("no vulkan device"); return -1; } @@ -367,7 +366,7 @@ int create_gpu_instance() ret = vkEnumerateInstanceLayerProperties(&instanceLayerPropertyCount, NULL); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkEnumerateInstanceLayerProperties failed %d\n", ret); + NCNN_LOGE("vkEnumerateInstanceLayerProperties failed %d", ret); return -1; } @@ -375,14 +374,14 @@ int create_gpu_instance() ret = vkEnumerateInstanceLayerProperties(&instanceLayerPropertyCount, instanceLayerProperties.data()); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkEnumerateInstanceLayerProperties failed %d\n", ret); + NCNN_LOGE("vkEnumerateInstanceLayerProperties failed %d", ret); return -1; } for (uint32_t i=0; i= layer_shader_registry_entry_count) { - fprintf(stderr, "no such shader module %d\n", shader_type_index); + NCNN_LOGE("no such shader module %d", shader_type_index); return 0; } @@ -1149,7 +1148,7 @@ VkShaderModule VulkanDevice::create_shader_module(int shader_type_index, uint32_ { if (shader_type_index < 0 || shader_type_index >= layer_shader_registry_entry_count) { - fprintf(stderr, "no such shader module %d\n", shader_type_index); + NCNN_LOGE("no such shader module %d", shader_type_index); return 0; } @@ -1172,7 +1171,7 @@ VkShaderModule VulkanDevice::compile_shader_module(const uint32_t* spv_data, siz VkResult ret = vkCreateShaderModule(device, &shaderModuleCreateInfo, 0, &shader_module); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateShaderModule failed %d\n", ret); + NCNN_LOGE("vkCreateShaderModule failed %d", ret); return 0; } @@ -1351,7 +1350,7 @@ uint32_t VulkanDevice::find_memory_index(uint32_t memory_type_bits, VkFlags requ } } - fprintf(stderr, "no such memory type %u %u %u %u\n", memory_type_bits, required, preferred, preferred_not); + NCNN_LOGE("no such memory type %u %u %u %u", memory_type_bits, required, preferred, preferred_not); return -1; } @@ -1375,7 +1374,7 @@ VkQueue VulkanDevice::acquire_queue(uint32_t queue_family_index) const && queue_family_index != info.graphics_queue_family_index && queue_family_index != info.transfer_queue_family_index) { - fprintf(stderr, "invalid queue_family_index %u\n", queue_family_index); + NCNN_LOGE("invalid queue_family_index %u", queue_family_index); return 0; } @@ -1403,7 +1402,7 @@ void VulkanDevice::reclaim_queue(uint32_t queue_family_index, VkQueue queue) con && queue_family_index != info.graphics_queue_family_index && queue_family_index != info.transfer_queue_family_index) { - fprintf(stderr, "invalid queue_family_index %u\n", queue_family_index); + NCNN_LOGE("invalid queue_family_index %u", queue_family_index); return; } @@ -1420,7 +1419,7 @@ void VulkanDevice::reclaim_queue(uint32_t queue_family_index, VkQueue queue) con } } - fprintf(stderr, "FATAL ERROR! reclaim_queue get wild queue %u %p\n", queue_family_index, queue); + NCNN_LOGE("FATAL ERROR! reclaim_queue get wild queue %u %p", queue_family_index, queue); } VkAllocator* VulkanDevice::acquire_blob_allocator() const @@ -1454,7 +1453,7 @@ void VulkanDevice::reclaim_blob_allocator(VkAllocator* allocator) const } } - fprintf(stderr, "FATAL ERROR! reclaim_blob_allocator get wild allocator %p\n", allocator); + NCNN_LOGE("FATAL ERROR! reclaim_blob_allocator get wild allocator %p", allocator); } VkAllocator* VulkanDevice::acquire_staging_allocator() const @@ -1488,7 +1487,7 @@ void VulkanDevice::reclaim_staging_allocator(VkAllocator* allocator) const } } - fprintf(stderr, "FATAL ERROR! reclaim_staging_allocator get wild allocator %p\n", allocator); + NCNN_LOGE("FATAL ERROR! reclaim_staging_allocator get wild allocator %p", allocator); } const VkSampler* VulkanDevice::immutable_texelfetch_sampler() const @@ -1551,7 +1550,7 @@ void VulkanDevice::convert_packing(const VkMat& src, VkMat& dst, int dst_elempac int cast_type_to_index = opt.use_fp16_storage ? 2 : opt.use_fp16_packed && dst_elempack % 4 == 0 ? 1 : 0; int packing_type_to_index = dst_elempack == 1 ? 0 : dst_elempack == 4 ? 1 : 2; -// fprintf(stderr, "convert_packing b2b %d %d %d\n", cast_type_from_index, cast_type_to_index, packing_type_to_index); +// NCNN_LOGE("convert_packing b2b %d %d %d", cast_type_from_index, cast_type_to_index, packing_type_to_index); const ncnn::Packing_vulkan* uop = uop_packing[0][0][cast_type_from_index][cast_type_to_index][packing_type_to_index]; uop->forward(src, dst, cmd, opt); @@ -1563,7 +1562,7 @@ void VulkanDevice::convert_packing(const VkImageMat& src, VkImageMat& dst, int d int cast_type_to_index = opt.use_fp16_storage ? 2 : opt.use_fp16_packed && dst_elempack % 4 == 0 ? 1 : 0; int packing_type_to_index = dst_elempack == 1 ? 0 : dst_elempack == 4 ? 1 : 2; -// fprintf(stderr, "convert_packing i2i %d %d %d\n", cast_type_from_index, cast_type_to_index, packing_type_to_index); +// NCNN_LOGE("convert_packing i2i %d %d %d", cast_type_from_index, cast_type_to_index, packing_type_to_index); const ncnn::Packing_vulkan* uop = uop_packing[1][1][cast_type_from_index][cast_type_to_index][packing_type_to_index]; uop->forward(src, dst, cmd, opt); @@ -1575,7 +1574,7 @@ void VulkanDevice::convert_packing(const VkMat& src, VkImageMat& dst, int dst_el int cast_type_to_index = opt.use_fp16_storage ? 2 : opt.use_fp16_packed && dst_elempack % 4 == 0 ? 1 : 0; int packing_type_to_index = dst_elempack == 1 ? 0 : dst_elempack == 4 ? 1 : 2; -// fprintf(stderr, "convert_packing b2i %d %d %d\n", cast_type_from_index, cast_type_to_index, packing_type_to_index); +// NCNN_LOGE("convert_packing b2i %d %d %d", cast_type_from_index, cast_type_to_index, packing_type_to_index); const ncnn::Packing_vulkan* uop = uop_packing[0][1][cast_type_from_index][cast_type_to_index][packing_type_to_index]; uop->forward(src, dst, cmd, opt); @@ -1587,7 +1586,7 @@ void VulkanDevice::convert_packing(const VkImageMat& src, VkMat& dst, int dst_el int cast_type_to_index = opt.use_fp16_storage ? 2 : opt.use_fp16_packed && dst_elempack % 4 == 0 ? 1 : 0; int packing_type_to_index = dst_elempack == 1 ? 0 : dst_elempack == 4 ? 1 : 2; -// fprintf(stderr, "convert_packing i2b %d %d %d\n", cast_type_from_index, cast_type_to_index, packing_type_to_index); +// NCNN_LOGE("convert_packing i2b %d %d %d", cast_type_from_index, cast_type_to_index, packing_type_to_index); const ncnn::Packing_vulkan* uop = uop_packing[1][0][cast_type_from_index][cast_type_to_index][packing_type_to_index]; uop->forward(src, dst, cmd, opt); @@ -1677,13 +1676,13 @@ int VulkanDevice::create_shader_module() VkShaderModule shader_module = compile_shader_module(spv_data, spv_data_size); if (shader_module == 0) { - fprintf(stderr, "compile_shader_module %d failed\n", i); + NCNN_LOGE("compile_shader_module %d failed", i); return -1; } shader_modules[i] = shader_module; -// fprintf(stderr, "shader_module %d created\n", i); +// NCNN_LOGE("shader_module %d created", i); } return 0; @@ -1779,7 +1778,7 @@ class VkDummyCompute : public VkCompute void record_dummy(const VkMat& buffer) { -// fprintf(stderr, "xxx barrier buffer %p +%d ~%d\n", buffer.buffer(), buffer.buffer_offset(), buffer.buffer_capacity()); +// NCNN_LOGE("xxx barrier buffer %p +%d ~%d", buffer.buffer(), buffer.buffer_offset(), buffer.buffer_capacity()); // barrier device any @ compute/null to shader-readwrite @ compute VkBufferMemoryBarrier* barriers = new VkBufferMemoryBarrier[1]; @@ -1820,7 +1819,7 @@ class VkDummyCompute : public VkCompute void record_dummy(const VkImageMat& image) { -// fprintf(stderr, "xxx barrier image %p +%d ~%d %p\n", image.image(), image.data->bind_offset, image.data->bind_capacity, image.imageview()); +// NCNN_LOGE("xxx barrier image %p +%d ~%d %p", image.image(), image.data->bind_offset, image.data->bind_capacity, image.imageview()); // image layout transform any @ any to shader-write @ compute VkImageMemoryBarrier* barriers = new VkImageMemoryBarrier[1]; @@ -2015,7 +2014,7 @@ const ShaderInfo& get_shader_info(int shader_type_index) { if (shader_type_index < 0 || shader_type_index >= layer_shader_registry_entry_count) { - fprintf(stderr, "no such shader module %d\n", shader_type_index); + NCNN_LOGE("no such shader module %d", shader_type_index); return layer_shader_infos[0]; } @@ -2139,7 +2138,7 @@ int resolve_shader_info(const uint32_t* spv_data, size_t spv_data_size, ShaderIn if (binding_count > 16) { - fprintf(stderr, "too many binding %d\n", binding_count); + NCNN_LOGE("too many binding %d", binding_count); return -1; } diff --git a/src/layer.cpp b/src/layer.cpp index 3d1c9c19dd1..58f74af9477 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -15,7 +15,6 @@ #include "layer.h" #include -#include #include #include #include "cpu.h" diff --git a/src/layer.h b/src/layer.h index 8b6bb087565..a009070828a 100644 --- a/src/layer.h +++ b/src/layer.h @@ -15,7 +15,6 @@ #ifndef NCNN_LAYER_H #define NCNN_LAYER_H -#include #include #include #include diff --git a/src/layer/arm/convolution_arm.cpp b/src/layer/arm/convolution_arm.cpp index 4368310f17f..646444b14a2 100644 --- a/src/layer/arm/convolution_arm.cpp +++ b/src/layer/arm/convolution_arm.cpp @@ -467,7 +467,7 @@ int Convolution_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option size_t elemsize = bottom_blob.elemsize; int elempack = bottom_blob.elempack; -// fprintf(stderr, "Convolution input %d x %d pad = %d %d ksize=%d %d stride=%d %d\n", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h); +// NCNN_LOGE("Convolution input %d x %d pad = %d %d ksize=%d %d stride=%d %d", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h); const int kernel_extent_w = dilation_w * (kernel_w - 1) + 1; const int kernel_extent_h = dilation_h * (kernel_h - 1) + 1; @@ -1218,7 +1218,7 @@ int Convolution_arm::forward_bf16s(const Mat& bottom_blob, Mat& top_blob, const size_t elemsize = bottom_blob.elemsize; int elempack = bottom_blob.elempack; -// fprintf(stderr, "Convolution input %d x %d pad = %d %d ksize=%d %d stride=%d %d\n", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h); +// NCNN_LOGE("Convolution input %d x %d pad = %d %d ksize=%d %d stride=%d %d", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h); const int kernel_extent_w = dilation_w * (kernel_w - 1) + 1; const int kernel_extent_h = dilation_h * (kernel_h - 1) + 1; @@ -1679,7 +1679,7 @@ int Convolution_arm::forward_int8_arm(const Mat& bottom_blob, Mat& top_blob, con // int channels = bottom_blob.c; size_t elemsize = bottom_blob.elemsize; -// fprintf(stderr, "Convolution_arm input %d x %d ksize=%d %d stride=%d %d\n", w, h, kernel_w, kernel_h, stride_w, stride_h); +// NCNN_LOGE("Convolution_arm input %d x %d ksize=%d %d stride=%d %d", w, h, kernel_w, kernel_h, stride_w, stride_h); const int kernel_extent_w = dilation_w * (kernel_w - 1) + 1; const int kernel_extent_h = dilation_h * (kernel_h - 1) + 1; diff --git a/src/layer/arm/deconvolution_arm.cpp b/src/layer/arm/deconvolution_arm.cpp index c7a0f415b3e..f00c8c56aac 100644 --- a/src/layer/arm/deconvolution_arm.cpp +++ b/src/layer/arm/deconvolution_arm.cpp @@ -285,7 +285,7 @@ int Deconvolution_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Opti size_t elemsize = bottom_blob.elemsize; int elempack = bottom_blob.elempack; -// fprintf(stderr, "Deconvolution input %d x %d pad = %d %d ksize=%d %d stride=%d %d\n", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h); +// NCNN_LOGE("Deconvolution input %d x %d pad = %d %d ksize=%d %d stride=%d %d", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h); const int kernel_extent_w = dilation_w * (kernel_w - 1) + 1; const int kernel_extent_h = dilation_h * (kernel_h - 1) + 1; diff --git a/src/layer/arm/pooling_arm.cpp b/src/layer/arm/pooling_arm.cpp index 7e4e39c05bc..f1ebf704ece 100644 --- a/src/layer/arm/pooling_arm.cpp +++ b/src/layer/arm/pooling_arm.cpp @@ -55,7 +55,7 @@ int Pooling_arm::forward(const Mat& bottom_blob, Mat& top_blob, const Option& op int elempack = bottom_blob.elempack; #if __ARM_NEON -// fprintf(stderr, "Pooling input %d x %d pad = %d %d %d %d ksize=%d %d stride=%d %d\n", w, h, pad_left, pad_right, pad_top, pad_bottom, kernel_w, kernel_h, stride_w, stride_h); +// NCNN_LOGE("Pooling input %d x %d pad = %d %d %d %d ksize=%d %d stride=%d %d", w, h, pad_left, pad_right, pad_top, pad_bottom, kernel_w, kernel_h, stride_w, stride_h); if (elempack == 4) { @@ -346,7 +346,7 @@ int Pooling_arm::forward_bf16s(const Mat& bottom_blob, Mat& top_blob, const Opti size_t elemsize = bottom_blob.elemsize; int elempack = bottom_blob.elempack; -// fprintf(stderr, "Pooling input %d x %d pad = %d %d %d %d ksize=%d %d stride=%d %d\n", w, h, pad_left, pad_right, pad_top, pad_bottom, kernel_w, kernel_h, stride_w, stride_h); +// NCNN_LOGE("Pooling input %d x %d pad = %d %d %d %d ksize=%d %d stride=%d %d", w, h, pad_left, pad_right, pad_top, pad_bottom, kernel_w, kernel_h, stride_w, stride_h); if (global_pooling) { diff --git a/src/layer/convolution.cpp b/src/layer/convolution.cpp index 3b7b3237eab..a0ad38019d7 100644 --- a/src/layer/convolution.cpp +++ b/src/layer/convolution.cpp @@ -158,7 +158,7 @@ int Convolution::forward(const Mat& bottom_blob, Mat& top_blob, const Option& op int channels = bottom_blob.c; size_t elemsize = bottom_blob.elemsize; -// fprintf(stderr, "Convolution input %d x %d pad = %d %d ksize=%d %d stride=%d %d\n", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h); +// NCNN_LOGE("Convolution input %d x %d pad = %d %d ksize=%d %d stride=%d %d", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h); const int kernel_extent_w = dilation_w * (kernel_w - 1) + 1; const int kernel_extent_h = dilation_h * (kernel_h - 1) + 1; @@ -322,7 +322,7 @@ int Convolution::forward_int8(const Mat& bottom_blob, Mat& top_blob, const Optio int channels = bottom_blob.c; size_t elemsize = bottom_blob.elemsize; -// fprintf(stderr, "Convolution input %d x %d ksize=%d %d stride=%d %d\n", w, h, kernel_w, kernel_h, stride_w, stride_h); +// NCNN_LOGE("Convolution input %d x %d ksize=%d %d stride=%d %d", w, h, kernel_w, kernel_h, stride_w, stride_h); const int kernel_extent_w = dilation_w * (kernel_w - 1) + 1; const int kernel_extent_h = dilation_h * (kernel_h - 1) + 1; diff --git a/src/layer/convolutiondepthwise.cpp b/src/layer/convolutiondepthwise.cpp index cb4e0cbc74b..09c59f4f504 100644 --- a/src/layer/convolutiondepthwise.cpp +++ b/src/layer/convolutiondepthwise.cpp @@ -146,7 +146,7 @@ int ConvolutionDepthWise::forward(const Mat& bottom_blob, Mat& top_blob, const O return -100; } -// fprintf(stderr, "ConvolutionDepthWise input %d x %d pad = %d %d ksize=%d %d stride=%d %d\n", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h); +// NCNN_LOGE("ConvolutionDepthWise input %d x %d pad = %d %d ksize=%d %d stride=%d %d", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h); const int kernel_extent_w = dilation_w * (kernel_w - 1) + 1; const int kernel_extent_h = dilation_h * (kernel_h - 1) + 1; @@ -391,7 +391,7 @@ int ConvolutionDepthWise::forward_int8(const Mat& bottom_blob, Mat& top_blob, co return -100; } -// fprintf(stderr, "ConvolutionDepthWise input %d x %d pad = %d %d ksize=%d %d stride=%d %d\n", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h); +// NCNN_LOGE("ConvolutionDepthWise input %d x %d pad = %d %d ksize=%d %d stride=%d %d", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h); const int kernel_extent_w = dilation_w * (kernel_w - 1) + 1; const int kernel_extent_h = dilation_h * (kernel_h - 1) + 1; diff --git a/src/layer/deconvolution.cpp b/src/layer/deconvolution.cpp index 4adc1df6d33..eb372444fb7 100644 --- a/src/layer/deconvolution.cpp +++ b/src/layer/deconvolution.cpp @@ -77,7 +77,7 @@ int Deconvolution::forward(const Mat& bottom_blob, Mat& top_blob, const Option& int channels = bottom_blob.c; size_t elemsize = bottom_blob.elemsize; -// fprintf(stderr, "Deconvolution input %d x %d pad = %d %d ksize=%d %d stride=%d %d\n", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h); +// NCNN_LOGE("Deconvolution input %d x %d pad = %d %d ksize=%d %d stride=%d %d", w, h, pad_w, pad_h, kernel_w, kernel_h, stride_w, stride_h); const int kernel_extent_w = dilation_w * (kernel_w - 1) + 1; const int kernel_extent_h = dilation_h * (kernel_h - 1) + 1; diff --git a/src/layer/interp.cpp b/src/layer/interp.cpp index 9d6782ea8e4..eec761ac0a7 100644 --- a/src/layer/interp.cpp +++ b/src/layer/interp.cpp @@ -35,7 +35,7 @@ int Interp::load_param(const ParamDict& pd) if (resize_type < 1 || resize_type > 3) { - fprintf(stderr, "unsupported resize type %d\n", resize_type); + NCNN_LOGE("unsupported resize type %d", resize_type); return -1; } diff --git a/src/layer/pooling.cpp b/src/layer/pooling.cpp index f9924527f33..6d3ceeccc5b 100644 --- a/src/layer/pooling.cpp +++ b/src/layer/pooling.cpp @@ -55,7 +55,7 @@ int Pooling::forward(const Mat& bottom_blob, Mat& top_blob, const Option& opt) c int channels = bottom_blob.c; size_t elemsize = bottom_blob.elemsize; -// fprintf(stderr, "Pooling input %d x %d pad = %d %d %d %d ksize=%d %d stride=%d %d\n", w, h, pad_left, pad_right, pad_top, pad_bottom, kernel_w, kernel_h, stride_w, stride_h); +// NCNN_LOGE("Pooling input %d x %d pad = %d %d %d %d ksize=%d %d stride=%d %d", w, h, pad_left, pad_right, pad_top, pad_bottom, kernel_w, kernel_h, stride_w, stride_h); if (global_pooling) { top_blob.create(channels, elemsize, opt.blob_allocator); diff --git a/src/layer/softmax.cpp b/src/layer/softmax.cpp index cdad47b3373..de2ed2c95f0 100644 --- a/src/layer/softmax.cpp +++ b/src/layer/softmax.cpp @@ -13,6 +13,7 @@ // specific language governing permissions and limitations under the License. #include "softmax.h" + #include #include #include @@ -36,7 +37,7 @@ int Softmax::load_param(const ParamDict& pd) int fixbug0 = pd.get(1, 0); if (fixbug0 == 0 && axis != 0) { - fprintf(stderr, "param is too old, please regenerate!\n"); + NCNN_LOGE("param is too old, please regenerate!"); return -1; } diff --git a/src/layer/vulkan/packing_vulkan.cpp b/src/layer/vulkan/packing_vulkan.cpp index b4046a9f102..4c611408baf 100644 --- a/src/layer/vulkan/packing_vulkan.cpp +++ b/src/layer/vulkan/packing_vulkan.cpp @@ -238,7 +238,7 @@ int Packing_vulkan::destroy_pipeline(const Option& /*opt*/) int Packing_vulkan::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute& cmd, const Option& opt) const { int elempack = bottom_blob.elempack; -// fprintf(stderr, "Packing_vulkan b2b %d %d %d %d %d %d\n", elempack, out_elempack, cast_type_from, cast_type_to, storage_type_from, storage_type_to); +// NCNN_LOGE("Packing_vulkan b2b %d %d %d %d %d %d", elempack, out_elempack, cast_type_from, cast_type_to, storage_type_from, storage_type_to); if (elempack == out_elempack && cast_type_from == cast_type_to && bottom_blob.allocator == opt.blob_vkallocator) { @@ -410,7 +410,7 @@ int Packing_vulkan::forward(const VkMat& bottom_blob, VkMat& top_blob, VkCompute int Packing_vulkan::forward(const VkImageMat& bottom_blob, VkImageMat& top_blob, VkCompute& cmd, const Option& opt) const { int elempack = bottom_blob.elempack; -// fprintf(stderr, "Packing_vulkan i2i %d %d %d %d %d %d\n", elempack, out_elempack, cast_type_from, cast_type_to, storage_type_from, storage_type_to); +// NCNN_LOGE("Packing_vulkan i2i %d %d %d %d %d %d", elempack, out_elempack, cast_type_from, cast_type_to, storage_type_from, storage_type_to); if (elempack == out_elempack && cast_type_from == cast_type_to && bottom_blob.allocator == opt.blob_vkallocator) { @@ -571,7 +571,7 @@ int Packing_vulkan::forward(const VkImageMat& bottom_blob, VkImageMat& top_blob, int Packing_vulkan::forward(const VkMat& bottom_blob, VkImageMat& top_blob, VkCompute& cmd, const Option& opt) const { int elempack = bottom_blob.elempack; -// fprintf(stderr, "Packing_vulkan b2i %d %d %d %d %d %d\n", elempack, out_elempack, cast_type_from, cast_type_to, storage_type_from, storage_type_to); +// NCNN_LOGE("Packing_vulkan b2i %d %d %d %d %d %d", elempack, out_elempack, cast_type_from, cast_type_to, storage_type_from, storage_type_to); int w = bottom_blob.w; int h = bottom_blob.h; @@ -582,7 +582,7 @@ int Packing_vulkan::forward(const VkMat& bottom_blob, VkImageMat& top_blob, VkCo // if (!use_padding) // { // // identity if use_padding not allowed -// fprintf(stderr, "buffer to mat use_padding not allowed\n"); +// NCNN_LOGE("buffer to mat use_padding not allowed"); // return -1; // } @@ -713,7 +713,7 @@ int Packing_vulkan::forward(const VkMat& bottom_blob, VkImageMat& top_blob, VkCo int Packing_vulkan::forward(const VkImageMat& bottom_blob, VkMat& top_blob, VkCompute& cmd, const Option& opt) const { int elempack = bottom_blob.elempack; -// fprintf(stderr, "Packing_vulkan i2b %d %d %d %d %d %d\n", elempack, out_elempack, cast_type_from, cast_type_to, storage_type_from, storage_type_to); +// NCNN_LOGE("Packing_vulkan i2b %d %d %d %d %d %d", elempack, out_elempack, cast_type_from, cast_type_to, storage_type_from, storage_type_to); int w = bottom_blob.w; int h = bottom_blob.h; @@ -724,7 +724,7 @@ int Packing_vulkan::forward(const VkImageMat& bottom_blob, VkMat& top_blob, VkCo // if (!use_padding) // { // // identity if use_padding not allowed -// fprintf(stderr, "buffer to mat use_padding not allowed\n"); +// NCNN_LOGE("buffer to mat use_padding not allowed"); // return -1; // } diff --git a/src/layer/yolodetectionoutput.cpp b/src/layer/yolodetectionoutput.cpp index be1378a6291..d26f4824627 100644 --- a/src/layer/yolodetectionoutput.cpp +++ b/src/layer/yolodetectionoutput.cpp @@ -250,7 +250,7 @@ int YoloDetectionOutput::forward_inplace(std::vector& bottom_top_blobs, con } } - // fprintf(stderr, "%d %f %f\n", class_index, box_score, class_score); + // NCNN_LOGE("%d %f %f", class_index, box_score, class_score); float confidence = box_score * class_score; if (confidence >= confidence_threshold) diff --git a/src/mat.cpp b/src/mat.cpp index 98b6f859cc4..bed32c94076 100644 --- a/src/mat.cpp +++ b/src/mat.cpp @@ -209,7 +209,7 @@ unsigned short float32_to_float16(float value) unsigned short exponent = (tmp.u & 0x7F800000) >> 23; unsigned int significand = tmp.u & 0x7FFFFF; - // fprintf(stderr, "%d %d %d\n", sign, exponent, significand); + // NCNN_LOGE("%d %d %d", sign, exponent, significand); // 1 : 5 : 10 unsigned short fp16; @@ -263,7 +263,7 @@ float float16_to_float32(unsigned short value) unsigned short exponent = (value & 0x7c00) >> 10; unsigned short significand = value & 0x03FF; - // fprintf(stderr, "%d %d %d\n", sign, exponent, significand); + // NCNN_LOGE("%d %d %d", sign, exponent, significand); // 1 : 8 : 23 union diff --git a/src/mat.h b/src/mat.h index 6b565eaa4c3..091e9b471bd 100644 --- a/src/mat.h +++ b/src/mat.h @@ -15,7 +15,6 @@ #ifndef NCNN_MAT_H #define NCNN_MAT_H -#include #include #include #if __ARM_NEON diff --git a/src/modelbin.cpp b/src/modelbin.cpp index 51c35e2ebd2..44cad70c41d 100644 --- a/src/modelbin.cpp +++ b/src/modelbin.cpp @@ -14,7 +14,6 @@ #include "modelbin.h" -#include #include #include #include "datareader.h" @@ -68,7 +67,7 @@ Mat ModelBinFromDataReader::load(int w, int type) const nread = dr.read(&flag_struct, sizeof(flag_struct)); if (nread != sizeof(flag_struct)) { - fprintf(stderr, "ModelBin read flag_struct failed %zd\n", nread); + NCNN_LOGE("ModelBin read flag_struct failed %zd", nread); return Mat(); } @@ -83,7 +82,7 @@ Mat ModelBinFromDataReader::load(int w, int type) const nread = dr.read(float16_weights.data(), align_data_size); if (nread != align_data_size) { - fprintf(stderr, "ModelBin read float16_weights failed %zd\n", nread); + NCNN_LOGE("ModelBin read float16_weights failed %zd", nread); return Mat(); } @@ -98,7 +97,7 @@ Mat ModelBinFromDataReader::load(int w, int type) const nread = dr.read(int8_weights.data(), align_data_size); if (nread != align_data_size) { - fprintf(stderr, "ModelBin read int8_weights failed %zd\n", nread); + NCNN_LOGE("ModelBin read int8_weights failed %zd", nread); return Mat(); } @@ -120,7 +119,7 @@ Mat ModelBinFromDataReader::load(int w, int type) const nread = dr.read(m, w * sizeof(float)); if (nread != w * sizeof(float)) { - fprintf(stderr, "ModelBin read weight_data failed %zd\n", nread); + NCNN_LOGE("ModelBin read weight_data failed %zd", nread); return Mat(); } @@ -138,7 +137,7 @@ Mat ModelBinFromDataReader::load(int w, int type) const nread = dr.read(quantization_value, 256 * sizeof(float)); if (nread != 256 * sizeof(float)) { - fprintf(stderr, "ModelBin read quantization_value failed %zd\n", nread); + NCNN_LOGE("ModelBin read quantization_value failed %zd", nread); return Mat(); } @@ -148,7 +147,7 @@ Mat ModelBinFromDataReader::load(int w, int type) const nread = dr.read(index_array.data(), align_weight_data_size); if (nread != align_weight_data_size) { - fprintf(stderr, "ModelBin read index_array failed %zd\n", nread); + NCNN_LOGE("ModelBin read index_array failed %zd", nread); return Mat(); } @@ -164,7 +163,7 @@ Mat ModelBinFromDataReader::load(int w, int type) const nread = dr.read(m, w * sizeof(float)); if (nread != w * sizeof(float)) { - fprintf(stderr, "ModelBin read weight_data failed %zd\n", nread); + NCNN_LOGE("ModelBin read weight_data failed %zd", nread); return Mat(); } } @@ -181,7 +180,7 @@ Mat ModelBinFromDataReader::load(int w, int type) const size_t nread = dr.read(m, w * sizeof(float)); if (nread != w * sizeof(float)) { - fprintf(stderr, "ModelBin read weight_data failed %zd\n", nread); + NCNN_LOGE("ModelBin read weight_data failed %zd", nread); return Mat(); } @@ -189,7 +188,7 @@ Mat ModelBinFromDataReader::load(int w, int type) const } else { - fprintf(stderr, "ModelBin load type %d not implemented\n", type); + NCNN_LOGE("ModelBin load type %d not implemented", type); return Mat(); } diff --git a/src/net.cpp b/src/net.cpp index 4a65f102eef..407ab456c49 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -22,7 +22,6 @@ #include "relu.h" #include -#include #include #include @@ -59,7 +58,7 @@ int Net::register_custom_layer(const char* type, layer_creator_func creator) int typeindex = layer_to_index(type); if (typeindex != -1) { - fprintf(stderr, "can not register build-in layer type %s\n", type); + NCNN_LOGE("can not register build-in layer type %s", type); return -1; } @@ -71,7 +70,7 @@ int Net::register_custom_layer(const char* type, layer_creator_func creator) } else { - fprintf(stderr, "overwrite existing custom layer type %s\n", type); + NCNN_LOGE("overwrite existing custom layer type %s", type); custom_layer_registry[custom_index].name = type; custom_layer_registry[custom_index].creator = creator; } @@ -85,7 +84,7 @@ int Net::register_custom_layer(int index, layer_creator_func creator) int custom_index = index & ~LayerType::CustomBit; if (index == custom_index) { - fprintf(stderr, "can not register build-in layer index %d\n", custom_index); + NCNN_LOGE("can not register build-in layer index %d", custom_index); return -1; } @@ -101,7 +100,7 @@ int Net::register_custom_layer(int index, layer_creator_func creator) if (custom_layer_registry[custom_index].creator) { - fprintf(stderr, "overwrite existing custom layer index %d\n", custom_index); + NCNN_LOGE("overwrite existing custom layer index %d", custom_index); } custom_layer_registry[custom_index].creator = creator; @@ -114,7 +113,7 @@ int Net::load_param(const DataReader& dr) #define SCAN_VALUE(fmt, v) \ if (dr.scan(fmt, &v) != 1) \ { \ - fprintf(stderr, "parse " #v " failed\n"); \ + NCNN_LOGE("parse " #v " failed"); \ return -1; \ } @@ -122,7 +121,7 @@ int Net::load_param(const DataReader& dr) SCAN_VALUE("%d", magic) if (magic != 7767517) { - fprintf(stderr, "param is too old, please regenerate\n"); + NCNN_LOGE("param is too old, please regenerate"); return -1; } @@ -133,7 +132,7 @@ int Net::load_param(const DataReader& dr) SCAN_VALUE("%d", blob_count) if (layer_count <= 0 || blob_count <= 0) { - fprintf(stderr, "invalid layer_count or blob_count\n"); + NCNN_LOGE("invalid layer_count or blob_count"); return -1; } @@ -178,7 +177,7 @@ int Net::load_param(const DataReader& dr) } if (!layer) { - fprintf(stderr, "layer %s not exists or registered\n", layer_type); + NCNN_LOGE("layer %s not exists or registered", layer_type); clear(); return -1; } @@ -190,7 +189,7 @@ int Net::load_param(const DataReader& dr) layer->type = std::string(layer_type); layer->name = std::string(layer_name); -// fprintf(stderr, "new layer %d %s\n", i, layer_name); +// NCNN_LOGE("new layer %d %s", i, layer_name); layer->bottoms.resize(bottom_count); @@ -207,7 +206,7 @@ int Net::load_param(const DataReader& dr) bottom_blob_index = blob_index; blob.name = std::string(bottom_name); -// fprintf(stderr, "new blob %s\n", bottom_name); +// NCNN_LOGE("new blob %s", bottom_name); blob_index++; } @@ -228,7 +227,7 @@ int Net::load_param(const DataReader& dr) SCAN_VALUE("%255s", blob_name) blob.name = std::string(blob_name); -// fprintf(stderr, "new blob %s\n", blob_name); +// NCNN_LOGE("new blob %s", blob_name); blob.producer = i; @@ -241,7 +240,7 @@ int Net::load_param(const DataReader& dr) int pdlr = pd.load_param(dr); if (pdlr != 0) { - fprintf(stderr, "ParamDict load_param failed\n"); + NCNN_LOGE("ParamDict load_param failed"); continue; } @@ -288,7 +287,7 @@ int Net::load_param(const DataReader& dr) int lr = layer->load_param(pd); if (lr != 0) { - fprintf(stderr, "layer load_param failed\n"); + NCNN_LOGE("layer load_param failed"); continue; } @@ -305,7 +304,7 @@ int Net::load_param_bin(const DataReader& dr) #define READ_VALUE(buf) \ if (dr.read(&buf, sizeof(buf)) != sizeof(buf)) \ { \ - fprintf(stderr, "read " #buf " failed\n"); \ + NCNN_LOGE("read " #buf " failed"); \ return -1; \ } @@ -313,7 +312,7 @@ int Net::load_param_bin(const DataReader& dr) READ_VALUE(magic) if (magic != 7767517) { - fprintf(stderr, "param is too old, please regenerate\n"); + NCNN_LOGE("param is too old, please regenerate"); return -1; } @@ -323,7 +322,7 @@ int Net::load_param_bin(const DataReader& dr) READ_VALUE(blob_count) if (layer_count <= 0 || blob_count <= 0) { - fprintf(stderr, "invalid layer_count or blob_count\n"); + NCNN_LOGE("invalid layer_count or blob_count"); return -1; } @@ -366,7 +365,7 @@ int Net::load_param_bin(const DataReader& dr) } if (!layer) { - fprintf(stderr, "layer %d not exists or registered\n", typeindex); + NCNN_LOGE("layer %d not exists or registered", typeindex); clear(); return -1; } @@ -378,7 +377,7 @@ int Net::load_param_bin(const DataReader& dr) // layer->type = std::string(layer_type); // layer->name = std::string(layer_name); -// fprintf(stderr, "new layer %d\n", typeindex); +// NCNN_LOGE("new layer %d", typeindex); layer->bottoms.resize(bottom_count); for (int j=0; jload_param(pd); if (lr != 0) { - fprintf(stderr, "layer load_param failed\n"); + NCNN_LOGE("layer load_param failed"); continue; } @@ -475,7 +474,7 @@ int Net::load_model(const DataReader& dr) { if (layers.empty()) { - fprintf(stderr, "network graph not ready\n"); + NCNN_LOGE("network graph not ready"); return -1; } @@ -490,7 +489,7 @@ int Net::load_model(const DataReader& dr) //Here we found inconsistent content in the parameter file. if (!layer) { - fprintf(stderr, "load_model error at layer %d, parameter file has inconsistent content.\n", (int)i); + NCNN_LOGE("load_model error at layer %d, parameter file has inconsistent content.", (int)i); ret = -1; break; } @@ -498,7 +497,7 @@ int Net::load_model(const DataReader& dr) int lret = layer->load_model(mb); if (lret != 0) { - fprintf(stderr, "layer load_model %d failed\n", (int)i); + NCNN_LOGE("layer load_model %d failed", (int)i); ret = -1; break; } @@ -513,7 +512,7 @@ int Net::load_model(const DataReader& dr) //Here we found inconsistent content in the parameter file. if (!layer) { - fprintf(stderr, "load_model error at layer %d, parameter file has inconsistent content.\n", (int)i); + NCNN_LOGE("load_model error at layer %d, parameter file has inconsistent content.", (int)i); ret = -1; break; } @@ -527,7 +526,7 @@ int Net::load_model(const DataReader& dr) int cret = layer->create_pipeline(opt1); if (cret != 0) { - fprintf(stderr, "layer create_pipeline %d failed\n", (int)i); + NCNN_LOGE("layer create_pipeline %d failed", (int)i); ret = -1; break; } @@ -565,7 +564,7 @@ int Net::load_param(const char* protopath) FILE* fp = fopen(protopath, "rb"); if (!fp) { - fprintf(stderr, "fopen %s failed\n", protopath); + NCNN_LOGE("fopen %s failed", protopath); return -1; } @@ -586,7 +585,7 @@ int Net::load_param_bin(const char* protopath) FILE* fp = fopen(protopath, "rb"); if (!fp) { - fprintf(stderr, "fopen %s failed\n", protopath); + NCNN_LOGE("fopen %s failed", protopath); return -1; } @@ -606,7 +605,7 @@ int Net::load_model(const char* modelpath) FILE* fp = fopen(modelpath, "rb"); if (!fp) { - fprintf(stderr, "fopen %s failed\n", modelpath); + NCNN_LOGE("fopen %s failed", modelpath); return -1; } @@ -645,7 +644,7 @@ int Net::load_param(AAssetManager* mgr, const char* assetpath) AAsset* asset = AAssetManager_open(mgr, assetpath, AASSET_MODE_BUFFER); if (!asset) { - fprintf(stderr, "AAssetManager_open %s failed\n", assetpath); + NCNN_LOGE("AAssetManager_open %s failed", assetpath); return -1; } @@ -666,7 +665,7 @@ int Net::load_param_bin(AAssetManager* mgr, const char* assetpath) AAsset* asset = AAssetManager_open(mgr, assetpath, AASSET_MODE_BUFFER); if (!asset) { - fprintf(stderr, "AAssetManager_open %s failed\n", assetpath); + NCNN_LOGE("AAssetManager_open %s failed", assetpath); return -1; } @@ -686,7 +685,7 @@ int Net::load_model(AAssetManager* mgr, const char* assetpath) AAsset* asset = AAssetManager_open(mgr, assetpath, AASSET_MODE_STREAMING); if (!asset) { - fprintf(stderr, "AAssetManager_open %s failed\n", assetpath); + NCNN_LOGE("AAssetManager_open %s failed", assetpath); return -1; } @@ -700,7 +699,7 @@ int Net::fuse_network() { // set the int8 op fusion:requantize #if NCNN_STRING && NCNN_REQUANT - // fprintf(stderr, "Test op fusion to int8 implement:\n"); + // NCNN_LOGE("Test op fusion to int8 implement:"); // parse the network whether is a quantization model bool net_quantized = false; for (size_t i=0; itype == "ConvolutionDepthWise" && ((ConvolutionDepthWise*)layer_next)->weight_data.elemsize != 1u) continue; - // fprintf(stderr, "%s, %s\n", layer->name.c_str(), layer_next->name.c_str()); + // NCNN_LOGE("%s, %s", layer->name.c_str(), layer_next->name.c_str()); if (layer->type == "Convolution" && layer_next->type == "Convolution") { ((Convolution*)layer)->use_int8_requantize = true; @@ -776,7 +775,7 @@ int Net::fuse_network() if (layer_next_2->type == "ConvolutionDepthWise" && ((ConvolutionDepthWise*)layer_next_2)->weight_data.elemsize != 1u) continue; -// fprintf(stderr, "%s, %s, %s\n", layer->name.c_str(), layer_next->name.c_str(), layer_next_2->name.c_str()); +// NCNN_LOGE("%s, %s, %s", layer->name.c_str(), layer_next->name.c_str(), layer_next_2->name.c_str()); if (layer->type == "Convolution" && layer_next_2->type == "Convolution") { ((Convolution*)layer)->use_int8_requantize = true; @@ -806,20 +805,20 @@ int Net::fuse_network() int layer_next_3_index = blobs[layer_next_2->tops[i]].consumers[0]; if (layers[layer_next_3_index]->type != "Convolution" && layers[layer_next_3_index]->type != "ConvolutionDepthWise" && layers[layer_next_3_index]->type != "PriorBox" ) { - // fprintf(stderr, "%s, %s, %s, %s\n", layer->name.c_str(), layer_next->name.c_str(), layer_next_2->name.c_str(), layers[layer_next_3_index]->name.c_str()); + // NCNN_LOGE("%s, %s, %s, %s", layer->name.c_str(), layer_next->name.c_str(), layer_next_2->name.c_str(), layers[layer_next_3_index]->name.c_str()); all_conv = false; } } if (all_conv == true && layer_next_2->tops.size() >= size_t(2)) { - // fprintf(stderr, "%s, %s, %s, ", layer->name.c_str(), layer_next->name.c_str(), layer_next_2->name.c_str()); + // NCNN_LOGE("%s, %s, %s, ", layer->name.c_str(), layer_next->name.c_str(), layer_next_2->name.c_str()); for (size_t i=0; itops.size(); i++) { int layer_next_3_index = blobs[layer_next_2->tops[i]].consumers[0]; Layer* layer_next_3 = layers[layer_next_3_index]; - // fprintf(stderr, "%s, ", layer_next_3->name.c_str()); + // NCNN_LOGE("%s, ", layer_next_3->name.c_str()); if (layer_next_3->type == "Convolution") { ((Convolution*)layer)->top_blob_int8_scale = ((Convolution*)layer_next_3)->bottom_blob_int8_scale; @@ -827,12 +826,12 @@ int Net::fuse_network() } ((Convolution*)layer)->use_int8_requantize = true; - // fprintf(stderr, "\n"); + // NCNN_LOGE(""); } } else { - // fprintf(stderr, "%s, %s\n", layer->name.c_str(), layer_next->name.c_str()); + // NCNN_LOGE("%s, %s", layer->name.c_str(), layer_next->name.c_str()); } } else if (layer_next->type == "Pooling") @@ -841,7 +840,7 @@ int Net::fuse_network() } else { - // fprintf(stderr, "%s\n", layer->name.c_str()); + // NCNN_LOGE("%s", layer->name.c_str()); } } } @@ -870,7 +869,7 @@ void Net::clear() int dret = layer->destroy_pipeline(opt1); if (dret != 0) { - fprintf(stderr, "layer destroy_pipeline failed\n"); + NCNN_LOGE("layer destroy_pipeline failed"); // ignore anyway } @@ -939,7 +938,7 @@ int Net::upload_model() int uret = layers[i]->upload_model(cmd, opt_upload); if (uret != 0) { - fprintf(stderr, "layer upload_model %d failed\n", (int)i); + NCNN_LOGE("layer upload_model %d failed", (int)i); return -1; } } @@ -973,7 +972,7 @@ int Net::find_blob_index_by_name(const char* name) const } } - fprintf(stderr, "find_blob_index_by_name %s failed\n", name); + NCNN_LOGE("find_blob_index_by_name %s failed", name); return -1; } @@ -988,7 +987,7 @@ int Net::find_layer_index_by_name(const char* name) const } } - fprintf(stderr, "find_layer_index_by_name %s failed\n", name); + NCNN_LOGE("find_layer_index_by_name %s failed", name); return -1; } @@ -1031,7 +1030,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, const Optio { const Layer* layer = layers[layer_index]; -// fprintf(stderr, "forward_layer %d %s\n", layer_index, layer->name.c_str()); +// NCNN_LOGE("forward_layer %d %s", layer_index, layer->name.c_str()); if (layer->one_blob_only) { @@ -1222,9 +1221,9 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, const Optio } } -// fprintf(stderr, "forward_layer %d %s done\n", layer_index, layer->name.c_str()); +// NCNN_LOGE("forward_layer %d %s done", layer_index, layer->name.c_str()); // const Mat& blob = blob_mats[layer->tops[0]]; -// fprintf(stderr, "[%-2d %-16s %-16s] %d blobs count = %-3d size = %-3d x %-3d\n", layer_index, layer->type.c_str(), layer->name.c_str(), layer->tops[0], blob.c, blob.h, blob.w); +// NCNN_LOGE("[%-2d %-16s %-16s] %d blobs count = %-3d size = %-3d x %-3d", layer_index, layer->type.c_str(), layer->name.c_str(), layer->tops[0], blob.c, blob.h, blob.w); return 0; } @@ -1234,7 +1233,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector { const Layer* layer = layers[layer_index]; -// fprintf(stderr, "forward_layer %d %d %s\n", layer->support_vulkan, layer_index, layer->name.c_str()); +// NCNN_LOGE("forward_layer %d %d %s", layer->support_vulkan, layer_index, layer->name.c_str()); if (layer->support_vulkan) { @@ -1271,7 +1270,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector { VkMat bottom_blob_copy; cmd.record_clone(bottom_blob, bottom_blob_copy, opt); -// fprintf(stderr, "clone %p[+%lu] %p[+%lu]\n", bottom_blob.buffer(), bottom_blob.buffer_offset(), bottom_blob_copy.buffer(), bottom_blob_copy.buffer_offset()); +// NCNN_LOGE("clone %p[+%lu] %p[+%lu]", bottom_blob.buffer(), bottom_blob.buffer_offset(), bottom_blob_copy.buffer(), bottom_blob_copy.buffer_offset()); bottom_blob = bottom_blob_copy; } } @@ -1345,7 +1344,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector { VkMat bottom_blob_copy; cmd.record_clone(bottom_blobs[i], bottom_blob_copy, opt); -// fprintf(stderr, "clone %p[+%lu] %p[+%lu]\n", bottom_blobs[i].buffer(), bottom_blobs[i].buffer_offset(), bottom_blob_copy.buffer(), bottom_blob_copy.buffer_offset()); +// NCNN_LOGE("clone %p[+%lu] %p[+%lu]", bottom_blobs[i].buffer(), bottom_blobs[i].buffer_offset(), bottom_blob_copy.buffer(), bottom_blob_copy.buffer_offset()); bottom_blobs[i] = bottom_blob_copy; } } @@ -1440,7 +1439,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector continue; double duration_us = (end - start) * vkdev->info.timestamp_period / 1000; - fprintf(stderr, "%-24s %-30s %8.2lfus |\n", layers[i]->type.c_str(), layers[i]->name.c_str(), duration_us); + NCNN_LOGE("%-24s %-30s %8.2lfus |", layers[i]->type.c_str(), layers[i]->name.c_str(), duration_us); } #endif // NCNN_BENCHMARK @@ -1544,7 +1543,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector continue; double duration_us = (end - start) * vkdev->info.timestamp_period / 1000; - fprintf(stderr, "%-24s %-30s %8.2lfus |\n", layers[i]->type.c_str(), layers[i]->name.c_str(), duration_us); + NCNN_LOGE("%-24s %-30s %8.2lfus |", layers[i]->type.c_str(), layers[i]->name.c_str(), duration_us); } #endif // NCNN_BENCHMARK @@ -1618,7 +1617,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector } } -// fprintf(stderr, "forward_layer %d %d %s done\n", layer->support_vulkan, layer_index, layer->name.c_str()); +// NCNN_LOGE("forward_layer %d %d %s done", layer->support_vulkan, layer_index, layer->name.c_str()); return 0; } @@ -1627,7 +1626,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector { const Layer* layer = layers[layer_index]; -// fprintf(stderr, "forward_layer %d %d %s\n", layer->support_vulkan, layer_index, layer->name.c_str()); +// NCNN_LOGE("forward_layer %d %d %s", layer->support_vulkan, layer_index, layer->name.c_str()); if (layer->support_vulkan) { @@ -1699,7 +1698,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector { VkImageMat bottom_blob_copy; cmd.record_clone(bottom_blob, bottom_blob_copy, opt); -// fprintf(stderr, "clone %p[+%lu] %p[+%lu]\n", bottom_blob.buffer(), bottom_blob.buffer_offset(), bottom_blob_copy.buffer(), bottom_blob_copy.buffer_offset()); +// NCNN_LOGE("clone %p[+%lu] %p[+%lu]", bottom_blob.buffer(), bottom_blob.buffer_offset(), bottom_blob_copy.buffer(), bottom_blob_copy.buffer_offset()); bottom_blob = bottom_blob_copy; } } @@ -1814,7 +1813,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector { VkImageMat bottom_blob_copy; cmd.record_clone(bottom_blobs[i], bottom_blob_copy, opt); -// fprintf(stderr, "clone %p[+%lu] %p[+%lu]\n", bottom_blobs[i].buffer(), bottom_blobs[i].buffer_offset(), bottom_blob_copy.buffer(), bottom_blob_copy.buffer_offset()); +// NCNN_LOGE("clone %p[+%lu] %p[+%lu]", bottom_blobs[i].buffer(), bottom_blobs[i].buffer_offset(), bottom_blob_copy.buffer(), bottom_blob_copy.buffer_offset()); bottom_blobs[i] = bottom_blob_copy; } } @@ -1936,7 +1935,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector { VkMat bottom_blob_copy; cmd.record_clone(bottom_blob, bottom_blob_copy, opt); -// fprintf(stderr, "clone %p[+%lu] %p[+%lu]\n", bottom_blob.buffer(), bottom_blob.buffer_offset(), bottom_blob_copy.buffer(), bottom_blob_copy.buffer_offset()); +// NCNN_LOGE("clone %p[+%lu] %p[+%lu]", bottom_blob.buffer(), bottom_blob.buffer_offset(), bottom_blob_copy.buffer(), bottom_blob_copy.buffer_offset()); bottom_blob = bottom_blob_copy; } } @@ -2038,7 +2037,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector { VkMat bottom_blob_copy; cmd.record_clone(bottom_blobs[i], bottom_blob_copy, opt); -// fprintf(stderr, "clone %p[+%lu] %p[+%lu]\n", bottom_blobs[i].buffer(), bottom_blobs[i].buffer_offset(), bottom_blob_copy.buffer(), bottom_blob_copy.buffer_offset()); +// NCNN_LOGE("clone %p[+%lu] %p[+%lu]", bottom_blobs[i].buffer(), bottom_blobs[i].buffer_offset(), bottom_blob_copy.buffer(), bottom_blob_copy.buffer_offset()); bottom_blobs[i] = bottom_blob_copy; } } @@ -2162,7 +2161,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector continue; double duration_us = (end - start) * vkdev->info.timestamp_period / 1000; - fprintf(stderr, "%-24s %-30s %8.2lfus |\n", layers[i]->type.c_str(), layers[i]->name.c_str(), duration_us); + NCNN_LOGE("%-24s %-30s %8.2lfus |", layers[i]->type.c_str(), layers[i]->name.c_str(), duration_us); } #endif // NCNN_BENCHMARK @@ -2290,7 +2289,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector continue; double duration_us = (end - start) * vkdev->info.timestamp_period / 1000; - fprintf(stderr, "%-24s %-30s %8.2lfus |\n", layers[i]->type.c_str(), layers[i]->name.c_str(), duration_us); + NCNN_LOGE("%-24s %-30s %8.2lfus |", layers[i]->type.c_str(), layers[i]->name.c_str(), duration_us); } #endif // NCNN_BENCHMARK @@ -2364,7 +2363,7 @@ int Net::forward_layer(int layer_index, std::vector& blob_mats, std::vector } } -// fprintf(stderr, "forward_layer %d %d %s done\n", layer->support_vulkan, layer_index, layer->name.c_str()); +// NCNN_LOGE("forward_layer %d %d %s done", layer->support_vulkan, layer_index, layer->name.c_str()); return 0; } @@ -2438,7 +2437,7 @@ void Extractor::set_vulkan_compute(bool enable) } else { - fprintf(stderr, "set_vulkan_compute failed, network use_vulkan_compute disabled\n"); + NCNN_LOGE("set_vulkan_compute failed, network use_vulkan_compute disabled"); } } @@ -2546,7 +2545,7 @@ int Extractor::extract(int blob_index, Mat& feat) continue; double duration_us = (end - start) * net->vkdev->info.timestamp_period / 1000; - fprintf(stderr, "%-24s %-30s %8.2lfus |\n", net->layers[i]->type.c_str(), net->layers[i]->name.c_str(), duration_us); + NCNN_LOGE("%-24s %-30s %8.2lfus |", net->layers[i]->type.c_str(), net->layers[i]->name.c_str(), duration_us); } #endif // NCNN_BENCHMARK } @@ -2573,7 +2572,7 @@ int Extractor::extract(int blob_index, Mat& feat) continue; double duration_us = (end - start) * net->vkdev->info.timestamp_period / 1000; - fprintf(stderr, "%-24s %-30s %8.2lfus |\n", net->layers[i]->type.c_str(), net->layers[i]->name.c_str(), duration_us); + NCNN_LOGE("%-24s %-30s %8.2lfus |", net->layers[i]->type.c_str(), net->layers[i]->name.c_str(), duration_us); } #endif // NCNN_BENCHMARK } diff --git a/src/net.h b/src/net.h index 08abeb5fb95..9c68f23a174 100644 --- a/src/net.h +++ b/src/net.h @@ -15,7 +15,6 @@ #ifndef NCNN_NET_H #define NCNN_NET_H -#include #include #include "platform.h" #include "blob.h" diff --git a/src/paramdict.cpp b/src/paramdict.cpp index abe0d888137..eb3e29a3c5b 100644 --- a/src/paramdict.cpp +++ b/src/paramdict.cpp @@ -17,6 +17,10 @@ #include "datareader.h" #include "platform.h" +#if NCNN_STDIO || NCNN_STRING +#include +#endif + namespace ncnn { ParamDict::ParamDict() @@ -105,7 +109,7 @@ int ParamDict::load_param(const DataReader& dr) int nscan = dr.scan("%d", &len); if (nscan != 1) { - fprintf(stderr, "ParamDict read array length failed\n"); + NCNN_LOGE("ParamDict read array length failed"); return -1; } @@ -117,7 +121,7 @@ int ParamDict::load_param(const DataReader& dr) nscan = dr.scan(",%15[^,\n ]", vstr); if (nscan != 1) { - fprintf(stderr, "ParamDict read array element failed\n"); + NCNN_LOGE("ParamDict read array element failed"); return -1; } @@ -135,7 +139,7 @@ int ParamDict::load_param(const DataReader& dr) } if (nscan != 1) { - fprintf(stderr, "ParamDict parse array element failed\n"); + NCNN_LOGE("ParamDict parse array element failed"); return -1; } @@ -148,7 +152,7 @@ int ParamDict::load_param(const DataReader& dr) int nscan = dr.scan("%15s", vstr); if (nscan != 1) { - fprintf(stderr, "ParamDict read value failed\n"); + NCNN_LOGE("ParamDict read value failed"); return -1; } @@ -160,7 +164,7 @@ int ParamDict::load_param(const DataReader& dr) nscan = sscanf(vstr, "%d", ¶ms[id].i); if (nscan != 1) { - fprintf(stderr, "ParamDict parse value failed\n"); + NCNN_LOGE("ParamDict parse value failed"); return -1; } @@ -194,7 +198,7 @@ int ParamDict::load_param_bin(const DataReader& dr) nread = dr.read(&id, sizeof(int)); if (nread != sizeof(int)) { - fprintf(stderr, "ParamDict read id failed %zd\n", nread); + NCNN_LOGE("ParamDict read id failed %zd", nread); return -1; } @@ -212,7 +216,7 @@ int ParamDict::load_param_bin(const DataReader& dr) nread = dr.read(&len, sizeof(int)); if (nread != sizeof(int)) { - fprintf(stderr, "ParamDict read array length failed %zd\n", nread); + NCNN_LOGE("ParamDict read array length failed %zd", nread); return -1; } @@ -222,7 +226,7 @@ int ParamDict::load_param_bin(const DataReader& dr) nread = dr.read(ptr, sizeof(float) * len); if (nread != sizeof(float) * len) { - fprintf(stderr, "ParamDict read array element failed %zd\n", nread); + NCNN_LOGE("ParamDict read array element failed %zd", nread); return -1; } @@ -233,7 +237,7 @@ int ParamDict::load_param_bin(const DataReader& dr) nread = dr.read(¶ms[id].f, sizeof(float)); if (nread != sizeof(float)) { - fprintf(stderr, "ParamDict read value failed %zd\n", nread); + NCNN_LOGE("ParamDict read value failed %zd", nread); return -1; } @@ -243,7 +247,7 @@ int ParamDict::load_param_bin(const DataReader& dr) nread = dr.read(&id, sizeof(int)); if (nread != sizeof(int)) { - fprintf(stderr, "ParamDict read EOP failed %zd\n", nread); + NCNN_LOGE("ParamDict read EOP failed %zd", nread); return -1; } } diff --git a/src/pipeline.cpp b/src/pipeline.cpp index 6c8696aa8d8..975baec5f04 100644 --- a/src/pipeline.cpp +++ b/src/pipeline.cpp @@ -13,7 +13,6 @@ // specific language governing permissions and limitations under the License. #include "pipeline.h" -#include #include #include #include @@ -53,7 +52,7 @@ int Pipeline::create(const uint32_t* spv_data, size_t spv_data_size, const std:: int ret = resolve_shader_info(spv_data, spv_data_size, si); if (ret != 0) { - fprintf(stderr, "resolve_shader_info failed %d\n", ret); + NCNN_LOGE("resolve_shader_info failed %d", ret); return -1; } @@ -61,7 +60,7 @@ int Pipeline::create(const uint32_t* spv_data, size_t spv_data_size, const std:: int specialization_count_expected = si.specialization_count - 3; if ((int)specializations.size() != specialization_count_expected) { - fprintf(stderr, "pipeline specialization count mismatch, expect %d but got %d\n", specialization_count_expected, (int)specializations.size()); + NCNN_LOGE("pipeline specialization count mismatch, expect %d but got %d", specialization_count_expected, (int)specializations.size()); return -1; } @@ -74,7 +73,7 @@ int Pipeline::create(const uint32_t* spv_data, size_t spv_data_size, const std:: local_shader_module = vkdev->compile_shader_module(spv_data, spv_data_size); } -// fprintf(stderr, "local_shader_module %p created\n", local_shader_module); +// NCNN_LOGE("local_shader_module %p created", local_shader_module); return create(local_shader_module, si, specializations); } @@ -136,7 +135,7 @@ int Pipeline::create(int shader_type_index, const Option& opt, const std::vector int specialization_count_expected = si.specialization_count - 3; if ((int)specializations.size() != specialization_count_expected) { - fprintf(stderr, "pipeline %d specialization count mismatch, expect %d but got %d\n", shader_type_index, specialization_count_expected, (int)specializations.size()); + NCNN_LOGE("pipeline %d specialization count mismatch, expect %d but got %d", shader_type_index, specialization_count_expected, (int)specializations.size()); return -1; } @@ -252,7 +251,7 @@ void Pipeline::set_local_size_xyz(int w, int h, int c) local_size_y = h; local_size_z = c; -// fprintf(stderr, "local size = %d %d %d\n", local_size_x, local_size_y, local_size_z); +// NCNN_LOGE("local size = %d %d %d", local_size_x, local_size_y, local_size_z); } int Pipeline::create_descriptorset_layout() @@ -306,7 +305,7 @@ int Pipeline::create_descriptorset_layout() VkResult ret = vkCreateDescriptorSetLayout(vkdev->vkdevice(), &descriptorSetLayoutCreateInfo, 0, &descriptorset_layout); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateDescriptorSetLayout failed %d\n", ret); + NCNN_LOGE("vkCreateDescriptorSetLayout failed %d", ret); return -1; } @@ -352,7 +351,7 @@ int Pipeline::create_pipeline_layout() VkResult ret = vkCreatePipelineLayout(vkdev->vkdevice(), &pipelineLayoutCreateInfo, 0, &pipeline_layout); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreatePipelineLayout failed %d\n", ret); + NCNN_LOGE("vkCreatePipelineLayout failed %d", ret); return -1; } @@ -426,7 +425,7 @@ int Pipeline::create_pipeline(VkShaderModule shader_module, const std::vectorvkdevice(), 0, 1, &computePipelineCreateInfo, 0, &pipeline); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateComputePipelines failed %d\n", ret); + NCNN_LOGE("vkCreateComputePipelines failed %d", ret); return -1; } @@ -497,7 +496,7 @@ int Pipeline::create_descriptor_update_template() VkResult ret = vkdev->vkCreateDescriptorUpdateTemplateKHR(vkdev->vkdevice(), &descriptorUpdateTemplateCreateInfo, 0, &descriptor_update_template); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateDescriptorUpdateTemplateKHR failed %d\n", ret); + NCNN_LOGE("vkCreateDescriptorUpdateTemplateKHR failed %d", ret); return -1; } @@ -700,7 +699,7 @@ int ImportAndroidHardwareBufferPipeline::create_sampler(VkAndroidHardwareBufferI ret = vkCreateSampler(vkdev->vkdevice(), &samplerCreateInfo, 0, &sampler); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateSampler failed %d\n", ret); + NCNN_LOGE("vkCreateSampler failed %d", ret); return -1; } @@ -741,7 +740,7 @@ int ImportAndroidHardwareBufferPipeline::create_descriptorset_layout() VkResult ret = vkCreateDescriptorSetLayout(vkdev->vkdevice(), &descriptorSetLayoutCreateInfo, 0, &descriptorset_layout); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateDescriptorSetLayout failed %d\n", ret); + NCNN_LOGE("vkCreateDescriptorSetLayout failed %d", ret); return -1; } @@ -794,7 +793,7 @@ int ImportAndroidHardwareBufferPipeline::create_descriptor_update_template() VkResult ret = vkdev->vkCreateDescriptorUpdateTemplateKHR(vkdev->vkdevice(), &descriptorUpdateTemplateCreateInfo, 0, &descriptor_update_template); if (ret != VK_SUCCESS) { - fprintf(stderr, "vkCreateDescriptorUpdateTemplateKHR failed %d\n", ret); + NCNN_LOGE("vkCreateDescriptorUpdateTemplateKHR failed %d", ret); return -1; } diff --git a/src/platform.h.in b/src/platform.h.in index 804c218a826..df17760710a 100644 --- a/src/platform.h.in +++ b/src/platform.h.in @@ -135,4 +135,11 @@ private: } // namespace ncnn +#if NCNN_STDIO +#include +#define NCNN_LOGE(...) do { fprintf(stderr, ##__VA_ARGS__); fprintf(stderr, "\n"); } while(0) +#else +#define NCNN_LOGE(...) +#endif + #endif // NCNN_PLATFORM_H diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index ec586ca5fc6..00564e20d9d 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,23 +1,27 @@ +cmake_minimum_required(VERSION 3.1) # for CMAKE_CXX_STANDARD +set(CMAKE_CXX_STANDARD 11) + +if(MSVC) + # warning C4018: '<': signed/unsigned mismatch + # warning C4244: 'argument': conversion from 'uint64_t' to 'const unsigned int', possible loss of data + # warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. + add_definitions(/wd4018 /wd4244 /wd4996) +endif() add_subdirectory(caffe) add_subdirectory(mxnet) add_subdirectory(onnx) add_subdirectory(darknet) - add_subdirectory(quantize) add_executable(ncnn2mem ncnn2mem.cpp) - target_link_libraries(ncnn2mem PRIVATE ncnn) - if(NCNN_VULKAN) target_link_libraries(ncnn2mem PRIVATE ${Vulkan_LIBRARY}) endif() add_executable(ncnnoptimize ncnnoptimize.cpp) - target_link_libraries(ncnnoptimize PRIVATE ncnn) - if(NCNN_VULKAN) target_link_libraries(ncnnoptimize PRIVATE ${Vulkan_LIBRARY}) endif() diff --git a/tools/caffe/CMakeLists.txt b/tools/caffe/CMakeLists.txt index 47dc1dd7eb5..42c5e4c2ea0 100644 --- a/tools/caffe/CMakeLists.txt +++ b/tools/caffe/CMakeLists.txt @@ -8,7 +8,6 @@ if(PROTOBUF_FOUND) PRIVATE ${PROTOBUF_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - target_compile_options(caffe2ncnn PRIVATE -std=c++11) target_link_libraries(caffe2ncnn PRIVATE ${PROTOBUF_LIBRARIES}) # add all caffe2ncnn tool to a virtual project group diff --git a/tools/darknet/CMakeLists.txt b/tools/darknet/CMakeLists.txt index ed7b79d73fd..f2269f79ddf 100644 --- a/tools/darknet/CMakeLists.txt +++ b/tools/darknet/CMakeLists.txt @@ -1,3 +1,2 @@ add_executable(darknet2ncnn darknet2ncnn.cpp) -target_compile_options(darknet2ncnn PRIVATE -std=c++11) set_property(TARGET darknet2ncnn PROPERTY FOLDER "tools/converter") diff --git a/tools/onnx/CMakeLists.txt b/tools/onnx/CMakeLists.txt index dae10ca911d..78090291681 100644 --- a/tools/onnx/CMakeLists.txt +++ b/tools/onnx/CMakeLists.txt @@ -8,7 +8,6 @@ if(PROTOBUF_FOUND) PRIVATE ${PROTOBUF_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - target_compile_options(onnx2ncnn PRIVATE -std=c++11) target_link_libraries(onnx2ncnn PRIVATE ${PROTOBUF_LIBRARIES}) # add all onnx2ncnn tool to a virtual project group diff --git a/tools/quantize/CMakeLists.txt b/tools/quantize/CMakeLists.txt index cf629fca70c..63b62930d76 100644 --- a/tools/quantize/CMakeLists.txt +++ b/tools/quantize/CMakeLists.txt @@ -6,7 +6,6 @@ endif() if(OpenCV_FOUND) add_executable(ncnn2table ncnn2table.cpp) target_compile_definitions(ncnn2table PRIVATE -DOpenCV_VERSION_MAJOR=${OpenCV_VERSION_MAJOR}) - target_compile_options(ncnn2table PRIVATE -std=c++11) target_link_libraries(ncnn2table PRIVATE ncnn ${OpenCV_LIBS}) add_executable(ncnn2int8 ncnn2int8.cpp)