33#ifndef GKO_PUBLIC_CORE_BASE_BATCH_LIN_OP_HPP_
34#define GKO_PUBLIC_CORE_BASE_BATCH_LIN_OP_HPP_
42#include <ginkgo/core/base/abstract_factory.hpp>
43#include <ginkgo/core/base/batch_multi_vector.hpp>
44#include <ginkgo/core/base/dim.hpp>
45#include <ginkgo/core/base/exception_helpers.hpp>
46#include <ginkgo/core/base/math.hpp>
47#include <ginkgo/core/base/matrix_assembly_data.hpp>
48#include <ginkgo/core/base/matrix_data.hpp>
49#include <ginkgo/core/base/polymorphic_object.hpp>
50#include <ginkgo/core/base/types.hpp>
51#include <ginkgo/core/base/utils.hpp>
52#include <ginkgo/core/log/logger.hpp>
119 template <
typename ValueType>
136 template <
typename ValueType>
159 void set_size(
const batch_dim<2>& size) { size_ = size; }
167 explicit BatchLinOp(std::shared_ptr<const Executor> exec,
180 explicit BatchLinOp(std::shared_ptr<const Executor> exec,
183 : BatchLinOp{std::
move(exec),
190 batch_dim<2> size_{};
224 :
public AbstractFactory<BatchLinOp, std::shared_ptr<const BatchLinOp>> {
227 std::shared_ptr<const BatchLinOp>>::AbstractFactory;
229 std::unique_ptr<BatchLinOp> generate(
230 std::shared_ptr<const BatchLinOp> input)
const
233 gko::log::Logger::batch_linop_factory_generate_started>(
235 const auto exec = this->get_executor();
236 std::unique_ptr<BatchLinOp> generated;
237 if (input->get_executor() == exec) {
238 generated = this->AbstractFactory::generate(input);
241 this->AbstractFactory::generate(
gko::clone(exec, input));
244 gko::log::Logger::batch_linop_factory_generate_completed>(
245 this, input.get(), generated.get());
278template <
typename ConcreteBatchLinOp,
typename PolymorphicBase = BatchLinOp>
284 PolymorphicBase>::EnablePolymorphicObject;
387#define GKO_ENABLE_BATCH_LIN_OP_FACTORY(_batch_lin_op, _parameters_name, \
390 const _parameters_name##_type& get_##_parameters_name() const \
392 return _parameters_name##_; \
395 class _factory_name \
396 : public ::gko::batch::EnableDefaultBatchLinOpFactory< \
397 _factory_name, _batch_lin_op, _parameters_name##_type> { \
398 friend class ::gko::EnablePolymorphicObject< \
399 _factory_name, ::gko::batch::BatchLinOpFactory>; \
400 friend class ::gko::enable_parameters_type<_parameters_name##_type, \
402 explicit _factory_name(std::shared_ptr<const ::gko::Executor> exec) \
403 : ::gko::batch::EnableDefaultBatchLinOpFactory< \
404 _factory_name, _batch_lin_op, _parameters_name##_type>( \
407 explicit _factory_name(std::shared_ptr<const ::gko::Executor> exec, \
408 const _parameters_name##_type& parameters) \
409 : ::gko::batch::EnableDefaultBatchLinOpFactory< \
410 _factory_name, _batch_lin_op, _parameters_name##_type>( \
411 std::move(exec), parameters) \
414 friend ::gko::batch::EnableDefaultBatchLinOpFactory< \
415 _factory_name, _batch_lin_op, _parameters_name##_type>; \
419 _parameters_name##_type _parameters_name##_; \
422 static_assert(true, \
423 "This assert is used to counter the false positive extra " \
424 "semi-colon warnings")
The AbstractFactory is a generic interface template that enables easy implementation of the abstract ...
Definition abstract_factory.hpp:75
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:374
This mixin provides a default implementation of a concrete factory.
Definition abstract_factory.hpp:154
This mixin is used to enable a default PolymorphicObject::copy_from() implementation for objects that...
Definition polymorphic_object.hpp:752
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:691
A BatchLinOpFactory represents a higher order mapping which transforms one batch linear operator into...
Definition batch_lin_op.hpp:224
Definition batch_lin_op.hpp:88
const batch_dim< 2 > & get_size() const noexcept
Returns the size of the batch operator.
Definition batch_lin_op.hpp:112
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:120
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:137
dim< 2 > get_common_size() const
Returns the common size of the batch items.
Definition batch_lin_op.hpp:105
size_type get_num_batch_items() const noexcept
Returns the number of items in the batch operator.
Definition batch_lin_op.hpp:95
The EnableBatchLinOp mixin can be used to provide sensible default implementations of the majority of...
Definition batch_lin_op.hpp:281
MultiVector stores multiple vectors in a batched fashion and is useful for batched operations.
Definition batch_multi_vector.hpp:85
dim< 2 > get_common_size() const
Returns the common size of the batch items.
Definition batch_multi_vector.hpp:157
size_type get_num_batch_items() const
Returns the number of batch items.
Definition batch_multi_vector.hpp:147
The Ginkgo namespace.
Definition abstract_factory.hpp:48
constexpr T one()
Returns the multiplicative identity for T.
Definition math.hpp:803
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:120
detail::cloned_type< Pointer > clone(const Pointer &p)
Creates a unique clone of the object pointed to by p.
Definition utils_helper.hpp:203
A type representing the dimensions of a multidimensional batch object.
Definition batch_dim.hpp:56
dim< dimensionality, dimension_type > get_common_size() const
Get the common size of the batch items.
Definition batch_dim.hpp:72
size_type get_num_batch_items() const
Get the number of batch items stored.
Definition batch_dim.hpp:65
A type representing the dimensions of a multidimensional object.
Definition dim.hpp:55