From b9d210185b73d96515b465e5bffcf491755ed1e8 Mon Sep 17 00:00:00 2001 From: Alejandro Saucedo Date: Sat, 29 Aug 2020 16:03:01 +0100 Subject: [PATCH] Added once again extended parameters to manager and sequence templates and reformatted --- single_include/kompute/Kompute.hpp | 141 +++++++++++++++++++---------- src/Manager.cpp | 15 ++- src/Sequence.cpp | 8 +- src/Tensor.cpp | 14 +-- src/include/kompute/Algorithm.hpp | 23 +++-- src/include/kompute/Manager.hpp | 32 ++++--- src/include/kompute/Sequence.hpp | 44 ++++++--- src/include/kompute/Tensor.hpp | 43 ++++++--- 8 files changed, 210 insertions(+), 110 deletions(-) diff --git a/single_include/kompute/Kompute.hpp b/single_include/kompute/Kompute.hpp index f85285e2d..0f14a5aea 100755 --- a/single_include/kompute/Kompute.hpp +++ b/single_include/kompute/Kompute.hpp @@ -168,7 +168,10 @@ class Tensor { public: /** - * Type for tensors created: Device allows memory to be transferred from staging buffers. Staging are host memory visible. Storage are device visible but are not set up to transfer or receive data (only for shader storage). + * Type for tensors created: Device allows memory to be transferred from + * staging buffers. Staging are host memory visible. Storage are device + * visible but are not set up to transfer or receive data (only for shader + * storage). */ enum class TensorTypes { @@ -183,7 +186,8 @@ class Tensor Tensor(); /** - * Default constructor with data provided which would be used to create the respective vulkan buffer and memory. + * Default constructor with data provided which would be used to create the + * respective vulkan buffer and memory. * * @param data Vector of data that will be used by the tensor * @param tensorType Type for the tensor which is of type TensorTypes @@ -192,7 +196,8 @@ class Tensor TensorTypes tensorType = TensorTypes::eDevice); /** - * Destructor which is in charge of freeing vulkan resources unless they have been provided externally. + * Destructor which is in charge of freeing vulkan resources unless they + * have been provided externally. */ ~Tensor(); @@ -209,21 +214,26 @@ class Tensor void freeMemoryDestroyGPUResources(); /** - * Returns the vector of data currently contained by the Tensor. It is important to ensure that there is no out-of-sync data with the GPU memory. + * Returns the vector of data currently contained by the Tensor. It is + * important to ensure that there is no out-of-sync data with the GPU + * memory. * * @return Vector of elements representing the data in the tensor. */ std::vector data(); /** - * Returns the size/magnitude of the Tensor, which will be the total number of elements across all dimensions + * Returns the size/magnitude of the Tensor, which will be the total number + * of elements across all dimensions * * @return Unsigned integer representing the total number of elements */ uint32_t size(); /** - * Returns the shape of the tensor, which includes the number of dimensions and the size per dimension. + * Returns the shape of the tensor, which includes the number of dimensions + * and the size per dimension. * - * @return Array containing the sizes for each dimension. Zero means respective dimension is not active. + * @return Array containing the sizes for each dimension. Zero means + * respective dimension is not active. */ std::array shape(); /** @@ -233,12 +243,15 @@ class Tensor */ TensorTypes tensorType(); /** - * Returns true if the tensor initialisation function has been carried out successful, which would mean that the buffer and memory will have been provisioned. + * Returns true if the tensor initialisation function has been carried out + * successful, which would mean that the buffer and memory will have been + * provisioned. */ bool isInit(); /** - * Sets / resets the vector data of the tensor. This function does not perform any copies into GPU memory and is only performed on the host. + * Sets / resets the vector data of the tensor. This function does not + * perform any copies into GPU memory and is only performed on the host. */ void setData(const std::vector& data); @@ -248,10 +261,11 @@ class Tensor * a staging buffer transfer, or to gather output (between others). * * @param copyFromTensor Tensor to copy the data from - * @param createBarrier Whether to create a barrier that ensures the data is copied before further operations. Default is true. + * @param createBarrier Whether to create a barrier that ensures the data is + * copied before further operations. Default is true. */ void recordCopyFrom(std::shared_ptr copyFromTensor, - bool createBarrier = true); + bool createBarrier = true); /** * Records the buffer memory barrier into the command buffer which @@ -276,11 +290,13 @@ class Tensor */ vk::DescriptorBufferInfo constructDescriptorBufferInfo(); /** - * Maps data from the Host Visible GPU memory into the data vector. It requires the Tensor to be of staging type for it to work. + * Maps data from the Host Visible GPU memory into the data vector. It + * requires the Tensor to be of staging type for it to work. */ void mapDataFromHostMemory(); /** - * Maps data from the data vector into the Host Visible GPU memory. It requires the tensor to be of staging type for it to work. + * Maps data from the data vector into the Host Visible GPU memory. It + * requires the tensor to be of staging type for it to work. */ void mapDataIntoHostMemory(); @@ -432,11 +448,13 @@ class Sequence { public: /** - * Base constructor for Sequence. Should not be used unless explicit intended. - */ + * Base constructor for Sequence. Should not be used unless explicit + * intended. + */ Sequence(); /** - * Main constructor for sequence which requires core vulkan components to generate all dependent resources. + * Main constructor for sequence which requires core vulkan components to + * generate all dependent resources. * * @param physicalDevice Vulkan physical device * @param device Vulkan logical device @@ -448,25 +466,30 @@ class Sequence std::shared_ptr computeQueue, uint32_t queueIndex); /** - * Destructor for sequence which is responsible for cleaning all subsequent owned operations. + * Destructor for sequence which is responsible for cleaning all subsequent + * owned operations. */ ~Sequence(); /** - * Initialises sequence including the creation of the command pool and the command buffer. + * Initialises sequence including the creation of the command pool and the + * command buffer. */ void init(); /** - * Begins recording commands for commands to be submitted into the command buffer. + * Begins recording commands for commands to be submitted into the command + * buffer. */ bool begin(); /** - * Ends the recording and stops recording commands when the record command is sent. + * Ends the recording and stops recording commands when the record command + * is sent. */ bool end(); /** - * Eval sends all the recorded and stored operations in the vector of operations into the gpu as a submit job with a barrier. + * Eval sends all the recorded and stored operations in the vector of + * operations into the gpu as a submit job with a barrier. */ bool eval(); @@ -485,26 +508,35 @@ class Sequence bool isInit(); /** - * Record function for operation to be added to the GPU queue in batch. This template requires classes to be derived from the OpBase class. This function also requires the Sequence to be recording, otherwise it will not be able to add the operation. + * Record function for operation to be added to the GPU queue in batch. This + * template requires classes to be derived from the OpBase class. This + * function also requires the Sequence to be recording, otherwise it will + * not be able to add the operation. * * @param tensors Vector of tensors to use for the operation */ template - bool record(std::vector> tensors) + bool record(std::vector> tensors, TArgs&&... params) { static_assert(std::is_base_of::value, - "Kompute Sequence record(...) template only valid with OpBase derived classes"); + "Kompute Sequence record(...) template only valid with " + "OpBase derived classes"); SPDLOG_DEBUG("Kompute Sequence record function started"); if (!this->isRecording()) { - spdlog::error("Kompute sequence record attempted when not record BEGIN"); + spdlog::error( + "Kompute sequence record attempted when not record BEGIN"); return false; } SPDLOG_DEBUG("Kompute Sequence creating OpBase derived class instance"); - T* op = - new T(this->mPhysicalDevice, this->mDevice, this->mCommandBuffer, tensors); + T* op = new T(this->mPhysicalDevice, + this->mDevice, + this->mCommandBuffer, + tensors, + std::forward(params)...); + OpBase* baseOp = dynamic_cast(op); std::unique_ptr baseOpPtr{ baseOp }; @@ -561,17 +593,20 @@ class Manager private: public: /** - Base constructor and default used which creates the base resources including choosing the device 0 by default. + Base constructor and default used which creates the base resources + including choosing the device 0 by default. */ Manager(); /** - Similar to base constructor but allows the user to provide the device they would like to create the resources on. + Similar to base constructor but allows the user to provide the device + they would like to create the resources on. */ Manager(uint32_t physicalDeviceIndex); /** - * Manager constructor which allows your own vulkan application to integrate with the vulkan kompute use. + * Manager constructor which allows your own vulkan application to integrate + * with the vulkan kompute use. * * @param instance Vulkan compute instance to base this application * @physicalDevice Vulkan physical device to use for application @@ -584,27 +619,34 @@ class Manager uint32_t physicalDeviceIndex); /** - * Manager destructor which would ensure all owned resources are destroyed unless explicitly stated that resources should not be destroyed or freed. + * Manager destructor which would ensure all owned resources are destroyed + * unless explicitly stated that resources should not be destroyed or freed. */ ~Manager(); /** - * Get or create a managed Sequence that will be contained by this manager. If the named sequence does not currently exist, it would be created and initialised. - * - * @param sequenceName The name for the named sequence to be retrieved or created + * Get or create a managed Sequence that will be contained by this manager. + * If the named sequence does not currently exist, it would be created and + * initialised. + * + * @param sequenceName The name for the named sequence to be retrieved or + * created * @return Weak pointer to the manager owned sequence resource */ - std::weak_ptr getOrCreateManagedSequence(std::string sequenceName); + std::weak_ptr getOrCreateManagedSequence( + std::string sequenceName); /** - * Operation that adds extra operations to existing or new created sequences. + * Operation that adds extra operations to existing or new created + * sequences. * * @param tensors The tensors to be used in the operation recorded * @param sequenceName The name of the sequence to be retrieved or created */ template void evalOp(std::vector> tensors, - std::string sequenceName = KP_DEFAULT_SESSION) + std::string sequenceName = KP_DEFAULT_SESSION, + TArgs&&... params) { SPDLOG_DEBUG("Kompute Manager evalOp triggered"); std::weak_ptr sqWeakPtr = @@ -615,7 +657,7 @@ class Manager sq->begin(); SPDLOG_DEBUG("Kompute Manager evalOp running sequence RECORD"); - sq->record(tensors); + sq->record(tensors, std::forward(params)...); SPDLOG_DEBUG("Kompute Manager evalOp running sequence END"); sq->end(); @@ -658,13 +700,15 @@ class Manager namespace kp { /** - Abstraction for compute shaders that are run on top of tensors grouped via ParameterGroups (which group descriptorsets) + Abstraction for compute shaders that are run on top of tensors grouped via + ParameterGroups (which group descriptorsets) */ class Algorithm { public: /** - Base constructor for Algorithm. Should not be used unless explicit intended. + Base constructor for Algorithm. Should not be used unless explicit + intended. */ Algorithm(); @@ -672,27 +716,32 @@ class Algorithm * Default constructor for Algorithm * * @param device The Vulkan device to use for creating resources - * @param commandBuffer The vulkan command buffer to bind the pipeline and shaders - */ + * @param commandBuffer The vulkan command buffer to bind the pipeline and + * shaders + */ Algorithm(std::shared_ptr device, std::shared_ptr commandBuffer); /** - * Initialiser for the shader data provided to the algoithm as well as tensor parameters that will be used in shader. + * Initialiser for the shader data provided to the algoithm as well as + * tensor parameters that will be used in shader. * * @param shaderFileData The bytes in spir-v format of the shader - * @tensorParams The Tensors to be used in the Algorithm / shader for processing + * @tensorParams The Tensors to be used in the Algorithm / shader for + * processing */ void init(const std::vector& shaderFileData, std::vector> tensorParams); /** - * Destructor for Algorithm which is responsible for freeing and desroying respective pipelines and owned parameter groups. + * Destructor for Algorithm which is responsible for freeing and desroying + * respective pipelines and owned parameter groups. */ ~Algorithm(); /** - * Records the dispatch function with the provided template parameters or alternatively using the size of the tensor by default. + * Records the dispatch function with the provided template parameters or + * alternatively using the size of the tensor by default. * * @param x Layout X dispatch value * @param y Layout Y dispatch value diff --git a/src/Manager.cpp b/src/Manager.cpp index ffa15ee12..07a8cc1af 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -22,12 +22,11 @@ debugMessageCallback(VkDebugReportFlagsEXT flags, } #endif -Manager::Manager() : Manager(0) -{ +Manager::Manager() + : Manager(0) +{} -} - -Manager::Manager(uint32_t physicalDeviceIndex) +Manager::Manager(uint32_t physicalDeviceIndex) { this->mPhysicalDeviceIndex = physicalDeviceIndex; // TODO: Moving this into a separate init @@ -36,9 +35,9 @@ Manager::Manager(uint32_t physicalDeviceIndex) } Manager::Manager(std::shared_ptr instance, - std::shared_ptr physicalDevice, - std::shared_ptr device, - uint32_t physicalDeviceIndex) + std::shared_ptr physicalDevice, + std::shared_ptr device, + uint32_t physicalDeviceIndex) { this->mInstance = instance; this->mPhysicalDevice = physicalDevice; diff --git a/src/Sequence.cpp b/src/Sequence.cpp index 35a14cf47..29fc19287 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -150,11 +150,15 @@ Sequence::eval() return true; } -bool Sequence::isRecording() { +bool +Sequence::isRecording() +{ return this->mRecording; } -bool Sequence::isInit() { +bool +Sequence::isInit() +{ return this->mIsInit; } diff --git a/src/Tensor.cpp b/src/Tensor.cpp index e1b85a42e..882f11630 100644 --- a/src/Tensor.cpp +++ b/src/Tensor.cpp @@ -95,7 +95,8 @@ Tensor::setData(const std::vector& data) } void -Tensor::recordCopyFrom(std::shared_ptr copyFromTensor, bool createBarrier) +Tensor::recordCopyFrom(std::shared_ptr copyFromTensor, + bool createBarrier) { SPDLOG_DEBUG("Kompute Tensor recordCopyFrom called"); @@ -117,12 +118,11 @@ Tensor::recordCopyFrom(std::shared_ptr copyFromTensor, bool createBarrie if (createBarrier) { // Buffer to ensure wait until data is copied to staging buffer - this->recordBufferMemoryBarrier( - vk::AccessFlagBits::eTransferWrite, - vk::AccessFlagBits::eHostRead, - vk::PipelineStageFlagBits::eTransfer, - vk::PipelineStageFlagBits::eHost); - } + this->recordBufferMemoryBarrier(vk::AccessFlagBits::eTransferWrite, + vk::AccessFlagBits::eHostRead, + vk::PipelineStageFlagBits::eTransfer, + vk::PipelineStageFlagBits::eHost); + } } void diff --git a/src/include/kompute/Algorithm.hpp b/src/include/kompute/Algorithm.hpp index bef9cbaef..c45711689 100644 --- a/src/include/kompute/Algorithm.hpp +++ b/src/include/kompute/Algorithm.hpp @@ -7,13 +7,15 @@ namespace kp { /** - Abstraction for compute shaders that are run on top of tensors grouped via ParameterGroups (which group descriptorsets) + Abstraction for compute shaders that are run on top of tensors grouped via + ParameterGroups (which group descriptorsets) */ class Algorithm { public: /** - Base constructor for Algorithm. Should not be used unless explicit intended. + Base constructor for Algorithm. Should not be used unless explicit + intended. */ Algorithm(); @@ -21,27 +23,32 @@ class Algorithm * Default constructor for Algorithm * * @param device The Vulkan device to use for creating resources - * @param commandBuffer The vulkan command buffer to bind the pipeline and shaders - */ + * @param commandBuffer The vulkan command buffer to bind the pipeline and + * shaders + */ Algorithm(std::shared_ptr device, std::shared_ptr commandBuffer); /** - * Initialiser for the shader data provided to the algoithm as well as tensor parameters that will be used in shader. + * Initialiser for the shader data provided to the algoithm as well as + * tensor parameters that will be used in shader. * * @param shaderFileData The bytes in spir-v format of the shader - * @tensorParams The Tensors to be used in the Algorithm / shader for processing + * @tensorParams The Tensors to be used in the Algorithm / shader for + * processing */ void init(const std::vector& shaderFileData, std::vector> tensorParams); /** - * Destructor for Algorithm which is responsible for freeing and desroying respective pipelines and owned parameter groups. + * Destructor for Algorithm which is responsible for freeing and desroying + * respective pipelines and owned parameter groups. */ ~Algorithm(); /** - * Records the dispatch function with the provided template parameters or alternatively using the size of the tensor by default. + * Records the dispatch function with the provided template parameters or + * alternatively using the size of the tensor by default. * * @param x Layout X dispatch value * @param y Layout Y dispatch value diff --git a/src/include/kompute/Manager.hpp b/src/include/kompute/Manager.hpp index f71328199..7414aa6eb 100644 --- a/src/include/kompute/Manager.hpp +++ b/src/include/kompute/Manager.hpp @@ -18,17 +18,20 @@ class Manager private: public: /** - Base constructor and default used which creates the base resources including choosing the device 0 by default. + Base constructor and default used which creates the base resources + including choosing the device 0 by default. */ Manager(); /** - Similar to base constructor but allows the user to provide the device they would like to create the resources on. + Similar to base constructor but allows the user to provide the device + they would like to create the resources on. */ Manager(uint32_t physicalDeviceIndex); /** - * Manager constructor which allows your own vulkan application to integrate with the vulkan kompute use. + * Manager constructor which allows your own vulkan application to integrate + * with the vulkan kompute use. * * @param instance Vulkan compute instance to base this application * @physicalDevice Vulkan physical device to use for application @@ -41,27 +44,34 @@ class Manager uint32_t physicalDeviceIndex); /** - * Manager destructor which would ensure all owned resources are destroyed unless explicitly stated that resources should not be destroyed or freed. + * Manager destructor which would ensure all owned resources are destroyed + * unless explicitly stated that resources should not be destroyed or freed. */ ~Manager(); /** - * Get or create a managed Sequence that will be contained by this manager. If the named sequence does not currently exist, it would be created and initialised. - * - * @param sequenceName The name for the named sequence to be retrieved or created + * Get or create a managed Sequence that will be contained by this manager. + * If the named sequence does not currently exist, it would be created and + * initialised. + * + * @param sequenceName The name for the named sequence to be retrieved or + * created * @return Weak pointer to the manager owned sequence resource */ - std::weak_ptr getOrCreateManagedSequence(std::string sequenceName); + std::weak_ptr getOrCreateManagedSequence( + std::string sequenceName); /** - * Operation that adds extra operations to existing or new created sequences. + * Operation that adds extra operations to existing or new created + * sequences. * * @param tensors The tensors to be used in the operation recorded * @param sequenceName The name of the sequence to be retrieved or created */ template void evalOp(std::vector> tensors, - std::string sequenceName = KP_DEFAULT_SESSION) + std::string sequenceName = KP_DEFAULT_SESSION, + TArgs&&... params) { SPDLOG_DEBUG("Kompute Manager evalOp triggered"); std::weak_ptr sqWeakPtr = @@ -72,7 +82,7 @@ class Manager sq->begin(); SPDLOG_DEBUG("Kompute Manager evalOp running sequence RECORD"); - sq->record(tensors); + sq->record(tensors, std::forward(params)...); SPDLOG_DEBUG("Kompute Manager evalOp running sequence END"); sq->end(); diff --git a/src/include/kompute/Sequence.hpp b/src/include/kompute/Sequence.hpp index 7be635577..af05eaff6 100644 --- a/src/include/kompute/Sequence.hpp +++ b/src/include/kompute/Sequence.hpp @@ -13,11 +13,13 @@ class Sequence { public: /** - * Base constructor for Sequence. Should not be used unless explicit intended. - */ + * Base constructor for Sequence. Should not be used unless explicit + * intended. + */ Sequence(); /** - * Main constructor for sequence which requires core vulkan components to generate all dependent resources. + * Main constructor for sequence which requires core vulkan components to + * generate all dependent resources. * * @param physicalDevice Vulkan physical device * @param device Vulkan logical device @@ -29,25 +31,30 @@ class Sequence std::shared_ptr computeQueue, uint32_t queueIndex); /** - * Destructor for sequence which is responsible for cleaning all subsequent owned operations. + * Destructor for sequence which is responsible for cleaning all subsequent + * owned operations. */ ~Sequence(); /** - * Initialises sequence including the creation of the command pool and the command buffer. + * Initialises sequence including the creation of the command pool and the + * command buffer. */ void init(); /** - * Begins recording commands for commands to be submitted into the command buffer. + * Begins recording commands for commands to be submitted into the command + * buffer. */ bool begin(); /** - * Ends the recording and stops recording commands when the record command is sent. + * Ends the recording and stops recording commands when the record command + * is sent. */ bool end(); /** - * Eval sends all the recorded and stored operations in the vector of operations into the gpu as a submit job with a barrier. + * Eval sends all the recorded and stored operations in the vector of + * operations into the gpu as a submit job with a barrier. */ bool eval(); @@ -66,26 +73,35 @@ class Sequence bool isInit(); /** - * Record function for operation to be added to the GPU queue in batch. This template requires classes to be derived from the OpBase class. This function also requires the Sequence to be recording, otherwise it will not be able to add the operation. + * Record function for operation to be added to the GPU queue in batch. This + * template requires classes to be derived from the OpBase class. This + * function also requires the Sequence to be recording, otherwise it will + * not be able to add the operation. * * @param tensors Vector of tensors to use for the operation */ template - bool record(std::vector> tensors) + bool record(std::vector> tensors, TArgs&&... params) { static_assert(std::is_base_of::value, - "Kompute Sequence record(...) template only valid with OpBase derived classes"); + "Kompute Sequence record(...) template only valid with " + "OpBase derived classes"); SPDLOG_DEBUG("Kompute Sequence record function started"); if (!this->isRecording()) { - spdlog::error("Kompute sequence record attempted when not record BEGIN"); + spdlog::error( + "Kompute sequence record attempted when not record BEGIN"); return false; } SPDLOG_DEBUG("Kompute Sequence creating OpBase derived class instance"); - T* op = - new T(this->mPhysicalDevice, this->mDevice, this->mCommandBuffer, tensors); + T* op = new T(this->mPhysicalDevice, + this->mDevice, + this->mCommandBuffer, + tensors, + std::forward(params)...); + OpBase* baseOp = dynamic_cast(op); std::unique_ptr baseOpPtr{ baseOp }; diff --git a/src/include/kompute/Tensor.hpp b/src/include/kompute/Tensor.hpp index 0ff811300..ba73f67c5 100644 --- a/src/include/kompute/Tensor.hpp +++ b/src/include/kompute/Tensor.hpp @@ -18,7 +18,10 @@ class Tensor { public: /** - * Type for tensors created: Device allows memory to be transferred from staging buffers. Staging are host memory visible. Storage are device visible but are not set up to transfer or receive data (only for shader storage). + * Type for tensors created: Device allows memory to be transferred from + * staging buffers. Staging are host memory visible. Storage are device + * visible but are not set up to transfer or receive data (only for shader + * storage). */ enum class TensorTypes { @@ -33,7 +36,8 @@ class Tensor Tensor(); /** - * Default constructor with data provided which would be used to create the respective vulkan buffer and memory. + * Default constructor with data provided which would be used to create the + * respective vulkan buffer and memory. * * @param data Vector of data that will be used by the tensor * @param tensorType Type for the tensor which is of type TensorTypes @@ -42,7 +46,8 @@ class Tensor TensorTypes tensorType = TensorTypes::eDevice); /** - * Destructor which is in charge of freeing vulkan resources unless they have been provided externally. + * Destructor which is in charge of freeing vulkan resources unless they + * have been provided externally. */ ~Tensor(); @@ -59,21 +64,26 @@ class Tensor void freeMemoryDestroyGPUResources(); /** - * Returns the vector of data currently contained by the Tensor. It is important to ensure that there is no out-of-sync data with the GPU memory. + * Returns the vector of data currently contained by the Tensor. It is + * important to ensure that there is no out-of-sync data with the GPU + * memory. * * @return Vector of elements representing the data in the tensor. */ std::vector data(); /** - * Returns the size/magnitude of the Tensor, which will be the total number of elements across all dimensions + * Returns the size/magnitude of the Tensor, which will be the total number + * of elements across all dimensions * * @return Unsigned integer representing the total number of elements */ uint32_t size(); /** - * Returns the shape of the tensor, which includes the number of dimensions and the size per dimension. + * Returns the shape of the tensor, which includes the number of dimensions + * and the size per dimension. * - * @return Array containing the sizes for each dimension. Zero means respective dimension is not active. + * @return Array containing the sizes for each dimension. Zero means + * respective dimension is not active. */ std::array shape(); /** @@ -83,12 +93,15 @@ class Tensor */ TensorTypes tensorType(); /** - * Returns true if the tensor initialisation function has been carried out successful, which would mean that the buffer and memory will have been provisioned. + * Returns true if the tensor initialisation function has been carried out + * successful, which would mean that the buffer and memory will have been + * provisioned. */ bool isInit(); /** - * Sets / resets the vector data of the tensor. This function does not perform any copies into GPU memory and is only performed on the host. + * Sets / resets the vector data of the tensor. This function does not + * perform any copies into GPU memory and is only performed on the host. */ void setData(const std::vector& data); @@ -98,10 +111,11 @@ class Tensor * a staging buffer transfer, or to gather output (between others). * * @param copyFromTensor Tensor to copy the data from - * @param createBarrier Whether to create a barrier that ensures the data is copied before further operations. Default is true. + * @param createBarrier Whether to create a barrier that ensures the data is + * copied before further operations. Default is true. */ void recordCopyFrom(std::shared_ptr copyFromTensor, - bool createBarrier = true); + bool createBarrier = true); /** * Records the buffer memory barrier into the command buffer which @@ -117,7 +131,6 @@ class Tensor vk::PipelineStageFlagBits srcStageMask, vk::PipelineStageFlagBits dstStageMask); - /** * Constructs a vulkan descriptor buffer info which can be used to specify * and reference the underlying buffer component of the tensor without @@ -127,11 +140,13 @@ class Tensor */ vk::DescriptorBufferInfo constructDescriptorBufferInfo(); /** - * Maps data from the Host Visible GPU memory into the data vector. It requires the Tensor to be of staging type for it to work. + * Maps data from the Host Visible GPU memory into the data vector. It + * requires the Tensor to be of staging type for it to work. */ void mapDataFromHostMemory(); /** - * Maps data from the data vector into the Host Visible GPU memory. It requires the tensor to be of staging type for it to work. + * Maps data from the data vector into the Host Visible GPU memory. It + * requires the tensor to be of staging type for it to work. */ void mapDataIntoHostMemory();