pub struct TensorData {
pub name: Option<String>,
pub dtype: DataType,
pub dims: Vec<usize>,
pub data: Vec<u8>,
pub strings: Vec<String>,
}Expand description
A concrete constant tensor held inline (e.g. an attribute value or a small initializer). Element bytes are stored little-endian and densely packed.
Large model weights are referenced lazily via WeightRef instead.
Fields§
§name: Option<String>§dtype: DataType§dims: Vec<usize>Static dimensions (constants always have a fully known shape).
data: Vec<u8>Raw little-endian element bytes. Sub-byte values are densely packed
(two 4-bit or four 2-bit elements per byte); for DataType::String
this is empty and strings is used instead.
strings: Vec<String>String payloads for DataType::String tensors.
Implementations§
Source§impl TensorData
impl TensorData
Sourcepub fn from_raw(dtype: DataType, dims: Vec<usize>, data: Vec<u8>) -> Self
pub fn from_raw(dtype: DataType, dims: Vec<usize>, data: Vec<u8>) -> Self
A numeric tensor from raw little-endian bytes.
Sourcepub fn checked_numel(&self) -> Option<usize>
pub fn checked_numel(&self) -> Option<usize>
Number of elements, or None when the dimensions overflow usize.
Sourcepub fn expected_bytes(&self) -> usize
pub fn expected_bytes(&self) -> usize
Expected byte length for numel elements of dtype, accounting for
sub-byte packing.
Sourcepub fn checked_expected_bytes(&self) -> Option<usize>
pub fn checked_expected_bytes(&self) -> Option<usize>
Expected byte length, or None when the element or byte count overflows.
Trait Implementations§
Source§impl Clone for TensorData
impl Clone for TensorData
Source§fn clone(&self) -> TensorData
fn clone(&self) -> TensorData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more