Skip to content

Commit 2bf7411

Browse files
authored
Merge simplified GKO_REGISTER_OPERATION
This PR uses lambda captures to simplify the GKO_REGISTER_OPERATION parameter storage, dispatch and error message quality. Related PR: #859
2 parents 147c175 + 109c48d commit 2bf7411

2 files changed

Lines changed: 171 additions & 128 deletions

File tree

core/matrix/dense.cpp

Lines changed: 37 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,10 @@ void Dense<ValueType>::move_to(Dense<next_precision<ValueType>> *result)
468468
template <typename ValueType>
469469
void Dense<ValueType>::convert_to(Coo<ValueType, int32> *result) const
470470
{
471-
conversion_helper(
472-
result, this,
473-
dense::template make_convert_to_coo<const Dense<ValueType> *&,
474-
decltype(result)>);
471+
// const ref parameters, as make_* functions take parameters by ref
472+
conversion_helper(result, this, [](const auto &in, const auto &out) {
473+
return dense::make_convert_to_coo(in, out);
474+
});
475475
}
476476

477477

@@ -485,10 +485,9 @@ void Dense<ValueType>::move_to(Coo<ValueType, int32> *result)
485485
template <typename ValueType>
486486
void Dense<ValueType>::convert_to(Coo<ValueType, int64> *result) const
487487
{
488-
conversion_helper(
489-
result, this,
490-
dense::template make_convert_to_coo<const Dense<ValueType> *&,
491-
decltype(result)>);
488+
conversion_helper(result, this, [](const auto &in, const auto &out) {
489+
return dense::make_convert_to_coo(in, out);
490+
});
492491
}
493492

494493

@@ -502,10 +501,9 @@ void Dense<ValueType>::move_to(Coo<ValueType, int64> *result)
502501
template <typename ValueType>
503502
void Dense<ValueType>::convert_to(Csr<ValueType, int32> *result) const
504503
{
505-
conversion_helper(
506-
result, this,
507-
dense::template make_convert_to_csr<const Dense<ValueType> *&,
508-
decltype(result)>);
504+
conversion_helper(result, this, [](const auto &in, const auto &out) {
505+
return dense::make_convert_to_csr(in, out);
506+
});
509507
result->make_srow();
510508
}
511509

@@ -520,10 +518,9 @@ void Dense<ValueType>::move_to(Csr<ValueType, int32> *result)
520518
template <typename ValueType>
521519
void Dense<ValueType>::convert_to(Csr<ValueType, int64> *result) const
522520
{
523-
conversion_helper(
524-
result, this,
525-
dense::template make_convert_to_csr<const Dense<ValueType> *&,
526-
decltype(result)>);
521+
conversion_helper(result, this, [](const auto &in, const auto &out) {
522+
return dense::make_convert_to_csr(in, out);
523+
});
527524
result->make_srow();
528525
}
529526

@@ -538,10 +535,9 @@ void Dense<ValueType>::move_to(Csr<ValueType, int64> *result)
538535
template <typename ValueType>
539536
void Dense<ValueType>::convert_to(Ell<ValueType, int32> *result) const
540537
{
541-
conversion_helper(
542-
result, this,
543-
dense::template make_convert_to_ell<const Dense<ValueType> *&,
544-
decltype(result)>);
538+
conversion_helper(result, this, [](const auto &in, const auto &out) {
539+
return dense::make_convert_to_ell(in, out);
540+
});
545541
}
546542

547543

@@ -555,10 +551,9 @@ void Dense<ValueType>::move_to(Ell<ValueType, int32> *result)
555551
template <typename ValueType>
556552
void Dense<ValueType>::convert_to(Ell<ValueType, int64> *result) const
557553
{
558-
conversion_helper(
559-
result, this,
560-
dense::template make_convert_to_ell<const Dense<ValueType> *&,
561-
decltype(result)>);
554+
conversion_helper(result, this, [](const auto &in, const auto &out) {
555+
return dense::make_convert_to_ell(in, out);
556+
});
562557
}
563558

564559

@@ -572,10 +567,9 @@ void Dense<ValueType>::move_to(Ell<ValueType, int64> *result)
572567
template <typename ValueType>
573568
void Dense<ValueType>::convert_to(Hybrid<ValueType, int32> *result) const
574569
{
575-
conversion_helper(
576-
result, this,
577-
dense::template make_convert_to_hybrid<const Dense<ValueType> *&,
578-
decltype(result)>);
570+
conversion_helper(result, this, [](const auto &in, const auto &out) {
571+
return dense::make_convert_to_hybrid(in, out);
572+
});
579573
}
580574

581575

@@ -589,10 +583,9 @@ void Dense<ValueType>::move_to(Hybrid<ValueType, int32> *result)
589583
template <typename ValueType>
590584
void Dense<ValueType>::convert_to(Hybrid<ValueType, int64> *result) const
591585
{
592-
conversion_helper(
593-
result, this,
594-
dense::template make_convert_to_hybrid<const Dense<ValueType> *&,
595-
decltype(result)>);
586+
conversion_helper(result, this, [](const auto &in, const auto &out) {
587+
return dense::make_convert_to_hybrid(in, out);
588+
});
596589
}
597590

598591

@@ -606,10 +599,9 @@ void Dense<ValueType>::move_to(Hybrid<ValueType, int64> *result)
606599
template <typename ValueType>
607600
void Dense<ValueType>::convert_to(Sellp<ValueType, int32> *result) const
608601
{
609-
conversion_helper(
610-
result, this,
611-
dense::template make_convert_to_sellp<const Dense<ValueType> *&,
612-
decltype(result)>);
602+
conversion_helper(result, this, [](const auto &in, const auto &out) {
603+
return dense::make_convert_to_sellp(in, out);
604+
});
613605
}
614606

615607

@@ -623,10 +615,9 @@ void Dense<ValueType>::move_to(Sellp<ValueType, int32> *result)
623615
template <typename ValueType>
624616
void Dense<ValueType>::convert_to(Sellp<ValueType, int64> *result) const
625617
{
626-
conversion_helper(
627-
result, this,
628-
dense::template make_convert_to_sellp<const Dense<ValueType> *&,
629-
decltype(result)>);
618+
conversion_helper(result, this, [](const auto &in, const auto &out) {
619+
return dense::make_convert_to_sellp(in, out);
620+
});
630621
}
631622

632623

@@ -640,10 +631,9 @@ void Dense<ValueType>::move_to(Sellp<ValueType, int64> *result)
640631
template <typename ValueType>
641632
void Dense<ValueType>::convert_to(SparsityCsr<ValueType, int32> *result) const
642633
{
643-
conversion_helper(
644-
result, this,
645-
dense::template make_convert_to_sparsity_csr<const Dense<ValueType> *&,
646-
decltype(result)>);
634+
conversion_helper(result, this, [](const auto &in, const auto &out) {
635+
return dense::make_convert_to_sparsity_csr(in, out);
636+
});
647637
}
648638

649639

@@ -657,10 +647,9 @@ void Dense<ValueType>::move_to(SparsityCsr<ValueType, int32> *result)
657647
template <typename ValueType>
658648
void Dense<ValueType>::convert_to(SparsityCsr<ValueType, int64> *result) const
659649
{
660-
conversion_helper(
661-
result, this,
662-
dense::template make_convert_to_sparsity_csr<const Dense<ValueType> *&,
663-
decltype(result)>);
650+
conversion_helper(result, this, [](const auto &in, const auto &out) {
651+
return dense::make_convert_to_sparsity_csr(in, out);
652+
});
664653
}
665654

666655

0 commit comments

Comments
 (0)