pub struct MatView<'a> { /* private fields */ }Expand description
A read-only alias of part of a tensor.
A view shares the source storage: it neither copies nor extends the source’s lifetime, so it
borrows the tensor it came from and cannot be transferred into an extractor. Submitting one
through Extractor::input copies, because an alias keeps no storage
of its own.
Implementations§
Source§impl MatView<'_>
impl MatView<'_>
Sourcepub fn info(&self) -> TensorInfo
pub fn info(&self) -> TensorInfo
Returns the borrowed tensor metadata.
Sourcepub fn as_mat(&self) -> &Mat
pub fn as_mat(&self) -> &Mat
Borrows the aliased tensor.
The tensor keeps no storage of its own, so it cannot be transferred into an extractor, and
submitting it through Extractor::input copies. The borrowed
form accepts it without a copy: Input::view bounds
the borrow to one request, and
Extractor::input_borrowed carries the lifetime rules
of every other borrowed input, which requires light mode off.
Sourcepub fn as_f32_slice(&self) -> Result<&[f32]>
pub fn as_f32_slice(&self) -> Result<&[f32]>
Borrows contiguous FP32 storage without padding.
Sourcepub fn channel_f32(&self, channel: usize) -> Result<&[f32]>
pub fn channel_f32(&self, channel: usize) -> Result<&[f32]>
Borrows one channel of this region, skipping inter-channel padding.
Sourcepub fn to_f32_into(&self, buffer: &mut Vec<f32>) -> Result<()>
pub fn to_f32_into(&self, buffer: &mut Vec<f32>) -> Result<()>
Replaces the vector contents with logical FP32 elements.
Sourcepub fn deep_clone(&self) -> Result<Mat>
pub fn deep_clone(&self) -> Result<Mat>
Copies the region into a tensor with independent storage.