Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate crate for tensor space view #2334

Merged
merged 5 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ re_smart_channel = { path = "crates/re_smart_channel", version = "0.7.0-alpha.0"
re_space_view = { path = "crates/re_space_view", version = "0.7.0-alpha.0", default-features = false }
re_space_view_bar_chart = { path = "crates/re_space_view_bar_chart", version = "0.7.0-alpha.0", default-features = false }
re_space_view_spatial = { path = "crates/re_space_view_spatial", version = "0.7.0-alpha.0", default-features = false }
re_space_view_tensor = { path = "crates/re_space_view_tensor", version = "0.7.0-alpha.0", default-features = false }
re_space_view_text = { path = "crates/re_space_view_text", version = "0.7.0-alpha.0", default-features = false }
re_space_view_text_box = { path = "crates/re_space_view_text_box", version = "0.7.0-alpha.0", default-features = false }
re_space_view_time_series = { path = "crates/re_space_view_time_series", version = "0.7.0-alpha.0", default-features = false }
Expand Down
41 changes: 41 additions & 0 deletions crates/re_space_view_tensor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
authors.workspace = true
description = "A Space View dedicated to visualizing tensors with arbitrary dimensionality."
edition.workspace = true
homepage.workspace = true
license.workspace = true
name = "re_space_view_tensor"
publish = true
readme = "README.md"
repository.workspace = true
rust-version.workspace = true
version.workspace = true
include = ["../../LICENSE-APACHE", "../../LICENSE-MIT", "**/*.rs", "Cargo.toml"]

[package.metadata.docs.rs]
all-features = true

[dependencies]
re_arrow_store.workspace = true
re_components.workspace = true
re_data_store.workspace = true
re_data_ui.workspace = true
re_log_types.workspace = true
re_log.workspace = true
re_renderer.workspace = true
re_space_view.workspace = true
re_tensor_ops.workspace = true
re_tracing.workspace = true
re_ui.workspace = true
re_viewer_context.workspace = true

anyhow.workspace = true
ahash.workspace = true
bytemuck.workspace = true
eframe.workspace = true
egui.workspace = true
half.workspace = true
ndarray.workspace = true
thiserror.workspace = true
vec1.workspace = true
wgpu.workspace = true
11 changes: 11 additions & 0 deletions crates/re_space_view_tensor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# re_space_view_tensor

Part of the [`rerun`](https://github.com/rerun-io/rerun) family of crates.

[![Latest version](https://img.shields.io/crates/v/re_space_view_tensor.svg)](https://crates.io/crates/re_space_view_tensor)
[![Documentation](https://docs.rs/re_space_view_tensor/badge.svg)](https://docs.rs/re_space_view_tensor)
![MIT](https://img.shields.io/badge/license-MIT-blue.svg)
![Apache](https://img.shields.io/badge/license-Apache-blue.svg)

A Space View dedicated to visualizing tensors with arbitrary dimensionality.

10 changes: 10 additions & 0 deletions crates/re_space_view_tensor/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//! Rerun tensor Space View.
//!
//! A Space View dedicated to visualizing tensors with arbitrary dimensionality.

mod scene_part;
mod space_view_class;
mod tensor_dimension_mapper;
mod tensor_slice_to_gpu;

pub use space_view_class::TensorSpaceView;
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
use re_arrow_store::LatestAtQuery;
use re_components::{DecodedTensor, InstanceKey, Tensor};
use re_components::{DecodedTensor, Tensor};
use re_data_store::{EntityPath, EntityProperties, InstancePath};
use re_viewer_context::{SceneQuery, TensorDecodeCache, ViewerContext};
use re_log_types::{Component as _, InstanceKey};
use re_viewer_context::{
ArchetypeDefinition, ScenePart, SceneQuery, SpaceViewClass, SpaceViewHighlights,
TensorDecodeCache, ViewerContext,
};

/// A tensor scene, with everything needed to render it.
use crate::TensorSpaceView;

/// A bar chart scene, with everything needed to render it.
#[derive(Default)]
pub struct SceneTensor {
pub tensors: std::collections::BTreeMap<InstancePath, DecodedTensor>,
}

impl SceneTensor {
/// Loads all tensors into the scene according to the given query.
pub(crate) fn load(&mut self, ctx: &mut ViewerContext<'_>, query: &SceneQuery<'_>) {
impl ScenePart<TensorSpaceView> for SceneTensor {
fn archetype(&self) -> ArchetypeDefinition {
vec1::vec1![Tensor::name()]
}

fn populate(
&mut self,
ctx: &mut ViewerContext<'_>,
query: &SceneQuery<'_>,
_state: &<TensorSpaceView as SpaceViewClass>::State,
_scene_context: &<TensorSpaceView as SpaceViewClass>::Context,
_highlights: &SpaceViewHighlights,
) -> Vec<re_renderer::QueueableDrawData> {
re_tracing::profile_function!();

let store = &ctx.store_db.entity_db.data_store;
Expand All @@ -23,8 +39,12 @@ impl SceneTensor {
self.load_tensor_entity(ctx, ent_path, &props, tensor);
}
}

Vec::new()
}
}

impl SceneTensor {
fn load_tensor_entity(
&mut self,
ctx: &mut ViewerContext<'_>,
Expand Down
Loading