pub fn cat<T, C>(
_ctx: &mut C,
tensors: &[&Tensor<T>],
axis: usize,
) -> Result<Tensor<T>>where
T: Scalar,
C: TensorMetadataContextFor,Expand description
Concatenate tensors along an existing dimension.
The context parameter enables future GPU-backend dispatch. Currently
delegates to Tensor::cat.
§Errors
Returns an error if tensors have incompatible shapes, the axis is out of range, or the tensor list is empty.
§Examples
ⓘ
use tenferro_device::LogicalMemorySpace;
use tenferro_prims::{tensor_ops, CpuContext};
use tenferro_tensor::{MemoryOrder, Tensor};
let mut ctx = CpuContext::new(1);
let a = Tensor::<f64>::zeros(
&[2, 3],
LogicalMemorySpace::MainMemory,
MemoryOrder::ColumnMajor,
).unwrap();
let b = Tensor::<f64>::zeros(
&[2, 4],
LogicalMemorySpace::MainMemory,
MemoryOrder::ColumnMajor,
).unwrap();
let result = tensor_ops::cat(&mut ctx, &[&a, &b], 1).unwrap();
assert_eq!(result.dims(), &[2, 7]);