 |
Ginkgo
Generated from pipelines/2662685947 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
|
5 #ifndef GKO_PUBLIC_CORE_MATRIX_BATCH_DENSE_HPP_
6 #define GKO_PUBLIC_CORE_MATRIX_BATCH_DENSE_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/matrix/dense.hpp>
47 template <
typename ValueType = default_precision>
50 #if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
53 #if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
60 GKO_ASSERT_SUPPORTED_VALUE_TYPE;
66 using value_type = ValueType;
67 using index_type =
int32;
77 #if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
87 #if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
162 return values_.
get_data()[linearize_index(batch_id, row, col)];
171 return values_.
get_const_data()[linearize_index(batch_id, row, col)];
191 return values_.
get_data()[linearize_index(batch_id, idx)];
261 static std::unique_ptr<Dense>
create(
262 std::shared_ptr<const Executor> exec,
279 static std::unique_ptr<Dense>
create(std::shared_ptr<const Executor> exec,
287 template <
typename InputValueType>
289 "explicitly construct the gko::array argument instead of passing an"
293 std::initializer_list<InputValueType> values)
313 std::shared_ptr<const Executor> exec,
const batch_dim<2>& sizes,
314 gko::detail::const_array_view<ValueType>&& values);
395 Dense(std::shared_ptr<const Executor> exec,
398 Dense(std::shared_ptr<const Executor> exec,
const batch_dim<2>& size,
401 void apply_impl(
const MultiVector<value_type>* b,
402 MultiVector<value_type>* x)
const;
404 void apply_impl(
const MultiVector<value_type>* alpha,
405 const MultiVector<value_type>* b,
406 const MultiVector<value_type>* beta,
407 MultiVector<value_type>* x)
const;
422 array<value_type> values_;
431 #endif // GKO_PUBLIC_CORE_MATRIX_BATCH_DENSE_HPP_
size_type get_num_batch_items() const
Get the number of batch items stored.
Definition: batch_dim.hpp:36
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_dense.hpp:211
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_dense.hpp:224
dim< dimensionality, dimension_type > get_common_size() const
Get the common size of the batch items.
Definition: batch_dim.hpp:43
void scale(const array< value_type > &row_scale, const array< value_type > &col_scale)
Performs in-place row and column scaling for this matrix.
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.
size_type get_num_elements_per_item() const noexcept
Returns the number of stored elements in each batch item.
Definition: batch_dense.hpp:248
ValueType & at(size_type batch_id, size_type idx) noexcept
Returns a single element for a particular batch item.
Definition: batch_dense.hpp:188
Dense is a matrix format which explicitly stores all values of the matrix.
Definition: dense_cache.hpp:28
void apply(ptr_param< const MultiVector< value_type >> b, ptr_param< MultiVector< value_type >> x)
Apply the matrix to a multi-vector.
Definition: batch_lin_op.hpp:59
size_type get_num_batch_items() const noexcept
Returns the number of items in the batch operator.
Definition: batch_lin_op.hpp:66
static std::unique_ptr< const Dense > 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 dense matrix from a constant array.
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_dense.hpp:168
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:90
value_type & at(size_type batch_id, size_type row, size_type col)
Returns a single element for a particular batch item.
Definition: batch_dense.hpp:159
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() const noexcept
Returns a pointer to the array of values of the multi-vector.
Definition: batch_dense.hpp:143
dim< 2 > get_common_size() const
Returns the common size of the batch items.
Definition: batch_lin_op.hpp:76
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
ValueType at(size_type batch_id, size_type idx) const noexcept
Returns a single element for a particular batch item.
Definition: batch_dense.hpp:197
std::unique_ptr< const unbatch_type > create_const_view_for_item(size_type item_id) const
Creates a mutable view (of gko::matrix::Dense type) of one item of the batch::matrix::Dense<value_typ...
std::unique_ptr< unbatch_type > create_view_for_item(size_type item_id)
Creates a mutable view (of gko::matrix::Dense type) of one item of the batch::matrix::Dense<value_typ...
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:687
static std::unique_ptr< Dense > create(std::shared_ptr< const Executor > exec, const batch_dim< 2 > &size=batch_dim< 2 >{})
Creates an uninitialized Dense matrix of the specified size.
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_dense.hpp:238
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
This mixin is used to enable a default Cloneable::clone() implementation and similar for objects that...
Definition: polymorphic_object.hpp:369
ConvertibleTo interface is used to mark that the implementer can be converted to the object of Result...
Definition: polymorphic_object.hpp:140
std::int32_t int32
32-bit signed integral type.
Definition: types.hpp:107
The first step in using the Ginkgo library consists of creating an executor.
Definition: executor.hpp:616
value_type * get_values() noexcept
Returns a pointer to the array of values of the multi-vector.
Definition: batch_dense.hpp:134
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
Dense is a batch matrix format which explicitly stores all values of the matrix in each of the batche...
Definition: batch_dense.hpp:48
size_type get_size() const noexcept
Returns the number of elements in the array.
Definition: array.hpp:670
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
size_type get_cumulative_offset(size_type batch_id) const
Get the cumulative storage size offset.
Definition: batch_dense.hpp:122
const batch_dim< 2 > & get_size() const noexcept
Returns the size of the batch operator.
Definition: batch_lin_op.hpp:83
void scale_add(ptr_param< const MultiVector< value_type >> alpha, ptr_param< const batch::matrix::Dense< value_type >> b)
Performs the operation this = alpha*this + b.
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