VulkanBuffer Class — pytorch Architecture
Architecture documentation for the VulkanBuffer class in Resource.h from the pytorch codebase.
Entity Profile
Source Code
aten/src/ATen/native/vulkan/api/Resource.h lines 73–169
class VulkanBuffer final {
public:
struct BufferProperties final {
VkDeviceSize size;
VkDeviceSize mem_offset;
VkDeviceSize mem_range;
VkBufferUsageFlags buffer_usage;
};
explicit VulkanBuffer();
explicit VulkanBuffer(
const VmaAllocator,
const VkDeviceSize,
const VmaAllocationCreateInfo&,
const VkBufferUsageFlags,
const bool allocate_memory = true);
VulkanBuffer(const VulkanBuffer&) = delete;
VulkanBuffer& operator=(const VulkanBuffer&) = delete;
VulkanBuffer(VulkanBuffer&&) noexcept;
VulkanBuffer& operator=(VulkanBuffer&&) noexcept;
~VulkanBuffer();
struct Package final {
VkBuffer handle;
VkDeviceSize buffer_offset;
VkDeviceSize buffer_range;
};
friend struct BufferMemoryBarrier;
private:
BufferProperties buffer_properties_;
VmaAllocator allocator_;
MemoryAllocation memory_;
// Indicates whether the underlying memory is owned by this resource
bool owns_memory_;
VkBuffer handle_;
public:
inline VkDevice device() const {
VmaAllocatorInfo allocator_info{};
vmaGetAllocatorInfo(allocator_, &allocator_info);
return allocator_info.device;
}
inline VmaAllocator vma_allocator() const {
return allocator_;
}
inline VmaAllocation allocation() const {
return memory_.allocation;
}
inline VmaAllocationCreateInfo allocation_create_info() const {
return VmaAllocationCreateInfo(memory_.create_info);
}
inline VkBuffer handle() const {
return handle_;
}
inline VkDeviceSize mem_offset() const {
return buffer_properties_.mem_offset;
}
inline VkDeviceSize mem_range() const {
return buffer_properties_.mem_range;
}
inline VkDeviceSize mem_size() const {
return buffer_properties_.size;
}
inline bool has_memory() const {
return (memory_.allocation != VK_NULL_HANDLE);
}
inline bool owns_memory() const {
return owns_memory_;
}
operator bool() const {
return (handle_ != VK_NULL_HANDLE);
}
inline void bind_allocation(const MemoryAllocation& memory) {
VK_CHECK_COND(!memory_, "Cannot bind an already bound allocation!");
VK_CHECK(vmaBindBufferMemory(allocator_, memory.allocation, handle_));
memory_.allocation = memory.allocation;
}
VkMemoryRequirements get_memory_requirements() const;
};
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free