diff --git a/single_include/kompute/Kompute.hpp b/single_include/kompute/Kompute.hpp index a68cff1e6..97385e4fc 100755 --- a/single_include/kompute/Kompute.hpp +++ b/single_include/kompute/Kompute.hpp @@ -2181,6 +2181,16 @@ class Manager return tensor; } + std::shared_ptr algorithm( + const std::vector>& tensors = {}, + const std::vector& spirv = {}, + const Workgroup& workgroup = {}, + const std::vector& specializationConstants = {}, + const std::vector& pushConstants = {}) + { + return this->algorithm<>(tensors, spirv, workgroup, specializationConstants, pushConstants); + } + /** * Create a managed algorithm that will be destroyed by this manager * if it hasn't been destroyed by its reference count going to zero. @@ -2195,12 +2205,31 @@ class Manager * and defaults to an empty constant * @returns Shared pointer with initialised algorithm */ + template std::shared_ptr algorithm( - const std::vector>& tensors = {}, - const std::vector& spirv = {}, - const Workgroup& workgroup = {}, - const Constants& specializationConstants = {}, - const Constants& pushConstants = {}); + const std::vector>& tensors, + const std::vector& spirv, + const Workgroup& workgroup, + const std::vector& specializationConstants, + const std::vector

& pushConstants) + { + + KP_LOG_DEBUG("Kompute Manager algorithm creation triggered"); + + std::shared_ptr algorithm{ new kp::Algorithm( + this->mDevice, + tensors, + spirv, + workgroup, + specializationConstants, + pushConstants) }; + + if (this->mManageResources) { + this->mManagedAlgorithms.push_back(algorithm); + } + + return algorithm; + } /** * Destroy the GPU resources and all managed resources by manager. diff --git a/src/Manager.cpp b/src/Manager.cpp index 8e8367c30..a553d667f 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -422,32 +422,6 @@ Manager::createDevice(const std::vector& familyQueueIndices, KP_LOG_DEBUG("Kompute Manager compute queue obtained"); } -// TODO: Update to template -std::shared_ptr -Manager::algorithm(const std::vector>& tensors, - const std::vector& spirv, - const Workgroup& workgroup, - const Constants& specializationConstants, - const Constants& pushConstants) -{ - - KP_LOG_DEBUG("Kompute Manager algorithm creation triggered"); - - std::shared_ptr algorithm{ new kp::Algorithm( - this->mDevice, - tensors, - spirv, - workgroup, - specializationConstants, - pushConstants) }; - - if (this->mManageResources) { - this->mManagedAlgorithms.push_back(algorithm); - } - - return algorithm; -} - std::shared_ptr Manager::sequence(uint32_t queueIndex, uint32_t totalTimestamps) { diff --git a/src/include/kompute/Manager.hpp b/src/include/kompute/Manager.hpp index 62f98d6d5..8a4244a2b 100644 --- a/src/include/kompute/Manager.hpp +++ b/src/include/kompute/Manager.hpp @@ -123,6 +123,16 @@ class Manager return tensor; } + std::shared_ptr algorithm( + const std::vector>& tensors = {}, + const std::vector& spirv = {}, + const Workgroup& workgroup = {}, + const std::vector& specializationConstants = {}, + const std::vector& pushConstants = {}) + { + return this->algorithm<>(tensors, spirv, workgroup, specializationConstants, pushConstants); + } + /** * Create a managed algorithm that will be destroyed by this manager * if it hasn't been destroyed by its reference count going to zero. @@ -137,12 +147,31 @@ class Manager * and defaults to an empty constant * @returns Shared pointer with initialised algorithm */ + template std::shared_ptr algorithm( - const std::vector>& tensors = {}, - const std::vector& spirv = {}, - const Workgroup& workgroup = {}, - const Constants& specializationConstants = {}, - const Constants& pushConstants = {}); + const std::vector>& tensors, + const std::vector& spirv, + const Workgroup& workgroup, + const std::vector& specializationConstants, + const std::vector

& pushConstants) + { + + KP_LOG_DEBUG("Kompute Manager algorithm creation triggered"); + + std::shared_ptr algorithm{ new kp::Algorithm( + this->mDevice, + tensors, + spirv, + workgroup, + specializationConstants, + pushConstants) }; + + if (this->mManageResources) { + this->mManagedAlgorithms.push_back(algorithm); + } + + return algorithm; + } /** * Destroy the GPU resources and all managed resources by manager.