clone#
Clone one or more dimensions of an operator to a higher rank
-
template<int Rank, typename Op>
auto __MATX_INLINE__ matx::clone(const Op &t, const index_t (&shape)[Rank])#
-
template<std::size_t Rank, typename Op>
auto __MATX_INLINE__ matx::clone(const Op &t, const cuda::std::array<index_t, Rank> &shape)# Operator to clone an operator or tensor across dimensions.
- Template Parameters:
Rank – the rank of the cloned operator
T – source operator/tensor type
- Parameters:
t – source operator/tensor
shape – the shape of the cloned operator/tensor. Each element is either the size of the cloned dimension or
matxKeepDim
to be from the source tensor
- Returns:
operator to compute the cloned value
Examples#
auto tiv = make_tensor<TestType>({});
auto tov = make_tensor<TestType>({N,M,K});
tiv() = 3;
// Clone "tiv" from a 0D tensor to a 3D tensor
auto op = clone<3>(tiv, {N, M, K});
auto tiv = make_tensor<TestType>({K});
auto tov = make_tensor<TestType>({N,M,K});
for(int k = 0; k < K; k++) {
tiv(k) = static_cast<typename inner_op_type_t<TestType>::type>(k);
}
// Clone "tiv" from a 1D tensor to a 3D tensor
// matxKeepDim is used to indicate where the 1D tensor should be placed in the 3D tensor
auto op = clone<3>(tiv, {N, M, matxKeepDim});