Skip to content

Commit

Permalink
Use buffers for the tensor u8 types
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Feb 22, 2023
1 parent 8c9dc9a commit 92b759c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 2 additions & 4 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ rerun = { path = "crates/rerun", version = "0.2.0" }

anyhow = "1.0"
arrow2 = "0.16"
arrow2_convert = "0.4.2"
# TODO(jleibs): Land upstream: https://github.com/DataEngineeringLabs/arrow2-convert/pull/103
# arrow2_convert = "0.4.2"
arrow2_convert = {git = "https://github.com/rerun-io/arrow2-convert", rev ="3d6e7c07866b13331840"}
clap = "4.0"
comfy-table = { version = "6.1", default-features = false }
derive_more = "0.99"
Expand Down
10 changes: 5 additions & 5 deletions crates/re_log_types/src/component_types/tensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl ArrowDeserialize for TensorId {
#[derive(Clone, Debug, PartialEq, ArrowField, ArrowSerialize, ArrowDeserialize)]
#[arrow_field(type = "dense")]
pub enum TensorData {
U8(Vec<u8>),
U8(Buffer<u8>),
U16(Buffer<u16>),
U32(Buffer<u32>),
U64(Buffer<u64>),
Expand All @@ -169,7 +169,7 @@ pub enum TensorData {
//F16(Vec<arrow2::types::f16>),
F32(Buffer<f32>),
F64(Buffer<f64>),
JPEG(Vec<u8>),
JPEG(Buffer<u8>),
}

/// Flattened `Tensor` data payload
Expand Down Expand Up @@ -624,9 +624,9 @@ impl Tensor {
let (w, h) = (image.width(), image.height());

let (depth, data) = match image {
image::DynamicImage::ImageLuma8(image) => (1, TensorData::U8(image.into_raw())),
image::DynamicImage::ImageRgb8(image) => (3, TensorData::U8(image.into_raw())),
image::DynamicImage::ImageRgba8(image) => (4, TensorData::U8(image.into_raw())),
image::DynamicImage::ImageLuma8(image) => (1, TensorData::U8(image.into_raw().into())),
image::DynamicImage::ImageRgb8(image) => (3, TensorData::U8(image.into_raw().into())),
image::DynamicImage::ImageRgba8(image) => (4, TensorData::U8(image.into_raw().into())),
image::DynamicImage::ImageLuma16(image) => {
(1, TensorData::U16(image.into_raw().into()))
}
Expand Down

0 comments on commit 92b759c

Please sign in to comment.