Skip to main content

CubeTensor

Struct CubeTensor 

Source
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: Client

Compute client for the runtime this tensor’s device names.

§handle: Handle

The buffer where the data are stored.

§meta: Box<Metadata>

The metadata of the tensor.

§device: CubeDevice

The device of the tensor.

§dtype: DType

The datatype of the tensor.

§qparams: Option<QParams>

Runtime quantization parameters, if applicable

Implementations§

Source§

impl CubeTensor

Source

pub fn new( client: Client, handle: Handle, metadata: Metadata, device: CubeDevice, dtype: DType, ) -> Self

Create a new standard tensor

Source

pub fn new_contiguous( client: Client, device: CubeDevice, shape: Shape, handle: Handle, dtype: DType, ) -> Self

Create a new tensor with a contiguous memory layout.

Source

pub fn to_client(&mut self, client: Client, device: CubeDevice) -> Self

Change the context of the current tensor and return the newly transferred tensor.

Source

pub fn binding(self) -> TensorBinding

Return the reference to a tensor handle.

Source

pub fn elem_size(&self) -> usize

Returns the element size of this tensor

Source

pub fn into_tensor_arg(self) -> TensorArg

Return the reference to a tensor argument.

§Panics

On a storage-tiled tensor: a kernel argument is read as rows, and only cubek’s matmul reads storage tiles, through binding. Un-tile it first (untile).

Source

pub fn into_buffer_arg(self) -> BufferArg

Return the reference to a buffer argument.

Source

pub fn as_tensor_alias(&self, input_pos: usize) -> TensorArg

Returns a reference to the aliased tensor argument.

Source

pub fn into_linear_view(self) -> LinearViewLaunch

Return a linear view of this tensor.

Source

pub fn as_linear_view_alias(&self, input_pos: usize) -> LinearViewLaunch

Return an aliased linear view of this tensor

Source

pub fn into_linear_view_like(self, reference: &Self) -> LinearViewLaunch

Return a linear view broadcast to the reference tensor’s shape

Source

pub fn required_address_type(&self) -> AddressType

Returns the address type required to index this tensor

Source

pub fn try_scheme(&self) -> Option<&QuantScheme>

Return the QuantScheme if present

Source

pub fn copy(&self) -> Self

Copy the current tensor.

Source

pub fn can_mut(&self) -> bool

Check if the tensor is safe to mutate.

Source

pub fn assert_is_on_same_device(&self, other: &Self)

Assert that both tensors are on the same device.

Source

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.

Source

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).

Source

pub fn is_nonoverlapping(&self) -> bool

Checks if the tensor is non-overlapping (can be safely written to).

Source§

impl CubeTensor

Source

pub fn new_quantized( client: Client, handle: Handle, shape: Shape, device: CubeDevice, strides: Strides, dtype: DType, qparams: QParams, ) -> Self

Create a new quantized tensor

Source

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.

Source

pub fn scales(&self) -> Option<CubeTensor>

Construct a separate tensor for the quantization scales, if present

Source

pub fn global(&self) -> Option<CubeTensor>

Construct a separate tensor for the per-tensor scale, for a two-level scheme.

Trait Implementations§

Source§

impl AutotuneOutput for CubeTensor

Source§

impl Clone for CubeTensor

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CubeTensor

Source§

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

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

impl From<CubeTensor> for TensorHandle

Source§

fn from(val: CubeTensor) -> Self

Converts to this type from the input type.
Source§

impl From<CubeTensor> for CubeFusionHandle

Available on crate features fusion only.
Source§

fn from(value: CubeTensor) -> Self

Converts to this type from the input type.
Source§

impl TensorMetadata for CubeTensor

Source§

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§

type Device = Device

The device type associated with the tensor.
Source§

fn dtype(&self) -> DType

Get the dtype of the tensor.
Source§

fn rank(&self) -> usize

Get the number of dimensions of the tensor.
Source§

fn device(&self) -> Self::Device

Get the device associated with the tensor.
Source§

fn can_mut(&self) -> bool

Whether the tensor’s buffer can be mutated in place — i.e. this handle uniquely owns it, so an in-place op (slice_assign, an inplace kernel) writes the existing allocation instead of copying it first. Read more
Source§

fn scheme(&self) -> QuantScheme

Get the quantization scheme for a quantized float tensor. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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

Converts 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)

Converts &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)

Converts &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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

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

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

Source§

fn comptime(self) -> Self

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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<T> TuneInputs for T
where T: Clone + Send + Sync + 'static,

Source§

type At<'a> = T

The concrete input type at lifetime 'a.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

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