pub struct GpuTensor { /* private fields */ }
Implementations§
Source§impl GpuTensor
impl GpuTensor
pub async fn uninitialized(shape: Vec<usize>) -> GpuTensor
pub async fn new_filled(shape: Vec<usize>, fill_val: f32) -> GpuTensor
pub fn from_data_with_gpu( gpu: &GpuInstance, data: Vec<f32>, shape: Vec<usize>, ) -> Self
pub fn from_buffer(buffer: GpuBuffer, shape: VecDeque<usize>) -> Self
pub fn from_buffer_with_strides_and_offset( buffer: GpuBuffer, shape: VecDeque<usize>, strides: VecDeque<usize>, offset: usize, ) -> Self
pub fn from(data: Vec<f32>, shape: Vec<usize>) -> Self
pub fn from_data_1d(data: Vec<f32>) -> Self
pub fn from_scalar(data: f32) -> Self
pub fn dim_strides(&self) -> &ShapeStrides
pub fn is_scalar(&self) -> bool
pub fn is_empty(&self) -> bool
pub fn slice<T: Into<SliceRangeInfo>>( &self, bounds: Vec<T>, ) -> GpuTensorView<'_>
pub async fn assign<T: Into<SliceRangeInfo>>( &mut self, bounds: Vec<T>, value: f32, )
Source§impl GpuTensor
impl GpuTensor
pub async fn eq(&self, other: &Self) -> bool
pub async fn transpose(&self) -> GpuTensor
pub async fn clone(&self) -> GpuTensor
pub async fn leaky_relu(&self, leakage: f32) -> GpuTensor
pub async fn fill_with(&mut self, value: f32)
pub async fn matmul<'a>(&'a self, other: &'a Self) -> Self
Source§impl GpuTensor
impl GpuTensor
pub fn view(&self) -> GpuTensorView<'_>
pub fn reshape(&mut self, shape: Vec<usize>)
Sourcepub fn broadcast<'a>(
&'a self,
other: &'a Self,
skipping_dims: Option<usize>,
) -> Option<(GpuTensorView<'a>, GpuTensorView<'a>)>
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 GpuAllocated for GpuTensor
impl GpuAllocated for GpuTensor
fn get_gpu(&self) -> &'static GpuInstance
fn internal_gpu_buffer(&self) -> &GpuBuffer
fn internal_buffer_size_in_bytes(&self) -> usize
Source§impl MutShapeStrideTrait for GpuTensor
impl MutShapeStrideTrait for GpuTensor
Source§fn increase_rank(&mut self)
fn increase_rank(&mut self)
Artificially increase the rank, setting the new dimension shape to 1
Source§fn decrease_rank(&mut self)
fn decrease_rank(&mut self)
Decrease the rank if the leading shape dimension is 1, otherwise panics
Auto Trait Implementations§
impl !Freeze for GpuTensor
impl !RefUnwindSafe for GpuTensor
impl Send for GpuTensor
impl Sync for GpuTensor
impl Unpin for GpuTensor
impl !UnwindSafe for GpuTensor
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
Mutably borrows from an owned value. Read more