CubeTensor

Struct CubeTensor 

Source
pub struct CubeTensor<R: CubeRuntime> {
    pub client: ComputeClient<R>,
    pub handle: Handle,
    pub shape: Shape,
    pub device: R::Device,
    pub strides: Vec<usize>,
    pub dtype: DType,
    pub qparams: Option<QParams>,
}
Expand description

The basic tensor primitive struct.

Fields§

§client: ComputeClient<R>

Compute client for the runtime.

§handle: Handle

The buffer where the data are stored.

§shape: Shape

The shape of the tensor.

§device: R::Device

The device of the tensor.

§strides: Vec<usize>

The strides of the tensor.

§dtype: DType

The datatype of the tensor.

§qparams: Option<QParams>

Runtime quantization parameters, if applicable

Implementations§

Source§

impl<R> CubeTensor<R>
where R: CubeRuntime,

Source

pub fn new( client: ComputeClient<R>, handle: Handle, shape: Shape, device: R::Device, strides: Vec<usize>, dtype: DType, ) -> Self

Create a new standard tensor

Source

pub fn new_contiguous( client: ComputeClient<R>, device: R::Device, shape: Shape, handle: Handle, dtype: DType, ) -> Self

Create a new tensor with a contiguous memory layout.

Source

pub fn to_client(&self, client: ComputeClient<R>, device: R::Device) -> Self

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

Source

pub fn as_handle_ref(&self) -> TensorHandleRef<'_, R>

Return the reference to a tensor handle.

Source

pub fn elem_size(&self) -> usize

Returns the element size of this tensor

Source

pub fn as_tensor_arg<'a>(&'a self, line_size: LineSize) -> TensorArg<'a, R>

Return the reference to a tensor argument.

Source

pub fn as_array_arg<E: CubeElement>( &self, line_size: LineSize, ) -> ArrayArg<'_, R>

Return the reference to an array argument.

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§

impl<R: CubeRuntime> CubeTensor<R>

Source

pub fn new_quantized( client: ComputeClient<R>, handle: Handle, shape: Shape, device: R::Device, strides: Vec<usize>, dtype: DType, qparams: QParams, ) -> Self

Create a new quantized tensor

Source

pub fn quantized_handles(&self) -> Option<(CubeTensor<R>, CubeTensor<R>)>

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.

Source

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

Construct a separate tensor for the quantization scales, if present

Trait Implementations§

Source§

impl<R> Clone for CubeTensor<R>
where R: CubeRuntime,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<R> Debug for CubeTensor<R>
where R: CubeRuntime,

Source§

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

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

impl<R: CubeRuntime> From<CubeTensor<R>> for CubeFusionHandle<R>

Available on crate features fusion only.
Source§

fn from(value: CubeTensor<R>) -> Self

Converts to this type from the input type.
Source§

impl<R: CubeRuntime> From<CubeTensor<R>> for TensorHandle<R>

Source§

fn from(val: CubeTensor<R>) -> Self

Converts to this type from the input type.
Source§

impl<R: CubeRuntime> QTensorPrimitive for CubeTensor<R>

Source§

fn scheme(&self) -> &QuantScheme

Returns the quantization settings for the given tensor.
Source§

fn acc_precision(&self) -> QuantAcc

The precision used for the accumulation in various kernels.
Source§

fn propagation(&self) -> QuantPropagation

How quantization is propagated during computation.
Source§

fn default_scheme() -> QuantScheme

Returns the default tensor quantization scheme.
Source§

impl<R: CubeRuntime> TensorMetadata for CubeTensor<R>

Source§

fn dtype(&self) -> DType

The dtype of the tensor.
Source§

fn shape(&self) -> Shape

The shape of the tensor.
Source§

fn rank(&self) -> usize

The number of dimensions of the tensor.
Source§

impl<R: CubeRuntime> AutotuneOutput for CubeTensor<R>

Auto Trait Implementations§

§

impl<R> Freeze for CubeTensor<R>
where <R as CubeRuntime>::CubeDevice: Freeze,

§

impl<R> !RefUnwindSafe for CubeTensor<R>

§

impl<R> Send for CubeTensor<R>

§

impl<R> Sync for CubeTensor<R>

§

impl<R> Unpin for CubeTensor<R>

§

impl<R> !UnwindSafe for CubeTensor<R>

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

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