MemoryAllocator Class — pytorch Architecture
Architecture documentation for the MemoryAllocator class in Resource.h from the pytorch codebase.
Entity Profile
Source Code
aten/src/ATen/native/vulkan/api/Resource.h lines 439–498
class MemoryAllocator final {
public:
explicit MemoryAllocator(
VkInstance instance,
VkPhysicalDevice physical_device,
VkDevice device);
MemoryAllocator(const MemoryAllocator&) = delete;
MemoryAllocator& operator=(const MemoryAllocator&) = delete;
MemoryAllocator(MemoryAllocator&&) noexcept;
MemoryAllocator& operator=(MemoryAllocator&&) = delete;
~MemoryAllocator();
private:
VkInstance instance_;
VkPhysicalDevice physical_device_;
VkDevice device_;
VmaAllocator allocator_;
public:
MemoryAllocation create_allocation(
const VkMemoryRequirements& memory_requirements,
const VmaAllocationCreateInfo& create_info);
VulkanImage create_image(
const VkExtent3D&,
const VkFormat,
const VkImageType,
const VkImageViewType,
const VulkanImage::SamplerProperties&,
VkSampler,
const bool allow_transfer = false,
const bool allocate_memory = true);
VulkanBuffer create_storage_buffer(
const VkDeviceSize,
const bool gpu_only = true,
const bool allocate_memory = true);
VulkanBuffer create_staging_buffer(const VkDeviceSize);
/*
* Create a uniform buffer with a specified size
*/
VulkanBuffer create_uniform_buffer(const VkDeviceSize);
/*
* Create a uniform buffer containing the data in an arbitrary struct
*/
template <typename Block>
VulkanBuffer create_params_buffer(const Block& block);
VmaTotalStatistics get_memory_statistics() const {
VmaTotalStatistics stats = {};
vmaCalculateStatistics(allocator_, &stats);
return stats;
}
};
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free