--------------------------Prelu--------------------------//
| 90 | } |
| 91 | //--------------------------Prelu--------------------------// |
| 92 | VulkanPrelu::VulkanPrelu(Backend *bn, const Op *op) : VulkanBasicExecution(bn) { |
| 93 | std::vector<VkDescriptorType> types{VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, |
| 94 | VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER}; |
| 95 | auto vulkanBn = static_cast<VulkanBackend *>(bn); |
| 96 | mPreluPipeline = vulkanBn->getPipeline("glsl_preluWithChannel_comp", |
| 97 | /*glsl_preluWithChannel_comp, glsl_preluWithChannel_comp_len,*/ types); |
| 98 | const auto prelu = op->main_as_PRelu(); |
| 99 | mGpuPreluParam.reset(new VulkanBuffer(vulkanBn->getMemoryPool(), false, sizeof(GpuReluParam), nullptr, |
| 100 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)); |
| 101 | int count = ALIGN_UP4(prelu->slope()->size()); |
| 102 | |
| 103 | mSlope.reset(new VulkanImage(vulkanBn->getMemoryPool(), false, std::vector<int>{count / 4, 1})); |
| 104 | { |
| 105 | std::shared_ptr<VulkanBuffer> slopeBuffer(new VulkanBuffer( |
| 106 | vulkanBn->getMemoryPool(), false, sizeof(float) * count, nullptr, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT)); |
| 107 | auto slope = slopeBuffer->map(); |
| 108 | ::memset(slope, 0, count * sizeof(float)); |
| 109 | ::memcpy(slope, prelu->slope()->data(), prelu->slope()->size() * sizeof(float)); |
| 110 | slopeBuffer->unmap(); |
| 111 | vulkanBn->copyBufferToImage(slopeBuffer.get(), mSlope.get(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | VulkanPrelu::~VulkanPrelu() { |
| 116 | } |
nothing calls this directly
no test coverage detected