pub struct CubeTensor {
pub client: Client,
pub handle: Handle,
pub meta: Box<Metadata>,
pub device: CubeDevice,
pub dtype: DType,
pub qparams: Option<QParams>,
}Expand description
The basic tensor primitive struct.
Fields§
§client: ClientCompute client for the runtime this tensor’s device names.
handle: HandleThe buffer where the data are stored.
meta: Box<Metadata>The metadata of the tensor.
device: CubeDeviceThe device of the tensor.
dtype: DTypeThe datatype of the tensor.
qparams: Option<QParams>Runtime quantization parameters, if applicable
Implementations§
Source§impl CubeTensor
impl CubeTensor
Sourcepub fn new(
client: Client,
handle: Handle,
metadata: Metadata,
device: CubeDevice,
dtype: DType,
) -> Self
pub fn new( client: Client, handle: Handle, metadata: Metadata, device: CubeDevice, dtype: DType, ) -> Self
Create a new standard tensor
Sourcepub fn new_contiguous(
client: Client,
device: CubeDevice,
shape: Shape,
handle: Handle,
dtype: DType,
) -> Self
pub fn new_contiguous( client: Client, device: CubeDevice, shape: Shape, handle: Handle, dtype: DType, ) -> Self
Create a new tensor with a contiguous memory layout.
Sourcepub fn to_client(&mut self, client: Client, device: CubeDevice) -> Self
pub fn to_client(&mut self, client: Client, device: CubeDevice) -> Self
Change the context of the current tensor and return the newly transferred tensor.
Sourcepub fn binding(self) -> TensorBinding
pub fn binding(self) -> TensorBinding
Return the reference to a tensor handle.
Sourcepub fn into_tensor_arg(self) -> TensorArg
pub fn into_tensor_arg(self) -> TensorArg
Sourcepub fn into_buffer_arg(self) -> BufferArg
pub fn into_buffer_arg(self) -> BufferArg
Return the reference to a buffer argument.
Sourcepub fn as_tensor_alias(&self, input_pos: usize) -> TensorArg
pub fn as_tensor_alias(&self, input_pos: usize) -> TensorArg
Returns a reference to the aliased tensor argument.
Sourcepub fn into_linear_view(self) -> LinearViewLaunch
pub fn into_linear_view(self) -> LinearViewLaunch
Return a linear view of this tensor.
Sourcepub fn as_linear_view_alias(&self, input_pos: usize) -> LinearViewLaunch
pub fn as_linear_view_alias(&self, input_pos: usize) -> LinearViewLaunch
Return an aliased linear view of this tensor
Sourcepub fn into_linear_view_like(self, reference: &Self) -> LinearViewLaunch
pub fn into_linear_view_like(self, reference: &Self) -> LinearViewLaunch
Return a linear view broadcast to the reference tensor’s shape
Sourcepub fn required_address_type(&self) -> AddressType
pub fn required_address_type(&self) -> AddressType
Returns the address type required to index this tensor
Sourcepub fn try_scheme(&self) -> Option<&QuantScheme>
pub fn try_scheme(&self) -> Option<&QuantScheme>
Return the QuantScheme if present
Sourcepub fn assert_is_on_same_device(&self, other: &Self)
pub fn assert_is_on_same_device(&self, other: &Self)
Assert that both tensors are on the same device.
Sourcepub fn is_contiguous(&self) -> bool
pub fn is_contiguous(&self) -> bool
Check if the current tensor is contiguous.
A tensor is contiguous if the elements are stored in memory if the strides in non-increasing order and the strides at position k is equal to the product of the shapes at all positions greater than k. However, all axes with a shape of 1 are ignored.
Sourcepub fn is_contiguous_buffer(&self) -> bool
pub fn is_contiguous_buffer(&self) -> bool
Check if the current tensor has a contiguous backing buffer (no overlap and no empty memory regions within the shape).
Sourcepub fn is_nonoverlapping(&self) -> bool
pub fn is_nonoverlapping(&self) -> bool
Checks if the tensor is non-overlapping (can be safely written to).
Source§impl CubeTensor
impl CubeTensor
Sourcepub fn new_quantized(
client: Client,
handle: Handle,
shape: Shape,
device: CubeDevice,
strides: Strides,
dtype: DType,
qparams: QParams,
) -> Self
pub fn new_quantized( client: Client, handle: Handle, shape: Shape, device: CubeDevice, strides: Strides, dtype: DType, qparams: QParams, ) -> Self
Create a new quantized tensor
Sourcepub fn quantized_handles(&self) -> Option<(CubeTensor, CubeTensor)>
pub fn quantized_handles(&self) -> Option<(CubeTensor, CubeTensor)>
Returns the two tensors: (values, params) for a quantized tensor.
For the values, native types that aren’t supported as a normal DType will be returned
as an unsigned integer tensor representing the bits. Should be reconstructed using from_bits
in kernels.
A storage-tiled tensor’s values keep its metadata whole: its physical dims already state the packing, and only a kernel that reads tiles may bind them — any other refuses them as rows. The scales keep their own metadata, tiled or not.
Sourcepub fn scales(&self) -> Option<CubeTensor>
pub fn scales(&self) -> Option<CubeTensor>
Construct a separate tensor for the quantization scales, if present
Sourcepub fn global(&self) -> Option<CubeTensor>
pub fn global(&self) -> Option<CubeTensor>
Construct a separate tensor for the per-tensor scale, for a two-level scheme.
Trait Implementations§
impl AutotuneOutput for CubeTensor
Source§impl Clone for CubeTensor
impl Clone for CubeTensor
Source§impl Debug for CubeTensor
impl Debug for CubeTensor
Source§impl From<CubeTensor> for TensorHandle
impl From<CubeTensor> for TensorHandle
Source§fn from(val: CubeTensor) -> Self
fn from(val: CubeTensor) -> Self
Source§impl From<CubeTensor> for CubeFusionHandle
Available on crate features fusion only.
impl From<CubeTensor> for CubeFusionHandle
fusion only.Source§fn from(value: CubeTensor) -> Self
fn from(value: CubeTensor) -> Self
Source§impl TensorMetadata for CubeTensor
impl TensorMetadata for CubeTensor
Source§fn shape(&self) -> Shape
fn shape(&self) -> Shape
The logical shape: a storage-tiled tensor’s physical dims split each matrix dim in two, and its own metadata folds them back. Identity on a plain tensor.
Source§fn can_mut(&self) -> bool
fn can_mut(&self) -> bool
slice_assign, an inplace kernel)
writes the existing allocation instead of copying it first. Read moreSource§fn scheme(&self) -> QuantScheme
fn scheme(&self) -> QuantScheme
Auto Trait Implementations§
impl !RefUnwindSafe for CubeTensor
impl !UnwindSafe for CubeTensor
impl Freeze for CubeTensor
impl Send for CubeTensor
impl Sync for CubeTensor
impl Unpin for CubeTensor
impl UnsafeUnpin for CubeTensor
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneExpand for Twhere
T: Clone,
impl<T> CloneExpand for Twhere
T: Clone,
fn __expand_clone_method(&self, _: &Scope) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
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