gko::PolymorphicObject#
The base of every Ginkgo object. It holds the executor and provides
validate_data(). That function checks an object’s stored data and throws
gko::InvalidData on a violation. Ginkgo never calls it on
its own; call it after filling a matrix from external data.
The checks depend on the format:
Format |
What |
|---|---|
|
row pointers are non-descending and within |
|
row indices are non-descending and within |
|
the column indices of non-padding entries are below |
|
all values are finite |
|
the index array is a bijection on |
Other types keep the default, which accepts the object. The check copies the data to the host and scans it, so it costs a device-to-host transfer and \(O(\text{nnz})\) work.
auto A = gko::matrix::Csr<double, int>::create(exec, gko::dim<2>{3}, 4);
// ... fill A's row pointers, column indices and values from external data
try {
A->validate_data();
} catch (const gko::InvalidData& e) {
std::cerr << "invalid matrix: " << e.what() << '\n';
}
-
class PolymorphicObject #
Inherits from
public gko::log::EnableLogging<PolymorphicObject>
A PolymorphicObject is the abstract base for all “heavy” objects in Ginkgo that behave polymorphically.
It defines the basic utilities (copying moving, cloning, clearing the objects) for all such objects. It takes into account that these objects are dynamically allocated, managed by smart pointers, and used polymorphically. Additionally, it assumes their data can be allocated on different executors, and that they can be copied between those executors.
Note
Most of the public methods of this class should not be overridden directly, and are thus not virtual. Instead, there are equivalent protected methods (ending in <method_name>_impl) that should be overridden instead. This allows polymorphic objects to implement default behavior around virtual methods (parameter checking, type casting).
Subclassed by
gko::AbstractFactory< ReorderingBase< IndexType >
ReorderingBaseArgs >
gko::AbstractFactory< gko::reorder::ReorderingBase< IndexType >
gko::reorder::ReorderingBaseArgs >
gko::AbstractFactory< Criterion
CriterionArgs >
gko::AbstractFactory< LinOp
std::shared_ptr< const LinOp > >
gko::AbstractFactory< BatchLinOp
std::shared_ptr< const BatchLinOp > >
gko::experimental::distributed::Partition< LocalIndexType, GlobalIndexType >
gko::reorder::ReorderingBase< int32 >
gko::AbstractFactory< AbstractProductType
ComponentsType >
gko::batch::BatchLinOp
gko::experimental::distributed::Partition< LocalIndexType, GlobalIndexType >
gko::experimental::distributed::RowGatherer< LocalIndexType >
gko::experimental::distributed::RowScatterer< LocalIndexType >
gko::reorder::ReorderingBase< IndexType >
Public Functions
-
inline virtual void validate_data() const#
Throws gko::InvalidData exception if we found the data inside the object does not fulfill certain property up to our knowledge.
See also