diff --git a/src/runtime/vulkan/vulkan.cc b/src/runtime/vulkan/vulkan.cc index 82c2dc0e19b8b..c8a0858ec1bc2 100644 --- a/src/runtime/vulkan/vulkan.cc +++ b/src/runtime/vulkan/vulkan.cc @@ -786,9 +786,7 @@ class VulkanModuleNode final : public runtime::ModuleNode { public: explicit VulkanModuleNode(std::unordered_map smap, std::unordered_map fmap, std::string source) - : smap_(smap), fmap_(fmap), source_(source), max_push_constants_(GetMaxPushConstantsSize()) { - LOG(INFO) << "VulkanModuleNode, max_push_constants: " << max_push_constants_; - } + : smap_(smap), fmap_(fmap), source_(source), max_push_constants_(GetMaxPushConstantsSize()) {} const char* type_key() const final { return "vulkan"; } @@ -898,7 +896,6 @@ class VulkanModuleNode final : public runtime::ModuleNode { size_t nbytes_scalars = num_pod * sizeof(ArgUnion64); if (nbytes_scalars > max_push_constants_) { - LOG(INFO) << "Using ubo"; push_arg_info(num_buffer, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER); } @@ -1044,7 +1041,7 @@ class VulkanModuleNode final : public runtime::ModuleNode { // The source std::string source_; // The maximum size of push constants in bytes - uint32_t max_push_constants_; + const uint32_t max_push_constants_; // Guards accesses to `ecache_` std::mutex mutex_; diff --git a/src/runtime/vulkan/vulkan_common.h b/src/runtime/vulkan/vulkan_common.h index 9ee28fee41c6e..e94a9fe7fa90f 100644 --- a/src/runtime/vulkan/vulkan_common.h +++ b/src/runtime/vulkan/vulkan_common.h @@ -35,9 +35,6 @@ namespace tvm { namespace runtime { namespace vulkan { -// TODO(masahi): Query this value using runtime API -#define MAX_PUSHCONSTANTS 128 - inline const char* VKGetErrorString(VkResult error) { switch (error) { case VK_SUCCESS: @@ -145,6 +142,7 @@ struct VulkanContext { bool UseImmediate() const { return descriptor_template_khr_functions.get() != nullptr; } }; +/*! \brief returns maximum push constant sizes in bytes for the target platform */ uint32_t GetMaxPushConstantsSize(); } // namespace vulkan diff --git a/src/target/spirv/ir_builder.h b/src/target/spirv/ir_builder.h index c06ec0acf341d..e252dcf94595c 100644 --- a/src/target/spirv/ir_builder.h +++ b/src/target/spirv/ir_builder.h @@ -491,8 +491,21 @@ class IRBuilder { */ Value GetPushConstant(Value ptr_push_const, const SType& v_type, uint32_t index); - // TODO(masahi): doc + /*! + * \brief Declare POD arguments through uniform buffer. + * + * \note Only call this function once! + * \param value_types The values in the uniform buffer + * \param binding The binding locaiton in descriptor set + * \return reference to self. + */ Value DeclareUniformBuffer(const std::vector& value_types, uint32_t binding); + /*! + * \brief Get i-th uniform constant + * \param v_type The value type + * \param index The uniform index + * \return the value of uniform constant + */ Value GetUniform(Value ptr_ubo, const SType& v_type, uint32_t index); /*! * \brief Declare a new function @@ -562,7 +575,13 @@ class IRBuilder { return val; } - // TOOD doc + /*! + * \brief The common function to declare push constants and uniform buffe + * \param value_types The values in the push constants or uniform buffer + * \param storage_class An enum defined by SPIR-V indicating push constant or uniform + * \param kind An enum indicating push constant or uniform + * \return The created new label + */ Value DeclareStorageVariable(const std::vector& value_types, spv::StorageClass storage_class, ValueKind kind);