MCPcopy Create free account
hub / github.com/alibaba/MNN / createKernel

Method createKernel

source/backend/vulkan/image/execution/VulkanMatrixMultier4x4.cpp:18–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16VulkanMatrixMultier4x4::~VulkanMatrixMultier4x4() {
17}
18std::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
38VulkanMatrixMultier4x4::VulkanMatrixMultier4x4(VulkanBackend* backend, const float* B, int l, int h, int c, std::shared_ptr<VulkanImage> kernel) {
39 mBackend = backend;

Callers

nothing calls this directly

Calls 4

copyBufferToImageMethod · 0.80
mapMethod · 0.45
unmapMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected