Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/dnn/src/vkcom/include/op_base.hpp
16344 views
1
// This file is part of OpenCV project.
2
// It is subject to the license terms in the LICENSE file found in the top-level directory
3
// of this distribution and at http://opencv.org/license.html.
4
//
5
// Copyright (C) 2018, Intel Corporation, all rights reserved.
6
// Third party copyrights are property of their respective owners.
7
8
#ifndef OPENCV_DNN_VKCOM_OP_BASE_HPP
9
#define OPENCV_DNN_VKCOM_OP_BASE_HPP
10
11
#include "../../precomp.hpp"
12
#include "vkcom.hpp"
13
14
namespace cv { namespace dnn { namespace vkcom {
15
16
#ifdef HAVE_VULKAN
17
18
// Forward declare
19
class Context;
20
21
class OpBase
22
{
23
public:
24
OpBase();
25
virtual ~OpBase();
26
virtual bool forward(std::vector<Tensor>& ins,
27
std::vector<Tensor>& blobs,
28
std::vector<Tensor>& outs) = 0;
29
protected:
30
void initVulkanThing(int buffer_num);
31
void createDescriptorSetLayout(int buffer_num);
32
void createDescriptorSet(int buffer_num);
33
void createShaderModule(const uint32_t* spv, size_t sz, const std::string& source = std::string());
34
void createPipeline(size_t push_constants_size = 0);
35
void createCommandBuffer();
36
void recordCommandBuffer(void* push_constants = NULL, size_t push_constants_size = 0);
37
void runCommandBuffer();
38
39
const Context* ctx_;
40
VkPipeline pipeline_;
41
VkCommandBuffer cmd_buffer_;
42
VkDescriptorPool descriptor_pool_;
43
VkDescriptorSet descriptor_set_;
44
VkDevice device_;
45
VkDescriptorSetLayout descriptor_set_layout_;
46
VkPipelineLayout pipeline_layout_;
47
VkShaderModule module_;
48
int group_x_;
49
int group_y_;
50
int group_z_;
51
std::string type_;
52
};
53
54
#endif // HAVE_VULKAN
55
56
}}} // namespace cv::dnn::vkcom
57
58
#endif // OPENCV_DNN_VKCOM_OP_BASE_HPP
59
60