pub struct GPUAccelerator { /* private fields */ }Expand description
GPU acceleration backend with intelligent device detection and CPU fallback
Implementations§
Source§impl GPUAccelerator
impl GPUAccelerator
Sourcepub fn global() -> &'static GPUAccelerator
pub fn global() -> &'static GPUAccelerator
Get the global GPU accelerator instance (singleton pattern for efficiency)
Sourcepub fn new() -> CandleResult<Self>
pub fn new() -> CandleResult<Self>
Create a new GPU accelerator with intelligent device detection
Sourcepub fn device_type(&self) -> &DeviceType
pub fn device_type(&self) -> &DeviceType
Get the device type being used
Sourcepub fn is_gpu_enabled(&self) -> bool
pub fn is_gpu_enabled(&self) -> bool
Check if GPU acceleration is available
Sourcepub fn device_count(&self) -> usize
pub fn device_count(&self) -> usize
Get number of available GPU devices
Sourcepub fn is_multi_gpu_available(&self) -> bool
pub fn is_multi_gpu_available(&self) -> bool
Check if multiple GPU devices are available
Sourcepub fn all_devices(&self) -> &[Device]
pub fn all_devices(&self) -> &[Device]
Get all available devices for multi-GPU operations
Sourcepub fn switch_device(&mut self, device_index: usize) -> Result<(), String>
pub fn switch_device(&mut self, device_index: usize) -> Result<(), String>
Switch to a specific device (for multi-GPU operations)
Sourcepub fn current_device_index(&self) -> usize
pub fn current_device_index(&self) -> usize
Get current device index
Sourcepub fn array_to_tensor(&self, array: &Array1<f32>) -> CandleResult<Tensor>
pub fn array_to_tensor(&self, array: &Array1<f32>) -> CandleResult<Tensor>
Convert ndarray to Candle tensor on the appropriate device
Sourcepub fn array2_to_tensor(&self, array: &Array2<f32>) -> CandleResult<Tensor>
pub fn array2_to_tensor(&self, array: &Array2<f32>) -> CandleResult<Tensor>
Convert 2D ndarray to Candle tensor on the appropriate device
Sourcepub fn tensor_to_array(&self, tensor: &Tensor) -> CandleResult<Array1<f32>>
pub fn tensor_to_array(&self, tensor: &Tensor) -> CandleResult<Array1<f32>>
Convert Candle tensor back to ndarray
Sourcepub fn tensor_to_array2(&self, tensor: &Tensor) -> CandleResult<Array2<f32>>
pub fn tensor_to_array2(&self, tensor: &Tensor) -> CandleResult<Array2<f32>>
Convert 2D Candle tensor back to ndarray
Sourcepub fn cosine_similarity_batch(
&self,
query: &Array1<f32>,
vectors: &Array2<f32>,
) -> CandleResult<Array1<f32>>
pub fn cosine_similarity_batch( &self, query: &Array1<f32>, vectors: &Array2<f32>, ) -> CandleResult<Array1<f32>>
Accelerated cosine similarity computation
Sourcepub fn matmul(
&self,
a: &Array2<f32>,
b: &Array2<f32>,
) -> CandleResult<Array2<f32>>
pub fn matmul( &self, a: &Array2<f32>, b: &Array2<f32>, ) -> CandleResult<Array2<f32>>
Accelerated matrix multiplication
Sourcepub fn add_vectors(&self, vectors: &[Array1<f32>]) -> CandleResult<Array1<f32>>
pub fn add_vectors(&self, vectors: &[Array1<f32>]) -> CandleResult<Array1<f32>>
Accelerated vector addition
Sourcepub fn memory_info(&self) -> String
pub fn memory_info(&self) -> String
Get memory usage information
Sourcepub fn benchmark(&self) -> CandleResult<f64>
pub fn benchmark(&self) -> CandleResult<f64>
Benchmark the device performance
Sourcepub fn multi_gpu_similarity_search(
&self,
query: &Array1<f32>,
vectors: &Array2<f32>,
) -> CandleResult<Array1<f32>>
pub fn multi_gpu_similarity_search( &self, query: &Array1<f32>, vectors: &Array2<f32>, ) -> CandleResult<Array1<f32>>
Multi-GPU parallel similarity search (when multiple GPUs available)
Trait Implementations§
Source§impl Clone for GPUAccelerator
impl Clone for GPUAccelerator
Source§fn clone(&self) -> GPUAccelerator
fn clone(&self) -> GPUAccelerator
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GPUAccelerator
impl Debug for GPUAccelerator
Auto Trait Implementations§
impl Freeze for GPUAccelerator
impl RefUnwindSafe for GPUAccelerator
impl Send for GPUAccelerator
impl Sync for GPUAccelerator
impl Unpin for GPUAccelerator
impl UnwindSafe for GPUAccelerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more