Skip to content

Commit

Permalink
Shorten function name
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Apr 13, 2023
1 parent 42a4add commit 9058f62
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions crates/re_viewer/src/ui/view_tensor/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,20 @@ fn texture_desc_from_tensor(
match tensor.dtype() {
TensorDataType::U8 => {
let tensor = ndarray::ArrayViewD::<u8>::try_from(tensor)?;
texture_desc_from_tensor_slice(&tensor, slice_selection, TextureFormat::R8Uint, |x| x)
to_texture_desc(&tensor, slice_selection, TextureFormat::R8Uint, |x| x)
}
TensorDataType::U16 => {
let tensor = ndarray::ArrayViewD::<u16>::try_from(tensor)?;
texture_desc_from_tensor_slice(&tensor, slice_selection, TextureFormat::R16Uint, |x| x)
to_texture_desc(&tensor, slice_selection, TextureFormat::R16Uint, |x| x)
}
TensorDataType::U32 => {
let tensor = ndarray::ArrayViewD::<u32>::try_from(tensor)?;
texture_desc_from_tensor_slice(&tensor, slice_selection, TextureFormat::R32Uint, |x| x)
to_texture_desc(&tensor, slice_selection, TextureFormat::R32Uint, |x| x)
}
TensorDataType::U64 => {
// narrow to f32:
let tensor = ndarray::ArrayViewD::<u64>::try_from(tensor)?;
texture_desc_from_tensor_slice(
to_texture_desc(
&tensor,
slice_selection,
TextureFormat::R32Float,
Expand All @@ -107,20 +107,20 @@ fn texture_desc_from_tensor(
}
TensorDataType::I8 => {
let tensor = ndarray::ArrayViewD::<i8>::try_from(tensor)?;
texture_desc_from_tensor_slice(&tensor, slice_selection, TextureFormat::R8Sint, |x| x)
to_texture_desc(&tensor, slice_selection, TextureFormat::R8Sint, |x| x)
}
TensorDataType::I16 => {
let tensor = ndarray::ArrayViewD::<i16>::try_from(tensor)?;
texture_desc_from_tensor_slice(&tensor, slice_selection, TextureFormat::R16Sint, |x| x)
to_texture_desc(&tensor, slice_selection, TextureFormat::R16Sint, |x| x)
}
TensorDataType::I32 => {
let tensor = ndarray::ArrayViewD::<i32>::try_from(tensor)?;
texture_desc_from_tensor_slice(&tensor, slice_selection, TextureFormat::R32Sint, |x| x)
to_texture_desc(&tensor, slice_selection, TextureFormat::R32Sint, |x| x)
}
TensorDataType::I64 => {
// narrow to f32:
let tensor = ndarray::ArrayViewD::<i64>::try_from(tensor)?;
texture_desc_from_tensor_slice(
to_texture_desc(
&tensor,
slice_selection,
TextureFormat::R32Float,
Expand All @@ -129,16 +129,16 @@ fn texture_desc_from_tensor(
}
TensorDataType::F16 => {
let tensor = ndarray::ArrayViewD::<half::f16>::try_from(tensor)?;
texture_desc_from_tensor_slice(&tensor, slice_selection, TextureFormat::R16Float, |x| x)
to_texture_desc(&tensor, slice_selection, TextureFormat::R16Float, |x| x)
}
TensorDataType::F32 => {
let tensor = ndarray::ArrayViewD::<f32>::try_from(tensor)?;
texture_desc_from_tensor_slice(&tensor, slice_selection, TextureFormat::R32Float, |x| x)
to_texture_desc(&tensor, slice_selection, TextureFormat::R32Float, |x| x)
}
TensorDataType::F64 => {
// narrow to f32:
let tensor = ndarray::ArrayViewD::<f64>::try_from(tensor)?;
texture_desc_from_tensor_slice(
to_texture_desc(
&tensor,
slice_selection,
TextureFormat::R32Float,
Expand All @@ -148,7 +148,7 @@ fn texture_desc_from_tensor(
}
}

fn texture_desc_from_tensor_slice<From: Copy, To: bytemuck::Pod>(
fn to_texture_desc<From: Copy, To: bytemuck::Pod>(
tensor: &ndarray::ArrayViewD<'_, From>,
slice_selection: &SliceSelection,
format: wgpu::TextureFormat,
Expand Down

0 comments on commit 9058f62

Please sign in to comment.