pub fn stack_tensor3d(
tensors: &[ArrayBase<OwnedRepr<f32>, Dim<[usize; 3]>>],
) -> Result<ArrayBase<OwnedRepr<f32>, Dim<[usize; 4]>>, OCRError>Expand description
Stacks a slice of 3D tensors into a single 4D tensor.
§Arguments
tensors- A slice of 3D tensors to stack.
§Returns
Ok(Tensor4D)- A 4D tensor created by stacking the input tensors.Err(OCRError)- An error if the input tensors are invalid (e.g., empty, inconsistent shapes).
§Examples
use oar_ocr_core::utils::tensor::{stack_tensor3d, vec_to_tensor3d};
// Create tensors first
let data1 = vec![vec![vec![1.0, 2.0], vec![3.0, 4.0]]];
let data2 = vec![vec![vec![5.0, 6.0], vec![7.0, 8.0]]];
let tensor1 = vec_to_tensor3d(&data1)?;
let tensor2 = vec_to_tensor3d(&data2)?;
let tensors = vec![tensor1, tensor2];
let stacked_tensor = stack_tensor3d(&tensors)?;