Trait TensorMetadata
pub trait TensorMetadata:
Clone
+ Send
+ Sync
+ Debug {
type Device: DeviceOps;
// Required methods
fn dtype(&self) -> DType;
fn shape(&self) -> Shape;
fn device(&self) -> Self::Device;
fn can_mut(&self) -> bool;
// Provided methods
fn rank(&self) -> usize { ... }
fn scheme(&self) -> QuantScheme { ... }
}Expand description
Tensor metadata trait for tensor primitive.
Required Associated Types§
Required Methods§
fn can_mut(&self) -> bool
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.
Backends that track buffer ownership (cubecl, fusion, tch) answer
precisely; a backend that can’t must return a conservative false —
the buffer may be aliased, so an in-place write can’t be assumed safe.
Provided Methods§
fn scheme(&self) -> QuantScheme
fn scheme(&self) -> QuantScheme
Get the quantization scheme for a quantized float tensor.
§Panics
Panics if the tensor is not quantized.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".