5#ifndef GKO_PUBLIC_CORE_BASE_BATCH_LIN_OP_HPP_
6#define GKO_PUBLIC_CORE_BASE_BATCH_LIN_OP_HPP_
14#include <ginkgo/core/base/abstract_factory.hpp>
15#include <ginkgo/core/base/batch_multi_vector.hpp>
16#include <ginkgo/core/base/dim.hpp>
17#include <ginkgo/core/base/exception_helpers.hpp>
18#include <ginkgo/core/base/math.hpp>
19#include <ginkgo/core/base/matrix_assembly_data.hpp>
20#include <ginkgo/core/base/matrix_data.hpp>
21#include <ginkgo/core/base/polymorphic_object.hpp>
22#include <ginkgo/core/base/types.hpp>
23#include <ginkgo/core/base/utils.hpp>
24#include <ginkgo/core/log/logger.hpp>
91 template <
typename ValueType>
108 template <
typename ValueType>
131 void set_size(
const batch_dim<2>& size) { size_ = size; }
139 explicit BatchLinOp(std::shared_ptr<const Executor> exec,
152 explicit BatchLinOp(std::shared_ptr<const Executor> exec,
154 const dim<2>& common_size = dim<2>{})
155 : BatchLinOp{std::move(exec),
157 ? batch_dim<2>(num_batch_items, common_size)
162 batch_dim<2> size_{};
196 :
public AbstractFactory<BatchLinOp, std::shared_ptr<const BatchLinOp>> {
199 std::shared_ptr<const BatchLinOp>>::AbstractFactory;
201 std::unique_ptr<BatchLinOp> generate(
202 std::shared_ptr<const BatchLinOp> input)
const
205 gko::log::Logger::batch_linop_factory_generate_started>(
207 const auto exec = this->get_executor();
208 std::unique_ptr<BatchLinOp> generated;
209 if (input->get_executor() == exec) {
210 generated = this->AbstractFactory::generate(input);
213 this->AbstractFactory::generate(
gko::clone(exec, input));
216 gko::log::Logger::batch_linop_factory_generate_completed>(
217 this, input.get(), generated.get());
250template <
typename ConcreteBatchLinOp,
typename PolymorphicBase = BatchLinOp>
256 PolymorphicBase>::EnablePolymorphicObject;
276template <
typename ConcreteFactory,
typename ConcreteBatchLinOp,
359#define GKO_ENABLE_BATCH_LIN_OP_FACTORY(_batch_lin_op, _parameters_name, \
362 const _parameters_name##_type& get_##_parameters_name() const \
364 return _parameters_name##_; \
367 class _factory_name \
368 : public ::gko::batch::EnableDefaultBatchLinOpFactory< \
369 _factory_name, _batch_lin_op, _parameters_name##_type> { \
370 friend class ::gko::EnablePolymorphicObject< \
371 _factory_name, ::gko::batch::BatchLinOpFactory>; \
372 friend class ::gko::enable_parameters_type<_parameters_name##_type, \
374 explicit _factory_name(std::shared_ptr<const ::gko::Executor> exec) \
375 : ::gko::batch::EnableDefaultBatchLinOpFactory< \
376 _factory_name, _batch_lin_op, _parameters_name##_type>( \
379 explicit _factory_name(std::shared_ptr<const ::gko::Executor> exec, \
380 const _parameters_name##_type& parameters) \
381 : ::gko::batch::EnableDefaultBatchLinOpFactory< \
382 _factory_name, _batch_lin_op, _parameters_name##_type>( \
383 std::move(exec), parameters) \
386 friend ::gko::batch::EnableDefaultBatchLinOpFactory< \
387 _factory_name, _batch_lin_op, _parameters_name##_type>; \
391 _parameters_name##_type _parameters_name##_; \
394 static_assert(true, \
395 "This assert is used to counter the false positive extra " \
396 "semi-colon warnings")
The AbstractFactory is a generic interface template that enables easy implementation of the abstract ...
Definition abstract_factory.hpp:47
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:346
This mixin provides a default implementation of a concrete factory.
Definition abstract_factory.hpp:126
This mixin is used to enable a default PolymorphicObject::copy_from() implementation for objects that...
Definition polymorphic_object.hpp:724
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:663
A BatchLinOpFactory represents a higher order mapping which transforms one batch linear operator into...
Definition batch_lin_op.hpp:196
Definition batch_lin_op.hpp:60
const batch_dim< 2 > & get_size() const noexcept
Returns the size of the batch operator.
Definition batch_lin_op.hpp:84
void validate_application_parameters(const MultiVector< ValueType > *b, MultiVector< ValueType > *x) const
Validates the sizes for the apply(b,x) operation in the concrete BatchLinOp.
Definition batch_lin_op.hpp:92
void validate_application_parameters(const MultiVector< ValueType > *alpha, const MultiVector< ValueType > *b, const MultiVector< ValueType > *beta, MultiVector< ValueType > *x) const
Validates the sizes for the apply(alpha, b , beta, x) operation in the concrete BatchLinOp.
Definition batch_lin_op.hpp:109
dim< 2 > get_common_size() const
Returns the common size of the batch items.
Definition batch_lin_op.hpp:77
size_type get_num_batch_items() const noexcept
Returns the number of items in the batch operator.
Definition batch_lin_op.hpp:67
The EnableBatchLinOp mixin can be used to provide sensible default implementations of the majority of...
Definition batch_lin_op.hpp:253
MultiVector stores multiple vectors in a batched fashion and is useful for batched operations.
Definition logger.hpp:41
dim< 2 > get_common_size() const
Returns the common size of the batch items.
Definition batch_multi_vector.hpp:127
size_type get_num_batch_items() const
Returns the number of batch items.
Definition batch_multi_vector.hpp:117
The Ginkgo namespace.
Definition abstract_factory.hpp:20
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:86
detail::cloned_type< Pointer > clone(const Pointer &p)
Creates a unique clone of the object pointed to by p.
Definition utils_helper.hpp:175
A type representing the dimensions of a multidimensional batch object.
Definition batch_dim.hpp:28
dim< dimensionality, dimension_type > get_common_size() const
Get the common size of the batch items.
Definition batch_dim.hpp:44
size_type get_num_batch_items() const
Get the number of batch items stored.
Definition batch_dim.hpp:37
A type representing the dimensions of a multidimensional object.
Definition dim.hpp:27