Trait dfdx::tensor_ops::TryConcatAlong
source · pub trait TryConcatAlong<Ax>: Sized {
type Output;
type Error: Debug;
// Required method
fn try_concat_along(self, ax: Ax) -> Result<Self::Output, Self::Error>;
// Provided method
fn concat_along(self, ax: Ax) -> Self::Output { ... }
}
Expand description
Concatenate two tensors along a given axis.
Pytorch equivalent torch.concat
.
Const dims requires nightly
Along Axis 0:
ⓘ
let a: Tensor<Rank2<3, 4>, f32, _> = dev.zeros();
let b: Tensor<Rank2<3, 4>, f32, _> = dev.zeros();
let _: Tensor<Rank2<6, 4>, f32, _> = (a, b).concat_along(Axis::<0>);
Along Axis 1:
ⓘ
let a: Tensor<Rank2<3, 4>, f32, _> = dev.zeros();
let b: Tensor<Rank2<3, 4>, f32, _> = dev.zeros();
let _: Tensor<Rank2<3, 8>, f32, _> = (a, b).concat_along(Axis::<1>);
usize dims
Along Axis 0:
let a: Tensor<(usize, Const<3>), f32, _> = dev.zeros_like(&(2, Const));
let b: Tensor<(usize, Const<3>), f32, _> = dev.zeros_like(&(4, Const));
let _: Tensor<Rank2<6, 3>, f32, _> = (a, b).concat_along(Axis::<0>).realize();
Along Axis 1:
let a: Tensor<(Const<2>, usize), f32, _> = dev.zeros_like(&(Const, 2));
let b: Tensor<(Const<2>, usize), f32, _> = dev.zeros_like(&(Const, 4));
let _: Tensor<Rank2<2, 6>, f32, _> = (a, b).concat_along(Axis::<1>).realize();
Required Associated Types§
Required Methods§
sourcefn try_concat_along(self, ax: Ax) -> Result<Self::Output, Self::Error>
fn try_concat_along(self, ax: Ax) -> Result<Self::Output, Self::Error>
Fallibly concatenates self along the given axis.
Provided Methods§
sourcefn concat_along(self, ax: Ax) -> Self::Output
fn concat_along(self, ax: Ax) -> Self::Output
Concatenates self along the given axis.