Struct GPUAccelerator

Source
pub struct GPUAccelerator { /* private fields */ }
Expand description

GPU acceleration backend with intelligent device detection and CPU fallback

Implementations§

Source§

impl GPUAccelerator

Source

pub fn global() -> &'static GPUAccelerator

Get the global GPU accelerator instance (singleton pattern for efficiency)

Source

pub fn new() -> CandleResult<Self>

Create a new GPU accelerator with intelligent device detection

Source

pub fn device_type(&self) -> &DeviceType

Get the device type being used

Source

pub fn device(&self) -> &Device

Get the underlying Candle device

Source

pub fn is_gpu_enabled(&self) -> bool

Check if GPU acceleration is available

Source

pub fn device_count(&self) -> usize

Get number of available GPU devices

Source

pub fn is_multi_gpu_available(&self) -> bool

Check if multiple GPU devices are available

Source

pub fn all_devices(&self) -> &[Device]

Get all available devices for multi-GPU operations

Source

pub fn switch_device(&mut self, device_index: usize) -> Result<(), String>

Switch to a specific device (for multi-GPU operations)

Source

pub fn current_device_index(&self) -> usize

Get current device index

Source

pub fn array_to_tensor(&self, array: &Array1<f32>) -> CandleResult<Tensor>

Convert ndarray to Candle tensor on the appropriate device

Source

pub fn array2_to_tensor(&self, array: &Array2<f32>) -> CandleResult<Tensor>

Convert 2D ndarray to Candle tensor on the appropriate device

Source

pub fn tensor_to_array(&self, tensor: &Tensor) -> CandleResult<Array1<f32>>

Convert Candle tensor back to ndarray

Source

pub fn tensor_to_array2(&self, tensor: &Tensor) -> CandleResult<Array2<f32>>

Convert 2D Candle tensor back to ndarray

Source

pub fn cosine_similarity_batch( &self, query: &Array1<f32>, vectors: &Array2<f32>, ) -> CandleResult<Array1<f32>>

Accelerated cosine similarity computation

Source

pub fn matmul( &self, a: &Array2<f32>, b: &Array2<f32>, ) -> CandleResult<Array2<f32>>

Accelerated matrix multiplication

Source

pub fn add_vectors(&self, vectors: &[Array1<f32>]) -> CandleResult<Array1<f32>>

Accelerated vector addition

Source

pub fn memory_info(&self) -> String

Get memory usage information

Source

pub fn benchmark(&self) -> CandleResult<f64>

Benchmark the device performance

Multi-GPU parallel similarity search (when multiple GPUs available)

Source

pub fn multi_gpu_batch_process<T, F>( &self, data: &[T], process_fn: F, ) -> Result<Vec<T>, String>
where T: Clone + Send + Sync, F: Fn(&[T], usize) -> Result<Vec<T>, String> + Send + Sync,

Multi-GPU batch processing for large operations

Trait Implementations§

Source§

impl Clone for GPUAccelerator

Source§

fn clone(&self) -> GPUAccelerator

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GPUAccelerator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GPUAccelerator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,