// This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. // // Copyright (C) 2018, Intel Corporation, all rights reserved. // Third party copyrights are property of their respective owners. #ifndef OPENCV_DNN_OP_VKCOM_HPP #define OPENCV_DNN_OP_VKCOM_HPP #include #ifdef HAVE_VULKAN #include "vkcom/include/vkcom.hpp" #endif // HAVE_VULKAN namespace cv { namespace dnn { #ifdef HAVE_VULKAN std::vector VkComTensors(const std::vector >& ptrs); vkcom::Tensor VkComTensor(const Ptr& ptr); // Data copied from/to Mat to/from Tensor. Change the shape of dst if // needed to make it the same shape as src void copyToTensor(vkcom::Tensor &dst, const Mat &src); void copyToMat(Mat &dst, const vkcom::Tensor &src); class VkComBackendNode : public BackendNode { public: VkComBackendNode(const std::vector >& inputsWrapper, const std::shared_ptr &op, const std::vector >& blobsWrapper = std::vector >()); bool forward(std::vector& outs); private: std::vector ins; std::vector blobs; std::vector > inputsWrapper_; std::shared_ptr operation; }; class VkComBackendWrapper : public BackendWrapper { public: VkComBackendWrapper(Mat& m); VkComBackendWrapper(const Ptr& baseBuffer, Mat& m); virtual void copyToHost() CV_OVERRIDE; virtual void setHostDirty() CV_OVERRIDE; void setDeviceDirty(); void copyToDevice(); vkcom::Tensor getTensor(); private: vkcom::Tensor tensor; Mat* host; bool hostDirty; bool deviceDirty; }; #endif // HAVE_VULKAN void forwardVkCom(std::vector > &outputs, const Ptr& node); bool haveVulkan(); } // namespace dnn } // namespace cv #endif // OPENCV_DNN_OP_VKCOM_HPP