 |
Ginkgo
Generated from pipelines/2837190956 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
|
5 #ifndef GKO_PUBLIC_CORE_BASE_BATCH_MULTI_VECTOR_HPP_
6 #define GKO_PUBLIC_CORE_BASE_BATCH_MULTI_VECTOR_HPP_
9 #include <initializer_list>
12 #include <ginkgo/core/base/array.hpp>
13 #include <ginkgo/core/base/batch_dim.hpp>
14 #include <ginkgo/core/base/dim.hpp>
15 #include <ginkgo/core/base/executor.hpp>
16 #include <ginkgo/core/base/mtx_io.hpp>
17 #include <ginkgo/core/base/polymorphic_object.hpp>
18 #include <ginkgo/core/base/range_accessors.hpp>
19 #include <ginkgo/core/base/types.hpp>
20 #include <ginkgo/core/base/utils.hpp>
21 #include <ginkgo/core/matrix/dense.hpp>
58 template <
typename ValueType = default_precision>
62 #if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
63 public ConvertibleTo<MultiVector<next_precision<ValueType, 2>>>,
65 #if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
66 public ConvertibleTo<MultiVector<next_precision<ValueType, 3>>>,
68 public ConvertibleTo<MultiVector<next_precision<ValueType>>> {
72 GKO_ASSERT_SUPPORTED_VALUE_TYPE;
80 using value_type = ValueType;
81 using index_type =
int32;
100 #if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
111 #if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
250 return values_.
get_data()[linearize_index(batch_id, row, col)];
259 return values_.
get_const_data()[linearize_index(batch_id, row, col)];
278 return values_.
get_data()[linearize_index(batch_id, idx)];
363 static std::unique_ptr<MultiVector>
create(
364 std::shared_ptr<const Executor> exec,
379 static std::unique_ptr<MultiVector>
create(
380 std::shared_ptr<const Executor> exec,
const batch_dim<2>& size,
387 template <
typename InputValueType>
389 "explicitly construct the gko::array argument instead of passing an "
393 std::initializer_list<InputValueType> values)
412 std::shared_ptr<const Executor> exec,
const batch_dim<2>& sizes,
413 gko::detail::const_array_view<ValueType>&& values);
420 void fill(ValueType value);
437 MultiVector(std::shared_ptr<const Executor> exec,
440 MultiVector(std::shared_ptr<const Executor> exec,
const batch_dim<2>& size,
441 array<value_type> values);
450 std::unique_ptr<MultiVector> create_with_same_config()
const;
466 batch_dim<2> batch_size_;
467 array<value_type> values_;
475 #endif // GKO_PUBLIC_CORE_BASE_BATCH_MULTI_VECTOR_HPP_
size_type get_num_batch_items() const
Get the number of batch items stored.
Definition: batch_dim.hpp:35
dim< dimensionality, dimension_type > get_common_size() const
Get the common size of the batch items.
Definition: batch_dim.hpp:42
value_type & at(size_type batch_id, size_type row, size_type col)
Returns a single element for a particular batch item.
Definition: batch_multi_vector.hpp:247
void scale(ptr_param< const MultiVector< ValueType >> alpha)
Scales the vector with a scalar (aka: BLAS scal).
void add_scaled(ptr_param< const MultiVector< ValueType >> alpha, ptr_param< const MultiVector< ValueType >> b)
Adds b scaled by alpha to the vector (aka: BLAS axpy).
Dense is a matrix format which explicitly stores all values of the matrix.
Definition: dense_cache.hpp:28
size_type get_num_stored_elements() const noexcept
Returns the number of elements explicitly stored in the batch matrix, cumulative across all the batch...
Definition: batch_multi_vector.hpp:218
void compute_dot(ptr_param< const MultiVector< ValueType >> b, ptr_param< MultiVector< ValueType >> result) const
Computes the column-wise dot product of each multi-vector in this batch and its corresponding entry i...
std::unique_ptr< unbatch_type > create_view_for_item(size_type item_id)
Creates a mutable view (of matrix::Dense type) of one item of the Batch MultiVector object.
A PolymorphicObject is the abstract base for all "heavy" objects in Ginkgo that behave polymorphicall...
Definition: polymorphic_object.hpp:46
ValueType at(size_type batch_id, size_type idx) const noexcept
Returns a single element for a particular batch item.
Definition: batch_multi_vector.hpp:284
const value_type * get_const_values_for_item(size_type batch_id) const noexcept
Returns a pointer to the array of values of the multi-vector for a specific batch item.
Definition: batch_multi_vector.hpp:204
value_type * get_values_for_item(size_type batch_id) noexcept
Returns a pointer to the array of values of the multi-vector for a specific batch item.
Definition: batch_multi_vector.hpp:191
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:101
MultiVector stores multiple vectors in a batched fashion and is useful for batched operations.
Definition: batch_multi_vector.hpp:59
void fill(ValueType value)
Fills the input MultiVector with a given value.
ValueType & at(size_type batch_id, size_type idx) noexcept
Returns a single element for a particular batch item.
Definition: batch_multi_vector.hpp:276
The Ginkgo namespace.
Definition: abstract_factory.hpp:19
batch_dim< 2 > get_size() const
Returns the batch size.
Definition: batch_multi_vector.hpp:145
void compute_conj_dot(ptr_param< const MultiVector< ValueType >> b, ptr_param< MultiVector< ValueType >> result) const
Computes the column-wise conjugate dot product of each multi-vector in this batch and its correspondi...
void compute_norm2(ptr_param< MultiVector< remove_complex< ValueType >>> result) const
Computes the Euclidean (L^2) norm of each multi-vector in this batch.
value_type * get_values() noexcept
Returns a pointer to the array of values of the multi-vector.
Definition: batch_multi_vector.hpp:169
value_type at(size_type batch_id, size_type row, size_type col) const
Returns a single element for a particular batch item.
Definition: batch_multi_vector.hpp:256
static std::unique_ptr< const MultiVector > create_const(std::shared_ptr< const Executor > exec, const batch_dim< 2 > &sizes, gko::detail::const_array_view< ValueType > &&values)
Creates a constant (immutable) batch multi-vector from a constant array.
dim< 2 > get_common_size() const
Returns the common size of the batch items.
Definition: batch_multi_vector.hpp:162
std::unique_ptr< const unbatch_type > create_const_view_for_item(size_type item_id) const
Creates a mutable view (of matrix::Dense type) of one item of the Batch MultiVector object.
size_type get_num_batch_items() const
Returns the number of batch items.
Definition: batch_multi_vector.hpp:152
This class is used for function parameters in the place of raw pointers.
Definition: utils_helper.hpp:43
value_type * get_data() noexcept
Returns a pointer to the block of memory used to store the elements of the array.
Definition: array.hpp:686
static std::unique_ptr< MultiVector > create(std::shared_ptr< const Executor > exec, const batch_dim< 2 > &size=batch_dim< 2 >{})
Creates an uninitialized multi-vector of the specified size.
const value_type * get_const_values() const noexcept
Returns a pointer to the array of values of the multi-vector.
Definition: batch_multi_vector.hpp:178
typename detail::find_precision_impl< T, step >::type next_precision
Obtains the next move type of T in the singly-linked precision corresponding bfloat16/half.
Definition: math.hpp:465
typename detail::find_precision_impl< T, -step >::type previous_precision
Obtains the previous move type of T in the singly-linked precision corresponding bfloat16/half.
Definition: math.hpp:472
This mixin is used to enable a default Cloneable::clone() implementation and similar for objects that...
Definition: polymorphic_object.hpp:376
ConvertibleTo interface is used to mark that the implementer can be converted to the object of Result...
Definition: polymorphic_object.hpp:147
std::int32_t int32
32-bit signed integral type.
Definition: types.hpp:118
static std::unique_ptr< MultiVector > create_with_config_of(ptr_param< const MultiVector > other)
Creates a MultiVector with the configuration of another MultiVector.
The first step in using the Ginkgo library consists of creating an executor.
Definition: executor.hpp:615
const value_type * get_const_data() const noexcept
Returns a constant pointer to the block of memory used to store the elements of the array.
Definition: array.hpp:695
size_type get_size() const noexcept
Returns the number of elements in the array.
Definition: array.hpp:669
typename detail::remove_complex_s< T >::type remove_complex
Obtain the type which removed the complex of complex/scalar type or the template parameter of class b...
Definition: math.hpp:263
size_type get_cumulative_offset(size_type batch_id) const
Get the cumulative storage size offset.
Definition: batch_multi_vector.hpp:230
typename detail::to_complex_s< T >::type to_complex
Obtain the type which adds the complex of complex/scalar type or the template parameter of class by a...
Definition: math.hpp:282