From d82a349d161e6c9c94a886a4662d31237241bcff Mon Sep 17 00:00:00 2001 From: xiaying Date: Wed, 16 Aug 2023 11:40:09 +0800 Subject: [PATCH] Fix bug for https://github.com/alibaba/MNN/issues/2433 --- source/backend/vulkan/image/backend/VulkanTensor.cpp | 1 - .../backend/vulkan/image/execution/VulkanImageConverter.cpp | 4 ---- source/backend/vulkan/image/execution/VulkanRaster.cpp | 4 +--- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/source/backend/vulkan/image/backend/VulkanTensor.cpp b/source/backend/vulkan/image/backend/VulkanTensor.cpp index 2153cd2c3..ad930e269 100644 --- a/source/backend/vulkan/image/backend/VulkanTensor.cpp +++ b/source/backend/vulkan/image/backend/VulkanTensor.cpp @@ -54,7 +54,6 @@ std::array VulkanTensor::tensorShapeFormat(const Tensor *input) { iW = 1; iC = input->buffer().dim[0].extent; } - #ifdef LOG_VERBOSE MNN_PRINT("tensorShapeFormat : [%d, %d, %d, %d] \n", iN, iH, iW, iC); #endif diff --git a/source/backend/vulkan/image/execution/VulkanImageConverter.cpp b/source/backend/vulkan/image/execution/VulkanImageConverter.cpp index 7bd65523a..b1c2bee92 100644 --- a/source/backend/vulkan/image/execution/VulkanImageConverter.cpp +++ b/source/backend/vulkan/image/execution/VulkanImageConverter.cpp @@ -126,10 +126,6 @@ void VulkanImageConverter::encodeTensorToBuffer(const Tensor* srcTensor, VkBuffe const VulkanCommandPool::Buffer* cmdBuffer) { auto sourceFormat = TensorUtils::getDescribe(srcTensor)->dimensionFormat; auto destFormat = destBufferFormat; - if (sourceFormat == MNN_DATA_FORMAT_NC4HW4 && 1 >= srcTensor->width() && 1 >= srcTensor->height() && - srcTensor->channel() % 4 == 0) { - destFormat = MNN_DATA_FORMAT_NC4HW4; - } auto vkTensor = (VulkanTensor*)(srcTensor->deviceId()); auto tensor = srcTensor; diff --git a/source/backend/vulkan/image/execution/VulkanRaster.cpp b/source/backend/vulkan/image/execution/VulkanRaster.cpp index 25c637218..9822e7f75 100644 --- a/source/backend/vulkan/image/execution/VulkanRaster.cpp +++ b/source/backend/vulkan/image/execution/VulkanRaster.cpp @@ -156,8 +156,6 @@ ErrorCode VulkanRaster::onEncode(const std::vector &___inputs, const s for (int i=0; idimensions(); ++i) { bufferSize *= origin->length(i); } - ivec4 dims; - writeNCHW(dims, origin); ConvertInfo info; info.buffer.reset(new VulkanBuffer(vkBn->getDynamicMemoryPool(), false, bufferSize, nullptr, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT)); @@ -212,6 +210,7 @@ ErrorCode VulkanRaster::onEncode(const std::vector &___inputs, const s for (auto& iter : mInputBuffers) { auto& info = iter.second; info.convert->encodeTensorToBuffer(iter.first, info.buffer->buffer(), info.buffer->size(), 0, VulkanImageConverter::getTensorLinearFormat(iter.first), cmdBuffer); + cmdBuffer->barrierSource(info.buffer->buffer(), 0, info.buffer->size()); } //Blit if (needZero) { @@ -223,7 +222,6 @@ ErrorCode VulkanRaster::onEncode(const std::vector &___inputs, const s info.describe->writeBuffer(info.srcBuffer, 1, info.srcBufferSize); info.describe->writeBuffer(info.uniform->buffer(), 2, info.uniform->size()); info.pipeline->bind(cmdBuffer->get(), info.describe->get()); - cmdBuffer->barrierSource(info.srcBuffer, 0, info.srcBufferSize); vkCmdDispatch(cmdBuffer->get(), info.workGroup[0], info.workGroup[1], info.workGroup[2]); }