pub struct CubeTensor<R: CubeRuntime> {
pub client: ComputeClient<R>,
pub handle: Handle,
pub meta: Box<Metadata>,
pub device: R::Device,
pub dtype: DType,
pub qparams: Option<QParams>,
}Expand description
The basic tensor primitive struct.
Fields§
§client: ComputeClient<R>Compute client for the runtime.
handle: HandleThe buffer where the data are stored.
meta: Box<Metadata>The metadata of the tensor.
device: R::DeviceThe device of the tensor.
dtype: DTypeThe datatype of the tensor.
qparams: Option<QParams>Runtime quantization parameters, if applicable
Implementations§
Source§impl<R> CubeTensor<R>where
R: CubeRuntime,
impl<R> CubeTensor<R>where
R: CubeRuntime,
Sourcepub fn new(
client: ComputeClient<R>,
handle: Handle,
metadata: Metadata,
device: R::Device,
dtype: DType,
) -> Self
pub fn new( client: ComputeClient<R>, handle: Handle, metadata: Metadata, device: R::Device, dtype: DType, ) -> Self
Create a new standard tensor
Sourcepub fn new_contiguous(
client: ComputeClient<R>,
device: R::Device,
shape: Shape,
handle: Handle,
dtype: DType,
) -> Self
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.
Sourcepub fn to_client(&mut self, client: ComputeClient<R>, device: R::Device) -> Self
pub fn to_client(&mut self, client: ComputeClient<R>, device: R::Device) -> Self
Change the context of the current tensor and return the newly transferred tensor.
Sourcepub fn binding(self) -> TensorBinding<R>
pub fn binding(self) -> TensorBinding<R>
Return the reference to a tensor handle.
Sourcepub fn into_tensor_arg(self) -> TensorArg<R>
pub fn into_tensor_arg(self) -> TensorArg<R>
Return the reference to a tensor argument.
Sourcepub fn into_array_arg(self) -> ArrayArg<R>
pub fn into_array_arg(self) -> ArrayArg<R>
Return the reference to an array argument.
Sourcepub fn as_tensor_alias(&self, input_pos: usize) -> TensorArg<R>
pub fn as_tensor_alias(&self, input_pos: usize) -> TensorArg<R>
Returns a reference to the aliased tensor argument.
Sourcepub fn into_linear_view(self) -> LinearViewLaunch<R>
pub fn into_linear_view(self) -> LinearViewLaunch<R>
Return a linear view of this tensor.
Sourcepub fn as_linear_view_alias(&self, input_pos: usize) -> LinearViewLaunch<R>
pub fn as_linear_view_alias(&self, input_pos: usize) -> LinearViewLaunch<R>
Return an aliased linear view of this tensor
Sourcepub fn into_linear_view_like(self, reference: &Self) -> LinearViewLaunch<R>
pub fn into_linear_view_like(self, reference: &Self) -> LinearViewLaunch<R>
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<R: CubeRuntime> CubeTensor<R>
impl<R: CubeRuntime> CubeTensor<R>
Sourcepub fn new_quantized(
client: ComputeClient<R>,
handle: Handle,
shape: Shape,
device: R::Device,
strides: Strides,
dtype: DType,
qparams: QParams,
) -> Self
pub fn new_quantized( client: ComputeClient<R>, handle: Handle, shape: Shape, device: R::Device, strides: Strides, dtype: DType, qparams: QParams, ) -> Self
Create a new quantized tensor
Sourcepub fn quantized_handles(&self) -> Option<(CubeTensor<R>, CubeTensor<R>)>
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.
Sourcepub fn scales(&self) -> Option<CubeTensor<R>>
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,
impl<R> Clone for CubeTensor<R>where
R: CubeRuntime,
Source§impl<R> Debug for CubeTensor<R>where
R: CubeRuntime,
impl<R> Debug for CubeTensor<R>where
R: CubeRuntime,
Source§impl<R: CubeRuntime> From<CubeTensor<R>> for CubeFusionHandle<R>
Available on crate features fusion only.
impl<R: CubeRuntime> From<CubeTensor<R>> for CubeFusionHandle<R>
fusion only.