UniformParamsBuffer Class — pytorch Architecture
Architecture documentation for the UniformParamsBuffer class in Context.h from the pytorch codebase.
Entity Profile
Source Code
aten/src/ATen/native/vulkan/api/Context.h lines 205–251
class UniformParamsBuffer final {
private:
Context* context_p_;
size_t nbytes_;
VulkanBuffer vulkan_buffer_;
public:
UniformParamsBuffer() : context_p_{nullptr}, vulkan_buffer_{} {}
template <typename Block>
UniformParamsBuffer(Context* context_p, const Block& block)
: context_p_(context_p),
nbytes_(sizeof(block)),
vulkan_buffer_(
context_p_->adapter_ptr()->vma().create_params_buffer(block)) {}
UniformParamsBuffer(const UniformParamsBuffer&);
UniformParamsBuffer& operator=(const UniformParamsBuffer&);
UniformParamsBuffer(UniformParamsBuffer&&) = default;
UniformParamsBuffer& operator=(UniformParamsBuffer&&) = default;
~UniformParamsBuffer() {
if (vulkan_buffer_) {
context_p_->register_buffer_cleanup(vulkan_buffer_);
}
}
VulkanBuffer& buffer() {
return vulkan_buffer_;
}
template <typename Block>
void update(const Block& block) {
if (sizeof(block) != nbytes_) {
VK_THROW(
"Attempted to update UniformParamsBuffer with data of different size");
}
// Fill the uniform buffer with data in block
{
MemoryMap mapping(vulkan_buffer_, MemoryAccessType::WRITE);
Block* data_ptr = mapping.template data<Block>();
*data_ptr = block;
}
}
};
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free