Adapter Class — pytorch Architecture
Architecture documentation for the Adapter class in Adapter.h from the pytorch codebase.
Entity Profile
Source Code
aten/src/ATen/native/vulkan/api/Adapter.h lines 84–212
class Adapter final {
public:
explicit Adapter(
VkInstance instance,
PhysicalDevice physical_device,
const uint32_t num_queues);
Adapter(const Adapter&) = delete;
Adapter& operator=(const Adapter&) = delete;
Adapter(Adapter&&) = delete;
Adapter& operator=(Adapter&&) = delete;
~Adapter() = default;
struct Queue {
uint32_t family_index;
uint32_t queue_index;
VkQueueFlags capabilities;
VkQueue handle;
};
private:
// Use a mutex to manage queue usage info since
// it can be accessed from multiple threads
std::mutex queue_usage_mutex_;
// Physical Device Info
PhysicalDevice physical_device_;
// Queue Management
std::vector<Queue> queues_;
std::vector<uint32_t> queue_usage_;
std::array<std::mutex, NUM_QUEUE_MUTEXES> queue_mutexes_;
// Handles
VkInstance instance_;
DeviceHandle device_;
// Device-level resource caches
ShaderLayoutCache shader_layout_cache_;
ShaderCache shader_cache_;
PipelineLayoutCache pipeline_layout_cache_;
ComputePipelineCache compute_pipeline_cache_;
// Memory Management
SamplerCache sampler_cache_;
MemoryAllocator vma_;
public:
// Physical Device metadata
inline VkPhysicalDevice physical_handle() const {
return physical_device_.handle;
}
inline VkDevice device_handle() const {
return device_.handle_;
}
inline bool has_unified_memory() const {
return physical_device_.has_unified_memory;
}
inline uint32_t num_compute_queues() const {
return physical_device_.num_compute_queues;
}
inline bool timestamp_compute_and_graphics() const {
return physical_device_.has_timestamps;
}
inline float timestamp_period() const {
return physical_device_.timestamp_period;
}
// Queue Management
Queue request_queue();
void return_queue(Queue&);
// Caches
inline ShaderLayoutCache& shader_layout_cache() {
return shader_layout_cache_;
}
inline ShaderCache& shader_cache() {
return shader_cache_;
}
inline PipelineLayoutCache& pipeline_layout_cache() {
return pipeline_layout_cache_;
}
inline ComputePipelineCache& compute_pipeline_cache() {
return compute_pipeline_cache_;
}
// Memory Allocation
inline SamplerCache& sampler_cache() {
return sampler_cache_;
}
inline MemoryAllocator& vma() {
return vma_;
}
// Command Buffer Submission
void submit_cmd(
const Queue&,
VkCommandBuffer,
VkFence fence = VK_NULL_HANDLE);
void submit_cmds(
const Adapter::Queue&,
const std::vector<VkCommandBuffer>&,
VkFence fence = VK_NULL_HANDLE);
// Miscellaneous
inline utils::uvec3 local_work_group_size() const {
return {
4u,
4u,
4u,
};
}
std::string stringize() const;
friend std::ostream& operator<<(std::ostream&, const Adapter&);
};
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free