 |
Ginkgo
Generated from pipelines/2017069469 branch based on develop. Ginkgo version 1.11.0
A numerical linear algebra library targeting many-core architectures
|
5 #ifndef GKO_PUBLIC_CORE_MATRIX_BATCH_ELL_HPP_
6 #define GKO_PUBLIC_CORE_MATRIX_BATCH_ELL_HPP_
9 #include <initializer_list>
12 #include <ginkgo/core/base/array.hpp>
13 #include <ginkgo/core/base/batch_lin_op.hpp>
14 #include <ginkgo/core/base/batch_multi_vector.hpp>
15 #include <ginkgo/core/base/executor.hpp>
16 #include <ginkgo/core/base/mtx_io.hpp>
17 #include <ginkgo/core/base/range_accessors.hpp>
18 #include <ginkgo/core/base/types.hpp>
19 #include <ginkgo/core/base/utils.hpp>
20 #include <ginkgo/core/base/utils_helper.hpp>
21 #include <ginkgo/core/matrix/ell.hpp>
51 template <
typename ValueType = default_precision,
typename IndexType =
int32>
54 #if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
55 public ConvertibleTo<Ell<next_precision<ValueType, 2>, IndexType>>,
57 #if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
58 public ConvertibleTo<Ell<next_precision<ValueType, 3>, IndexType>>,
60 public ConvertibleTo<Ell<next_precision<ValueType>, IndexType>> {
64 static_assert(std::is_same<IndexType, int32>::value,
65 "IndexType must be a 32 bit integer");
71 using value_type = ValueType;
72 using index_type = IndexType;
82 #if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
94 #if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
170 return num_elems_per_row_;
205 GKO_ASSERT(batch_id < this->get_num_batch_items());
219 GKO_ASSERT(batch_id < this->get_num_batch_items());
233 GKO_ASSERT(batch_id < this->get_num_batch_items());
248 GKO_ASSERT(batch_id < this->get_num_batch_items());
262 static std::unique_ptr<Ell>
create(
263 std::shared_ptr<const Executor> exec,
265 const IndexType num_elems_per_row = 0);
283 static std::unique_ptr<Ell>
create(std::shared_ptr<const Executor> exec,
285 const IndexType num_elems_per_row,
294 template <
typename InputValueType,
typename ColIndexType>
296 "explicitly construct the gko::array arguments instead of passing "
300 const IndexType num_elems_per_row,
301 std::initializer_list<InputValueType> values,
302 std::initializer_list<ColIndexType> col_idxs)
304 return create(exec, size, num_elems_per_row,
326 std::shared_ptr<const Executor> exec,
const batch_dim<2>& sizes,
327 const index_type num_elems_per_row,
328 gko::detail::const_array_view<value_type>&& values,
329 gko::detail::const_array_view<index_type>&& col_idxs);
396 IndexType num_elems_per_row)
402 Ell(std::shared_ptr<const Executor> exec,
404 const IndexType num_elems_per_row = 0);
406 Ell(std::shared_ptr<const Executor> exec,
const batch_dim<2>& size,
410 void apply_impl(
const MultiVector<value_type>* b,
411 MultiVector<value_type>* x)
const;
413 void apply_impl(
const MultiVector<value_type>* alpha,
414 const MultiVector<value_type>* b,
415 const MultiVector<value_type>* beta,
416 MultiVector<value_type>* x)
const;
418 index_type num_elems_per_row_;
429 #endif // GKO_PUBLIC_CORE_MATRIX_BATCH_ELL_HPP_
The EnableBatchLinOp mixin can be used to provide sensible default implementations of the majority of...
Definition: batch_lin_op.hpp:250
index_type get_num_stored_elements_per_row() const noexcept
Returns the number of elements per row explicitly stored.
Definition: batch_ell.hpp:168
size_type get_num_batch_items() const
Get the number of batch items stored.
Definition: batch_dim.hpp:36
dim< dimensionality, dimension_type > get_common_size() const
Get the common size of the batch items.
Definition: batch_dim.hpp:43
value_type * get_values() noexcept
Returns a pointer to the array of values of the matrix.
Definition: batch_ell.hpp:129
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_ell.hpp:180
Ell is a sparse matrix format that stores the same number of nonzeros in each row,...
Definition: batch_ell.hpp:52
Definition: batch_lin_op.hpp:59
void scale(const array< value_type > &row_scale, const array< value_type > &col_scale)
Performs in-place row and column scaling for this matrix.
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:90
value_type * get_values_for_item(size_type batch_id) noexcept
Returns a pointer to the array of values of the matrix for a specific batch item.
Definition: batch_ell.hpp:231
index_type * get_col_idxs_for_item(size_type batch_id) noexcept
Returns a pointer to the array of col_idxs of the matrix.
Definition: batch_ell.hpp:203
MultiVector stores multiple vectors in a batched fashion and is useful for batched operations.
Definition: batch_multi_vector.hpp:52
const value_type * get_const_values_for_item(size_type batch_id) const noexcept
Returns a pointer to the array of values of the matrix for a specific batch item.
Definition: batch_ell.hpp:245
const index_type * get_const_col_idxs() const noexcept
Returns a pointer to the array of column indices of the matrix.
Definition: batch_ell.hpp:157
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
std::unique_ptr< unbatch_type > create_view_for_item(size_type item_id)
Creates a mutable view (of matrix::Ell type) of one item of the batch::matrix::Ell<value_type> object...
index_type * get_col_idxs() noexcept
Returns a pointer to the array of column indices of the matrix.
Definition: batch_ell.hpp:148
void add_scaled_identity(ptr_param< const MultiVector< value_type >> alpha, ptr_param< const MultiVector< value_type >> beta)
Performs the operation this = alpha*I + beta*this.
static std::unique_ptr< Ell > create(std::shared_ptr< const Executor > exec, const batch_dim< 2 > &size=batch_dim< 2 >{}, const IndexType num_elems_per_row=0)
Creates an uninitialized Ell matrix of the specified size.
This class is used for function parameters in the place of raw pointers.
Definition: utils_helper.hpp:41
Ell * apply(ptr_param< const MultiVector< value_type >> b, ptr_param< MultiVector< value_type >> x)
Apply the matrix to a multi-vector.
value_type * get_data() noexcept
Returns a pointer to the block of memory used to store the elements of the array.
Definition: array.hpp:687
static std::unique_ptr< const Ell > create_const(std::shared_ptr< const Executor > exec, const batch_dim< 2 > &sizes, const index_type num_elems_per_row, gko::detail::const_array_view< value_type > &&values, gko::detail::const_array_view< index_type > &&col_idxs)
Creates a constant (immutable) batch ell matrix from a constant array.
const index_type * get_const_col_idxs_for_item(size_type batch_id) const noexcept
Returns a pointer to the array of col_idxs of the matrix.
Definition: batch_ell.hpp:216
size_type get_num_elements_per_item() const noexcept
Returns the number of stored elements in each batch item.
Definition: batch_ell.hpp:190
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:466
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:473
ELL is a matrix format where stride with explicit zeros is used such that all rows have the same numb...
Definition: csr.hpp:31
ConvertibleTo interface is used to mark that the implementer can be converted to the object of Result...
Definition: polymorphic_object.hpp:479
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:696
size_type get_size() const noexcept
Returns the number of elements in the array.
Definition: array.hpp:670
std::unique_ptr< const unbatch_type > create_const_view_for_item(size_type item_id) const
Creates a mutable view (of matrix::Ell type) of one item of the batch::matrix::Ell<value_type> object...
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:264
const value_type * get_const_values() const noexcept
Returns a pointer to the array of values of the matrix.
Definition: batch_ell.hpp:138
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:283
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition: polymorphic_object.hpp:667