Ginkgo
Generated from pipelines/1556235455 branch based on develop. Ginkgo version 1.9.0
A numerical linear algebra library targeting many-core architectures
|
MultiVector stores multiple vectors in a batched fashion and is useful for batched operations. More...
#include <ginkgo/core/base/batch_multi_vector.hpp>
Public Types | |
using | value_type = ValueType |
using | index_type = int32 |
using | unbatch_type = gko::matrix::Dense< ValueType > |
using | absolute_type = remove_complex< MultiVector< ValueType > > |
using | complex_type = to_complex< MultiVector< ValueType > > |
Public Types inherited from gko::EnablePolymorphicAssignment< MultiVector< ValueType > > | |
using | result_type = MultiVector< ValueType > |
Public Types inherited from gko::ConvertibleTo< MultiVector< ValueType > > | |
using | result_type = MultiVector< ValueType > |
Public Types inherited from gko::ConvertibleTo< MultiVector< next_precision< ValueType > > > | |
using | result_type = MultiVector< next_precision< ValueType > > |
Public Member Functions | |
void | convert_to (MultiVector< next_precision< ValueType >> *result) const override |
void | move_to (MultiVector< next_precision< ValueType >> *result) override |
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. More... | |
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. More... | |
batch_dim< 2 > | get_size () const |
Returns the batch size. More... | |
size_type | get_num_batch_items () const |
Returns the number of batch items. More... | |
dim< 2 > | get_common_size () const |
Returns the common size of the batch items. More... | |
value_type * | get_values () noexcept |
Returns a pointer to the array of values of the multi-vector. More... | |
const value_type * | get_const_values () const noexcept |
Returns a pointer to the array of values of the multi-vector. More... | |
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. More... | |
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. More... | |
size_type | get_num_stored_elements () const noexcept |
Returns the number of elements explicitly stored in the batch matrix, cumulative across all the batch items. More... | |
size_type | get_cumulative_offset (size_type batch_id) const |
Get the cumulative storage size offset. More... | |
value_type & | at (size_type batch_id, size_type row, size_type col) |
Returns a single element for a particular batch item. More... | |
value_type | at (size_type batch_id, size_type row, size_type col) const |
Returns a single element for a particular batch item. More... | |
ValueType & | at (size_type batch_id, size_type idx) noexcept |
Returns a single element for a particular batch item. More... | |
ValueType | at (size_type batch_id, size_type idx) const noexcept |
Returns a single element for a particular batch item. More... | |
void | scale (ptr_param< const MultiVector< ValueType >> alpha) |
Scales the vector with a scalar (aka: BLAS scal). More... | |
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). More... | |
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 in b . More... | |
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 corresponding entry in b . More... | |
void | compute_norm2 (ptr_param< MultiVector< remove_complex< ValueType >>> result) const |
Computes the Euclidean (L^2) norm of each multi-vector in this batch. More... | |
void | fill (ValueType value) |
Fills the input MultiVector with a given value. More... | |
Public Member Functions inherited from gko::EnableAbstractPolymorphicObject< MultiVector< ValueType >, PolymorphicObject > | |
std::unique_ptr< MultiVector< ValueType > > | create_default (std::shared_ptr< const Executor > exec) const |
std::unique_ptr< MultiVector< ValueType > > | create_default () const |
std::unique_ptr< MultiVector< ValueType > > | clone (std::shared_ptr< const Executor > exec) const |
std::unique_ptr< MultiVector< ValueType > > | clone () const |
MultiVector< ValueType > * | copy_from (const PolymorphicObject *other) |
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, MultiVector< ValueType > > * | copy_from (std::unique_ptr< Derived > &&other) |
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, MultiVector< ValueType > > * | copy_from (const std::unique_ptr< Derived > &other) |
MultiVector< ValueType > * | copy_from (const std::shared_ptr< const PolymorphicObject > &other) |
MultiVector< ValueType > * | move_from (ptr_param< PolymorphicObject > other) |
MultiVector< ValueType > * | clear () |
Public Member Functions inherited from gko::PolymorphicObject | |
PolymorphicObject & | operator= (const PolymorphicObject &) |
std::unique_ptr< PolymorphicObject > | create_default (std::shared_ptr< const Executor > exec) const |
Creates a new "default" object of the same dynamic type as this object. More... | |
std::unique_ptr< PolymorphicObject > | create_default () const |
Creates a new "default" object of the same dynamic type as this object. More... | |
std::unique_ptr< PolymorphicObject > | clone (std::shared_ptr< const Executor > exec) const |
Creates a clone of the object. More... | |
std::unique_ptr< PolymorphicObject > | clone () const |
Creates a clone of the object. More... | |
PolymorphicObject * | copy_from (const PolymorphicObject *other) |
Copies another object into this object. More... | |
template<typename Derived , typename Deleter > | |
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, PolymorphicObject > * | copy_from (std::unique_ptr< Derived, Deleter > &&other) |
Moves another object into this object. More... | |
template<typename Derived , typename Deleter > | |
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, PolymorphicObject > * | copy_from (const std::unique_ptr< Derived, Deleter > &other) |
Copies another object into this object. More... | |
PolymorphicObject * | copy_from (const std::shared_ptr< const PolymorphicObject > &other) |
Copies another object into this object. More... | |
PolymorphicObject * | move_from (ptr_param< PolymorphicObject > other) |
Moves another object into this object. More... | |
PolymorphicObject * | clear () |
Transforms the object into its default state. More... | |
std::shared_ptr< const Executor > | get_executor () const noexcept |
Returns the Executor of the object. More... | |
Public Member Functions inherited from gko::log::EnableLogging< PolymorphicObject > | |
void | add_logger (std::shared_ptr< const Logger > logger) override |
void | remove_logger (const Logger *logger) override |
void | remove_logger (ptr_param< const Logger > logger) |
const std::vector< std::shared_ptr< const Logger > > & | get_loggers () const override |
void | clear_loggers () override |
Public Member Functions inherited from gko::log::Loggable | |
void | remove_logger (ptr_param< const Logger > logger) |
Public Member Functions inherited from gko::EnablePolymorphicAssignment< MultiVector< ValueType > > | |
void | convert_to (result_type *result) const override |
Converts the implementer to an object of type result_type. More... | |
void | move_to (result_type *result) override |
Converts the implementer to an object of type result_type by moving data from this object. More... | |
Public Member Functions inherited from gko::ConvertibleTo< MultiVector< ValueType > > | |
void | convert_to (ptr_param< result_type > result) const |
void | move_to (ptr_param< result_type > result) |
Public Member Functions inherited from gko::ConvertibleTo< MultiVector< next_precision< ValueType > > > | |
virtual void | convert_to (result_type *result) const=0 |
Converts the implementer to an object of type result_type. More... | |
void | convert_to (ptr_param< result_type > result) const |
virtual void | move_to (result_type *result)=0 |
Converts the implementer to an object of type result_type by moving data from this object. More... | |
void | move_to (ptr_param< result_type > result) |
Static Public Member Functions | |
static std::unique_ptr< MultiVector > | create_with_config_of (ptr_param< const MultiVector > other) |
Creates a MultiVector with the configuration of another MultiVector. More... | |
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. More... | |
static std::unique_ptr< MultiVector > | create (std::shared_ptr< const Executor > exec, const batch_dim< 2 > &size, array< value_type > values) |
Creates a MultiVector from an already allocated (and initialized) array. More... | |
template<typename InputValueType > | |
static std::unique_ptr< MultiVector > | create (std::shared_ptr< const Executor > exec, const batch_dim< 2 > &size, std::initializer_list< InputValueType > values) |
create(std::shared_ptr<const More... | |
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. More... | |
Friends | |
class | EnablePolymorphicObject< MultiVector > |
class | MultiVector< to_complex< ValueType > > |
class | MultiVector< next_precision< ValueType > > |
MultiVector stores multiple vectors in a batched fashion and is useful for batched operations.
For example, if you want to store two batch items with multi-vectors of size (3 x 2) given below:
[1 2 ; 3 4 1 2 ; 3 4 1 2 ; 3 4]
In memory, they would be stored as a single array: [1 2 1 2 1 2 3 4 3 4 3 4].
Access functions @at can help access individual item if necessary.
The values of the different batch items are stored consecutively and in each batch item, the multi-vectors are stored in a row-major fashion.
ValueType | precision of multi-vector elements |
void gko::batch::MultiVector< ValueType >::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).
alpha | the scalar |
b | a multi-vector of the same dimension as this |
|
inlinenoexcept |
Returns a single element for a particular batch item.
batch_id | the batch item index to be queried |
row | the row of the requested element |
col | the column of the requested element |
References gko::array< ValueType >::get_const_data().
|
inlinenoexcept |
Returns a single element for a particular batch item.
Useful for iterating across all elements of the vector. However, it is less efficient than the two-parameter variant of this method.
batch_id | the batch item index to be queried |
idx | a linear index of the requested element |
References gko::array< ValueType >::get_data().
|
inline |
Returns a single element for a particular batch item.
batch_id | the batch item index to be queried |
row | the row of the requested element |
col | the column of the requested element |
References gko::array< ValueType >::get_data(), and gko::batch::MultiVector< ValueType >::get_num_batch_items().
|
inline |
Returns a single element for a particular batch item.
batch_id | the batch item index to be queried |
row | the row of the requested element |
col | the column of the requested element |
References gko::array< ValueType >::get_const_data(), and gko::batch::MultiVector< ValueType >::get_num_batch_items().
void gko::batch::MultiVector< ValueType >::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 corresponding entry in b
.
If the vector has complex value_type, then the conjugate of this is taken.
b | a MultiVector of same dimension as this |
result | a MultiVector row vector, used to store the dot product (the number of column in the vector must match the number of columns of this) |
void gko::batch::MultiVector< ValueType >::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 in b
.
b | a MultiVector of same dimension as this |
result | a MultiVector row vector, used to store the dot product |
void gko::batch::MultiVector< ValueType >::compute_norm2 | ( | ptr_param< MultiVector< remove_complex< ValueType >>> | result | ) | const |
Computes the Euclidean (L^2) norm of each multi-vector in this batch.
result | a MultiVector, used to store the norm (the number of columns in the vector must match the number of columns of this) |
|
static |
Creates a MultiVector from an already allocated (and initialized) array.
exec | Executor associated to the vector |
size | sizes of the batch matrices in a batch_dim object |
values | array of values |
values
is not an rvalue, not an array of ValueType, or is on the wrong executor, an internal copy will be created, and the original array data will not be used in the vector.
|
inlinestatic |
create(std::shared_ptr<const
create(std::shared_ptr<const executor>="">, const batch_dim<2>&, array<value_type>)
References gko::batch::MultiVector< ValueType >::create().
|
static |
Creates an uninitialized multi-vector of the specified size.
exec | Executor associated to the vector |
size | size of the batch multi vector |
Referenced by gko::batch::MultiVector< ValueType >::create().
|
static |
Creates a constant (immutable) batch multi-vector from a constant array.
exec | the executor to create the vector on |
size | the dimensions of the vector |
values | the value array of the vector |
stride | the row-stride of the vector |
std::unique_ptr<const unbatch_type> gko::batch::MultiVector< ValueType >::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.
Does not perform any deep copies, but only returns a view of the data.
item_id | The index of the batch item |
std::unique_ptr<unbatch_type> gko::batch::MultiVector< ValueType >::create_view_for_item | ( | size_type | item_id | ) |
Creates a mutable view (of matrix::Dense type) of one item of the Batch MultiVector object.
Does not perform any deep copies, but only returns a view of the data.
item_id | The index of the batch item |
|
static |
Creates a MultiVector with the configuration of another MultiVector.
other | The other multi-vector whose configuration needs to copied. |
void gko::batch::MultiVector< ValueType >::fill | ( | ValueType | value | ) |
Fills the input MultiVector with a given value.
value | the value to be filled |
|
inline |
Returns the common size of the batch items.
References gko::batch_dim< Dimensionality, DimensionType >::get_common_size().
Referenced by gko::batch::MultiVector< ValueType >::get_cumulative_offset(), and gko::batch::BatchLinOp::validate_application_parameters().
|
inlinenoexcept |
Returns a pointer to the array of values of the multi-vector.
References gko::array< ValueType >::get_const_data().
|
inlinenoexcept |
Returns a pointer to the array of values of the multi-vector for a specific batch item.
batch_id | the id of the batch item. |
References gko::array< ValueType >::get_const_data(), gko::batch::MultiVector< ValueType >::get_cumulative_offset(), and gko::batch::MultiVector< ValueType >::get_num_batch_items().
|
inline |
Get the cumulative storage size offset.
batch_id | the batch id |
References gko::batch::MultiVector< ValueType >::get_common_size().
Referenced by gko::batch::MultiVector< ValueType >::get_const_values_for_item(), and gko::batch::MultiVector< ValueType >::get_values_for_item().
|
inline |
Returns the number of batch items.
References gko::batch_dim< Dimensionality, DimensionType >::get_num_batch_items().
Referenced by gko::batch::MultiVector< ValueType >::at(), gko::batch::MultiVector< ValueType >::get_const_values_for_item(), gko::batch::MultiVector< ValueType >::get_values_for_item(), and gko::batch::BatchLinOp::validate_application_parameters().
|
inlinenoexcept |
Returns the number of elements explicitly stored in the batch matrix, cumulative across all the batch items.
References gko::array< ValueType >::get_size().
|
inline |
Returns the batch size.
|
inlinenoexcept |
Returns a pointer to the array of values of the multi-vector.
References gko::array< ValueType >::get_data().
|
inlinenoexcept |
Returns a pointer to the array of values of the multi-vector for a specific batch item.
batch_id | the id of the batch item. |
References gko::batch::MultiVector< ValueType >::get_cumulative_offset(), gko::array< ValueType >::get_data(), and gko::batch::MultiVector< ValueType >::get_num_batch_items().
void gko::batch::MultiVector< ValueType >::scale | ( | ptr_param< const MultiVector< ValueType >> | alpha | ) |
Scales the vector with a scalar (aka: BLAS scal).
alpha | the scalar |