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: HandleThe buffer where the data are stored.
shape: ShapeThe shape of the tensor.
device: R::DeviceThe device of the tensor.
strides: Vec<usize>The strides 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,
shape: Shape,
device: R::Device,
strides: Vec<usize>,
dtype: DType,
) -> Self
pub fn new( client: ComputeClient<R>, handle: Handle, shape: Shape, device: R::Device, strides: Vec<usize>, 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(&self, client: ComputeClient<R>, device: R::Device) -> Self
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.
Sourcepub fn as_handle_ref(&self) -> TensorHandleRef<'_, R>
pub fn as_handle_ref(&self) -> TensorHandleRef<'_, R>
Return the reference to a tensor handle.
Sourcepub fn as_tensor_arg<'a>(&'a self, line_size: LineSize) -> TensorArg<'a, R>
pub fn as_tensor_arg<'a>(&'a self, line_size: LineSize) -> TensorArg<'a, R>
Return the reference to a tensor argument.
Sourcepub fn as_array_arg<E: CubeElement>(
&self,
line_size: LineSize,
) -> ArrayArg<'_, R>
pub fn as_array_arg<E: CubeElement>( &self, line_size: LineSize, ) -> ArrayArg<'_, R>
Return the reference to an array argument.
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).
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: Vec<usize>,
dtype: DType,
qparams: QParams,
) -> Self
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
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.