-
Notifications
You must be signed in to change notification settings - Fork 692
Expand file tree
/
Copy pathlib.rs
More file actions
45 lines (39 loc) · 1.16 KB
/
lib.rs
File metadata and controls
45 lines (39 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Rerun tensor view.
//!
//! A view dedicated to visualizing tensors with arbitrary dimensionality.
mod dimension_mapping;
mod tensor_dimension_mapper;
mod tensor_slice_hover;
mod tensor_slice_to_gpu;
mod view_class;
mod visualizer_system;
pub use view_class::TensorView;
/// Information about a dimension of a tensor.
struct TensorDimension {
pub size: u64,
pub name: Option<re_sdk_types::ArrowString>,
}
impl TensorDimension {
pub fn from_tensor_data(tensor_data: &re_sdk_types::datatypes::TensorData) -> Vec<Self> {
tensor_data
.shape
.iter()
.enumerate()
.map(|(dim_idx, dim_len)| Self {
size: *dim_len,
name: tensor_data.dim_name(dim_idx).cloned(),
})
.collect()
}
#[cfg_attr(not(test), expect(dead_code))] // only used in tests
pub fn unnamed(size: u64) -> Self {
Self { size, name: None }
}
#[cfg_attr(not(test), expect(dead_code))] // only used in tests
pub fn named(size: u64, name: impl Into<re_sdk_types::ArrowString>) -> Self {
Self {
size,
name: Some(name.into()),
}
}
}