pub struct QTensor { /* private fields */ }
Implementations§
Source§impl QTensor
impl QTensor
pub fn new<S: Into<Shape>>(storage: QStorage, shape: S) -> Result<Self>
pub fn quantize(src: &Tensor, dtype: GgmlDType) -> Result<Self>
pub fn dtype(&self) -> GgmlDType
pub fn device(&self) -> Device
pub fn rank(&self) -> usize
pub fn shape(&self) -> &Shape
pub fn dequantize(&self, device: &Device) -> Result<Tensor>
pub fn dequantize_f16(&self, device: &Device) -> Result<Tensor>
pub fn storage_size_in_bytes(&self) -> usize
pub fn data(&self) -> Result<Cow<'_, [u8]>>
Trait Implementations§
Source§impl CustomOp1 for QTensor
impl CustomOp1 for QTensor
fn name(&self) -> &'static str
Source§fn cpu_fwd(
&self,
storage: &CpuStorage,
layout: &Layout,
) -> Result<(CpuStorage, Shape)>
fn cpu_fwd( &self, storage: &CpuStorage, layout: &Layout, ) -> Result<(CpuStorage, Shape)>
The forward pass, as run on a cpu device. Note that the storage can use arbitrary strides,
offsets etc so the associated layout should be used to access it.
Source§fn metal_fwd(
&self,
storage: &MetalStorage,
layout: &Layout,
) -> Result<(MetalStorage, Shape)>
fn metal_fwd( &self, storage: &MetalStorage, layout: &Layout, ) -> Result<(MetalStorage, Shape)>
The forward pass, as run on a metal gpu device. Note that the storage can use arbitrary strides,
offsets etc so the associated layout should be used to access it.
Source§fn cuda_fwd(
&self,
storage: &CudaStorage,
layout: &Layout,
) -> Result<(CudaStorage, Shape)>
fn cuda_fwd( &self, storage: &CudaStorage, layout: &Layout, ) -> Result<(CudaStorage, Shape)>
The forward pass, as run on a gpu device. Note that the storage can use arbitrary strides,
offsets etc so the associated layout should be used to access it.
Source§fn bwd(
&self,
_arg: &Tensor,
_res: &Tensor,
_grad_res: &Tensor,
) -> Result<Option<Tensor>>
fn bwd( &self, _arg: &Tensor, _res: &Tensor, _grad_res: &Tensor, ) -> Result<Option<Tensor>>
This function takes as argument the argument
arg
used in the forward pass, the result
produced by the forward operation res
and the gradient of the result grad_res
.
The function should return the gradient of the argument.Auto Trait Implementations§
impl Freeze for QTensor
impl !RefUnwindSafe for QTensor
impl Send for QTensor
impl Sync for QTensor
impl Unpin for QTensor
impl !UnwindSafe for QTensor
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
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>
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 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>
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