Path: blob/master/modules/dnn/src/vkcom/include/tensor.hpp
16344 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html.3//4// Copyright (C) 2018, Intel Corporation, all rights reserved.5// Third party copyrights are property of their respective owners.67#ifndef OPENCV_DNN_VKCOM_TENSOR_HPP8#define OPENCV_DNN_VKCOM_TENSOR_HPP910#ifdef HAVE_VULKAN11#include <vulkan/vulkan.h>12#endif13#include <memory>14#include "vkcom.hpp"1516namespace cv { namespace dnn { namespace vkcom {1718#ifdef HAVE_VULKAN1920class Buffer;2122class Tensor23{24public:25Tensor(Format fmt = kFormatFp32);26Tensor(const char* data, std::vector<int>& shape, Format fmt = kFormatFp32);27void* map();28void unMap();29Shape getShape() const;30int dimSize(const int dim) const;31int dimNum() const;32int count(const int start_axis = 0, const int end_axis = -1) const;3334// Change shape and format to as passed in.35// Copy data if data != NULL36// Allocate new internal buffer if new size > old size or alloc flag is true37Tensor reshape(const char* data, const std::vector<int>& shape, bool alloc = false, Format fmt = kFormatInvalid);3839void setTo(float val);40int getFormat() const;41size_t size() const { return size_in_byte_; }42bool isEmpty() { return size_in_byte_ == 0 ? true : false; }43void copyTo(Tensor& dst);44std::shared_ptr<Buffer> getBuffer() { return buffer_; }4546private:47VkDevice device_;48std::vector<int> shape_;49size_t size_in_byte_;50std::shared_ptr<Buffer> buffer_;51Format format_;52};5354#endif // HAVE_VULKAN5556}}} // namespace cv::dnn::vkcom5758#endif // OPENCV_DNN_VKCOM_TENSOR_HPP596061