Struct re_types::archetypes::Tensor
source · pub struct Tensor {
pub data: TensorData,
}
Expand description
Archetype: A generic n-dimensional Tensor.
§Example
§Simple tensor
ⓘ
use ndarray::{Array, ShapeBuilder};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let rec = rerun::RecordingStreamBuilder::new("rerun_example_tensor").spawn()?;
let mut data = Array::<u8, _>::default((8, 6, 3, 5).f());
data.map_inplace(|x| *x = rand::random());
let tensor =
rerun::Tensor::try_from(data)?.with_dim_names(["width", "height", "channel", "batch"]);
rec.log("tensor", &tensor)?;
Ok(())
}
Fields§
§data: TensorData
The tensor data
Implementations§
source§impl Tensor
impl Tensor
sourcepub const NUM_COMPONENTS: usize = 2usize
pub const NUM_COMPONENTS: usize = 2usize
The total number of components in the archetype: 1 required, 1 recommended, 0 optional
source§impl Tensor
impl Tensor
sourcepub fn data(&self) -> &TensorData
pub fn data(&self) -> &TensorData
Accessor to the underlying TensorData
.
sourcepub fn try_from<T: TryInto<TensorData>>(data: T) -> Result<Self, T::Error>
pub fn try_from<T: TryInto<TensorData>>(data: T) -> Result<Self, T::Error>
Try to construct a Tensor
from anything that can be converted into TensorData
This is useful for constructing a tensor from an ndarray.
sourcepub fn with_dim_names(
self,
names: impl IntoIterator<Item = impl Into<ArrowString>>
) -> Self
pub fn with_dim_names( self, names: impl IntoIterator<Item = impl Into<ArrowString>> ) -> Self
Update the names
of the contained TensorData
dimensions.
Any existing Dimension names will be overwritten.
If too many, or too few names are provided, this function will warn and only update the subset of names that it can.
Trait Implementations§
source§impl Archetype for Tensor
impl Archetype for Tensor
§type Indicator = GenericIndicatorComponent<Tensor>
type Indicator = GenericIndicatorComponent<Tensor>
The associated indicator component, whose presence indicates that the high-level
archetype-based APIs were used to log the data. Read more
source§fn name() -> ArchetypeName
fn name() -> ArchetypeName
The fully-qualified name of this archetype, e.g.
rerun.archetypes.Points2D
.source§fn indicator() -> MaybeOwnedComponentBatch<'static>
fn indicator() -> MaybeOwnedComponentBatch<'static>
source§fn required_components() -> Cow<'static, [ComponentName]>
fn required_components() -> Cow<'static, [ComponentName]>
Returns the names of all components that must be provided by the user when constructing
this archetype.
source§fn recommended_components() -> Cow<'static, [ComponentName]>
fn recommended_components() -> Cow<'static, [ComponentName]>
Returns the names of all components that should be provided by the user when constructing
this archetype.
source§fn optional_components() -> Cow<'static, [ComponentName]>
fn optional_components() -> Cow<'static, [ComponentName]>
Returns the names of all components that may be provided by the user when constructing
this archetype.
source§fn all_components() -> Cow<'static, [ComponentName]>
fn all_components() -> Cow<'static, [ComponentName]>
Returns the names of all components that must, should and may be provided by the user when
constructing this archetype. Read more
source§fn from_arrow_components(
arrow_data: impl IntoIterator<Item = (ComponentName, Box<dyn Array>)>
) -> DeserializationResult<Self>
fn from_arrow_components( arrow_data: impl IntoIterator<Item = (ComponentName, Box<dyn Array>)> ) -> DeserializationResult<Self>
Given an iterator of Arrow arrays and their respective
ComponentNames
, deserializes them
into this archetype. Read moresource§fn from_arrow(
data: impl IntoIterator<Item = (Field, Box<dyn Array>)>
) -> Result<Self, DeserializationError>where
Self: Sized,
fn from_arrow(
data: impl IntoIterator<Item = (Field, Box<dyn Array>)>
) -> Result<Self, DeserializationError>where
Self: Sized,
Given an iterator of Arrow arrays and their respective field metadata, deserializes them
into this archetype. Read more
source§impl AsComponents for Tensor
impl AsComponents for Tensor
source§fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
Exposes the object’s contents as a set of
ComponentBatch
s. Read moresource§impl PartialEq for Tensor
impl PartialEq for Tensor
source§impl SizeBytes for Tensor
impl SizeBytes for Tensor
source§fn heap_size_bytes(&self) -> u64
fn heap_size_bytes(&self) -> u64
Returns the total size of
self
on the heap, in bytes.source§fn total_size_bytes(&self) -> u64
fn total_size_bytes(&self) -> u64
Returns the total size of
self
in bytes, accounting for both stack and heap space.source§fn stack_size_bytes(&self) -> u64
fn stack_size_bytes(&self) -> u64
Returns the total size of
self
on the stack, in bytes. Read moreimpl StructuralPartialEq for Tensor
Auto Trait Implementations§
impl Freeze for Tensor
impl RefUnwindSafe for Tensor
impl Send for Tensor
impl Sync for Tensor
impl Unpin for Tensor
impl UnwindSafe for Tensor
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more