Updated docs and renamig kp::Constants

Signed-off-by: Alejandro Saucedo <axsauze@gmail.com>
This commit is contained in:
Alejandro Saucedo 2021-09-12 16:51:43 +01:00
parent 990ccd5f3b
commit 932620091c
14 changed files with 162 additions and 47 deletions

View file

@ -1087,12 +1087,12 @@ class Algorithm
* @param spirv (optional) The spirv code to use to create the algorithm
* @param workgroup (optional) The kp::Workgroup to use for the dispatch
* which defaults to kp::Workgroup(tensor[0].size(), 1, 1) if not set.
* @param specializationConstants (optional) The kp::Constants to use to
* @param specializationConstants (optional) The templatable param is to be used to
* initialize the specialization constants which cannot be changed once set.
* @param pushConstants (optional) The kp::Constants to use when
* @param pushConstants (optional) This templatable param is to be used when
* initializing the pipeline, which set the size of the push constants -
* these can be modified but all new values must have the same vector size
* as this initial value.
* these can be modified but all new values must have the same data type and length
* as otherwise it will result in errors.
*/
template<typename S = float, typename P = float>
Algorithm(std::shared_ptr<vk::Device> device,
@ -1127,9 +1127,9 @@ class Algorithm
* @param spirv The spirv code to use to create the algorithm
* @param workgroup (optional) The kp::Workgroup to use for the dispatch
* which defaults to kp::Workgroup(tensor[0].size(), 1, 1) if not set.
* @param specializationConstants (optional) The kp::Constants to use to
* @param specializationConstants (optional) The std::vector<float> to use to
* initialize the specialization constants which cannot be changed once set.
* @param pushConstants (optional) The kp::Constants to use when
* @param pushConstants (optional) The std::vector<float> to use when
* initializing the pipeline, which set the size of the push constants -
* these can be modified but all new values must have the same vector size
* as this initial value.
@ -1239,7 +1239,7 @@ class Algorithm
* Sets the push constants to the new value provided to use in the next
* bindPush()
*
* @param The kp::Constant to use to set the push constants to use in the
* @param pushConstants The templatable vector is to be used to set the push constants to use in the
* next bindPush(...) calls. The constants provided must be of the same size
* as the ones created during initialization.
*/
@ -1252,6 +1252,14 @@ class Algorithm
this->setPushConstants(pushConstants.data(), size, memorySize);
}
/**
* Sets the push constants to the new value provided to use in the next
* bindPush() with the raw memory block location and memory size to be used.
*
* @param data The raw data point to copy the data from, without modifying the pointer.
* @param size The number of data elements provided in the data
* @param memorySize The memory size of each of the data elements in bytes.
*/
void setPushConstants(void* data, uint32_t size, uint32_t memorySize) {
uint32_t totalSize = memorySize * size;
@ -1285,7 +1293,7 @@ class Algorithm
/**
* Gets the specialization constants of the current algorithm.
*
* @returns The kp::Constants currently set for specialization constants
* @returns The std::vector<float> currently set for specialization constants
*/
template<typename T>
const std::vector<T> getSpecializationConstants()
@ -1296,7 +1304,7 @@ class Algorithm
/**
* Gets the specialization constants of the current algorithm.
*
* @returns The kp::Constants currently set for push constants
* @returns The std::vector<float> currently set for push constants
*/
template<typename T>
const std::vector<T> getPushConstants()
@ -2206,6 +2214,20 @@ class Manager
return tensor;
}
/**
* Default non-template function that can be used to create algorithm objects
* which provides default types to the push and spec constants as floats.
*
* @param tensors (optional) The tensors to initialise the algorithm with
* @param spirv (optional) The SPIRV bytes for the algorithm to dispatch
* @param workgroup (optional) kp::Workgroup for algorithm to use, and
* defaults to (tensor[0].size(), 1, 1)
* @param specializationConstants (optional) float vector to use for
* specialization constants, and defaults to an empty constant
* @param pushConstants (optional) float vector to use for push constants,
* and defaults to an empty constant
* @returns Shared pointer with initialised algorithm
*/
std::shared_ptr<Algorithm> algorithm(
const std::vector<std::shared_ptr<Tensor>>& tensors = {},
const std::vector<uint32_t>& spirv = {},
@ -2224,9 +2246,9 @@ class Manager
* @param spirv (optional) The SPIRV bytes for the algorithm to dispatch
* @param workgroup (optional) kp::Workgroup for algorithm to use, and
* defaults to (tensor[0].size(), 1, 1)
* @param specializationConstants (optional) kp::Constant to use for
* @param specializationConstants (optional) templatable vector parameter to use for
* specialization constants, and defaults to an empty constant
* @param pushConstants (optional) kp::Constant to use for push constants,
* @param pushConstants (optional) templatable vector parameter to use for push constants,
* and defaults to an empty constant
* @returns Shared pointer with initialised algorithm
*/