Struct GpuTensor

Source
pub struct GpuTensor { /* private fields */ }

Implementations§

Source§

impl GpuTensor

Source

pub async fn uninitialized(shape: Vec<usize>) -> GpuTensor

Source

pub async fn new_filled(shape: Vec<usize>, fill_val: f32) -> GpuTensor

Source

pub fn from_data_with_gpu( gpu: &GpuInstance, data: Vec<f32>, shape: Vec<usize>, ) -> Self

Source

pub fn from_buffer(buffer: GpuBuffer, shape: VecDeque<usize>) -> Self

Source

pub fn from_buffer_with_strides_and_offset( buffer: GpuBuffer, shape: VecDeque<usize>, strides: VecDeque<usize>, offset: usize, ) -> Self

Source

pub fn from(data: Vec<f32>, shape: Vec<usize>) -> Self

Source

pub fn from_data_1d(data: Vec<f32>) -> Self

Source

pub fn from_scalar(data: f32) -> Self

Source

pub fn dim_strides(&self) -> &ShapeStrides

Source

pub fn is_scalar(&self) -> bool

Source

pub fn is_empty(&self) -> bool

Source

pub fn slice<T: Into<SliceRangeInfo>>( &self, bounds: Vec<T>, ) -> GpuTensorView<'_>

Source

pub async fn assign<T: Into<SliceRangeInfo>>( &mut self, bounds: Vec<T>, value: f32, )

Source§

impl GpuTensor

Source

pub async fn eq(&self, other: &Self) -> bool

Source

pub async fn transpose(&self) -> GpuTensor

Source

pub async fn clone(&self) -> GpuTensor

Source

pub async fn leaky_relu(&self, leakage: f32) -> GpuTensor

Source

pub async fn fill_with(&mut self, value: f32)

Source

pub async fn matmul<'a>(&'a self, other: &'a Self) -> Self

Source§

impl GpuTensor

Source

pub fn view(&self) -> GpuTensorView<'_>

Source

pub fn reshape(&mut self, shape: Vec<usize>)

Source

pub fn broadcast<'a>( &'a self, other: &'a Self, skipping_dims: Option<usize>, ) -> Option<(GpuTensorView<'a>, GpuTensorView<'a>)>

Tensor are broadcastable if:

  • Each tensor has at least one dimension.
  • When iterating over the dimension sizes, starting at the trailing dimension, the dimension sizes must either be equal, one of them is 1, or one of them does not exist.

The broadcasting rules are: If the number of dimensions of x and y are not equal, prepend 1 to the dimensions of the tensor with fewer dimensions to make them equal length. Then, for each dimension size, the resulting dimension size is the max of the sizes of x and y along that dimension.

Trait Implementations§

Source§

impl Debug for GpuTensor

Source§

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

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

impl GpuAllocated for GpuTensor

Source§

fn get_gpu(&self) -> &'static GpuInstance

Source§

fn internal_gpu_buffer(&self) -> &GpuBuffer

Source§

fn internal_buffer_size_in_bytes(&self) -> usize

Source§

impl MutShapeStrideTrait for GpuTensor

Source§

fn increase_rank(&mut self)

Artificially increase the rank, setting the new dimension shape to 1
Source§

fn decrease_rank(&mut self)

Decrease the rank if the leading shape dimension is 1, otherwise panics
Source§

impl ShapeStrideTrait for GpuTensor

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> CpuTransferable for T

Source§

fn to_cpu<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = CpuTensor> + 'async_trait>>
where 'life0: 'async_trait, T: 'async_trait,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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