Skip to content

Commit

Permalink
doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
masahi committed Apr 8, 2021
1 parent 62d19eb commit 5711978
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/runtime/vulkan/vulkan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,7 @@ class VulkanModuleNode final : public runtime::ModuleNode {
public:
explicit VulkanModuleNode(std::unordered_map<std::string, VulkanShader> smap,
std::unordered_map<std::string, FunctionInfo> 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"; }

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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_;
Expand Down
4 changes: 1 addition & 3 deletions src/runtime/vulkan/vulkan_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
23 changes: 21 additions & 2 deletions src/target/spirv/ir_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<SType>& 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
Expand Down Expand Up @@ -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<SType>& value_types,
spv::StorageClass storage_class, ValueKind kind);

Expand Down

0 comments on commit 5711978

Please sign in to comment.