Skip to main content

CubeTensor

Struct CubeTensor 

Source
pub struct CubeTensor<R>
where R: CubeRuntime,
{ pub client: ComputeClient<R>, pub handle: Handle, pub meta: Box<Metadata>, pub device: <R as Runtime>::Device, pub dtype: DType, pub qparams: Option<QParams<QParamTensor>>, }
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.

§meta: Box<Metadata>

The metadata of the tensor.

§device: <R as Runtime>::Device

The device of the tensor.

§dtype: DType

The datatype of the tensor.

§qparams: Option<QParams<QParamTensor>>

Runtime quantization parameters, if applicable

Implementations§

Source§

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

Source

pub fn new( client: ComputeClient<R>, handle: Handle, metadata: Metadata, device: <R as Runtime>::Device, dtype: DType, ) -> CubeTensor<R>

Create a new standard tensor

Source

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

Create a new tensor with a contiguous memory layout.

Source

pub fn to_client( &mut self, client: ComputeClient<R>, device: <R as Runtime>::Device, ) -> CubeTensor<R>

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

Source

pub fn binding(self) -> TensorBinding<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 into_tensor_arg(self) -> TensorArg<R>

Return the reference to a tensor argument.

Source

pub fn into_array_arg(self) -> ArrayArg<R>

Return the reference to an array argument.

Source

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

Returns a reference to the aliased tensor argument.

Source

pub fn into_linear_view(self) -> ViewArg<usize, R>

Return a linear view of this tensor.

Source

pub fn as_linear_view_alias(&self, input_pos: usize) -> ViewArg<usize, R>

Return an aliased linear view of this tensor

Source

pub fn into_linear_view_like( self, reference: &CubeTensor<R>, ) -> ViewArg<usize, R>

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) -> CubeTensor<R>

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: &CubeTensor<R>)

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<R> CubeTensor<R>
where R: CubeRuntime,

Source

pub fn new_quantized( client: ComputeClient<R>, handle: Handle, shape: Shape, device: <R as Runtime>::Device, strides: Strides, dtype: DType, qparams: QParams<QParamTensor>, ) -> CubeTensor<R>

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) -> CubeTensor<R>

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<R> Debug for CubeTensor<R>
where R: CubeRuntime,

Source§

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

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

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

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> TensorMetadata for CubeTensor<R>
where R: CubeRuntime,

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> AutotuneOutput for CubeTensor<R>
where R: CubeRuntime,

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>
where <R as CubeRuntime>::CubeDevice: Unpin,

§

impl<R> UnsafeUnpin 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<C> CloneExpand for C
where C: Clone,

Source§

fn __expand_clone_method(&self, _scope: &mut Scope) -> C

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

Source§

fn downcast(&self) -> &T

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<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<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
Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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