| 16 | VulkanMatrixMultier4x4::~VulkanMatrixMultier4x4() { |
| 17 | } |
| 18 | std::shared_ptr<VulkanImage> VulkanMatrixMultier4x4::createKernel(VulkanBackend* backend, const float* B, int l, int h, int c) { |
| 19 | |
| 20 | auto kernel = std::make_shared<VulkanImage>(backend->getMemoryPool(), false, |
| 21 | std::vector<int>{ALIGN_UP4(l), UP_DIV(h, 4) * c}); |
| 22 | if (nullptr == B) { |
| 23 | return kernel; |
| 24 | } |
| 25 | |
| 26 | // Compute mKernel |
| 27 | auto tempBuffer = std::make_shared<VulkanBuffer>(backend->getMemoryPool(), false, |
| 28 | ALIGN_UP4(l) * ALIGN_UP4(h) * c * sizeof(float)); |
| 29 | { |
| 30 | auto dest = tempBuffer->map(); |
| 31 | ::memcpy(dest, B, ALIGN_UP4(l) * ALIGN_UP4(h) * c * sizeof(float)); |
| 32 | tempBuffer->unmap(); |
| 33 | } |
| 34 | backend->copyBufferToImage(tempBuffer.get(), kernel.get(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); |
| 35 | return kernel; |
| 36 | } |
| 37 | |
| 38 | VulkanMatrixMultier4x4::VulkanMatrixMultier4x4(VulkanBackend* backend, const float* B, int l, int h, int c, std::shared_ptr<VulkanImage> kernel) { |
| 39 | mBackend = backend; |
nothing calls this directly
no test coverage detected