ones#
Generate an operator of ones
-
template<typename T = int, typename ShapeType, std::enable_if_t<!std::is_array_v<typename remove_cvref<ShapeType>::type>, bool> = true>
inline auto matx::ones(ShapeType &&s)# Return one for all elements
Ones is used as an operator that always returns a 1 type for all elements. It can be used in place of memset to set all values to 1.
- Template Parameters:
T – Data type
- Parameters:
s – Shape of tensor
-
template<typename T = int, int RANK>
inline auto matx::ones(const index_t (&s)[RANK])# Return one for all elements
Ones is used as an operator that always returns a 1 type for all elements. It can be used in place of memset to set all values to 1.
- Template Parameters:
T – Data type
- Parameters:
s – Shape of tensor
Examples#
index_t count = 100;
cuda::std::array<index_t, 1> s({count});
auto t1 = make_tensor<TestType>(s);
(t1 = ones()).run(exec);