Skip to content

Commit

Permalink
get/apply_absolute -> compute_absolute(_inplace)
Browse files Browse the repository at this point in the history
Co-authored-by: Tobias Ribizel <[email protected]>
  • Loading branch information
yhmtsai and upsj committed Sep 9, 2020
1 parent f0d4234 commit 3ae2b45
Show file tree
Hide file tree
Showing 44 changed files with 173 additions and 173 deletions.
4 changes: 2 additions & 2 deletions core/matrix/coo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ Coo<ValueType, IndexType>::extract_diagonal() const


template <typename ValueType, typename IndexType>
void Coo<ValueType, IndexType>::apply_absolute()
void Coo<ValueType, IndexType>::compute_absolute_inplace()
{
auto exec = this->get_executor();

Expand All @@ -250,7 +250,7 @@ void Coo<ValueType, IndexType>::apply_absolute()

template <typename ValueType, typename IndexType>
std::unique_ptr<typename Coo<ValueType, IndexType>::outplace_absolute_type>
Coo<ValueType, IndexType>::get_absolute() const
Coo<ValueType, IndexType>::compute_absolute() const
{
auto exec = this->get_executor();

Expand Down
4 changes: 2 additions & 2 deletions core/matrix/csr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ Csr<ValueType, IndexType>::extract_diagonal() const


template <typename ValueType, typename IndexType>
void Csr<ValueType, IndexType>::apply_absolute()
void Csr<ValueType, IndexType>::compute_absolute_inplace()
{
auto exec = this->get_executor();

Expand All @@ -498,7 +498,7 @@ void Csr<ValueType, IndexType>::apply_absolute()

template <typename ValueType, typename IndexType>
std::unique_ptr<typename Csr<ValueType, IndexType>::outplace_absolute_type>
Csr<ValueType, IndexType>::get_absolute() const
Csr<ValueType, IndexType>::compute_absolute() const
{
auto exec = this->get_executor();

Expand Down
4 changes: 2 additions & 2 deletions core/matrix/dense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ std::unique_ptr<Diagonal<ValueType>> Dense<ValueType>::extract_diagonal() const


template <typename ValueType>
void Dense<ValueType>::apply_absolute()
void Dense<ValueType>::compute_absolute_inplace()
{
auto exec = this->get_executor();

Expand All @@ -765,7 +765,7 @@ void Dense<ValueType>::apply_absolute()

template <typename ValueType>
std::unique_ptr<typename Dense<ValueType>::outplace_absolute_type>
Dense<ValueType>::get_absolute() const
Dense<ValueType>::compute_absolute() const
{
auto exec = this->get_executor();

Expand Down
4 changes: 2 additions & 2 deletions core/matrix/diagonal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void Diagonal<ValueType>::write(mat_data32 &data) const


template <typename ValueType>
void Diagonal<ValueType>::apply_absolute()
void Diagonal<ValueType>::compute_absolute_inplace()
{
auto exec = this->get_executor();

Expand All @@ -278,7 +278,7 @@ void Diagonal<ValueType>::apply_absolute()

template <typename ValueType>
std::unique_ptr<typename Diagonal<ValueType>::outplace_absolute_type>
Diagonal<ValueType>::get_absolute() const
Diagonal<ValueType>::compute_absolute() const
{
auto exec = this->get_executor();

Expand Down
4 changes: 2 additions & 2 deletions core/matrix/ell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ Ell<ValueType, IndexType>::extract_diagonal() const


template <typename ValueType, typename IndexType>
void Ell<ValueType, IndexType>::apply_absolute()
void Ell<ValueType, IndexType>::compute_absolute_inplace()
{
auto exec = this->get_executor();

Expand All @@ -268,7 +268,7 @@ void Ell<ValueType, IndexType>::apply_absolute()

template <typename ValueType, typename IndexType>
std::unique_ptr<typename Ell<ValueType, IndexType>::outplace_absolute_type>
Ell<ValueType, IndexType>::get_absolute() const
Ell<ValueType, IndexType>::compute_absolute() const
{
auto exec = this->get_executor();

Expand Down
8 changes: 4 additions & 4 deletions core/matrix/hybrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ Hybrid<ValueType, IndexType>::extract_diagonal() const


template <typename ValueType, typename IndexType>
void Hybrid<ValueType, IndexType>::apply_absolute()
void Hybrid<ValueType, IndexType>::compute_absolute_inplace()
{
auto exec = this->get_executor();

Expand All @@ -304,15 +304,15 @@ void Hybrid<ValueType, IndexType>::apply_absolute()

template <typename ValueType, typename IndexType>
std::unique_ptr<typename Hybrid<ValueType, IndexType>::outplace_absolute_type>
Hybrid<ValueType, IndexType>::get_absolute() const
Hybrid<ValueType, IndexType>::compute_absolute() const
{
auto exec = this->get_executor();

// use default strategy
auto abs_hybrid = outplace_absolute_type::create(exec, this->get_size());

abs_hybrid->ell_->copy_from(ell_->get_absolute());
abs_hybrid->coo_->copy_from(coo_->get_absolute());
abs_hybrid->ell_->copy_from(ell_->compute_absolute());
abs_hybrid->coo_->copy_from(coo_->compute_absolute());

return abs_hybrid;
}
Expand Down
4 changes: 2 additions & 2 deletions core/matrix/sellp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ Sellp<ValueType, IndexType>::extract_diagonal() const


template <typename ValueType, typename IndexType>
void Sellp<ValueType, IndexType>::apply_absolute()
void Sellp<ValueType, IndexType>::compute_absolute_inplace()
{
auto exec = this->get_executor();

Expand All @@ -321,7 +321,7 @@ void Sellp<ValueType, IndexType>::apply_absolute()

template <typename ValueType, typename IndexType>
std::unique_ptr<typename Sellp<ValueType, IndexType>::outplace_absolute_type>
Sellp<ValueType, IndexType>::get_absolute() const
Sellp<ValueType, IndexType>::compute_absolute() const
{
auto exec = this->get_executor();

Expand Down
12 changes: 6 additions & 6 deletions core/test/base/lin_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ class DummyLinOpWithType
: gko::EnableLinOp<DummyLinOpWithType>(exec, size), value_(value)
{}

void apply_absolute() override { value_ = gko::abs(value_); }
void compute_absolute_inplace() override { value_ = gko::abs(value_); }

std::unique_ptr<outplace_absolute_type> get_absolute() const override
std::unique_ptr<outplace_absolute_type> compute_absolute() const override
{
return std::make_unique<outplace_absolute_type>(
this->get_executor(), this->get_size(), gko::abs(value_));
Expand Down Expand Up @@ -369,15 +369,15 @@ class EnableAbsoluteComputation : public ::testing::Test {

TEST_F(EnableAbsoluteComputation, InplaceAbsoluteOnConcreteType)
{
op->apply_absolute();
op->compute_absolute_inplace();

ASSERT_EQ(op->get_value(), std::complex<double>{5.0});
}


TEST_F(EnableAbsoluteComputation, OutplaceAbsoluteOnConcreteType)
{
auto abs_op = op->get_absolute();
auto abs_op = op->compute_absolute();

ASSERT_EQ(typeid(abs_op),
typeid(std::unique_ptr<gko::remove_complex<dummy_type>>));
Expand All @@ -389,7 +389,7 @@ TEST_F(EnableAbsoluteComputation, InplaceAbsoluteOnAbsoluteComputable)
{
auto linop = gko::as<gko::LinOp>(op);

gko::as<gko::AbsoluteComputable>(linop)->apply_absolute();
gko::as<gko::AbsoluteComputable>(linop)->compute_absolute_inplace();

ASSERT_EQ(gko::as<dummy_type>(linop)->get_value(),
std::complex<double>{5.0});
Expand All @@ -398,7 +398,7 @@ TEST_F(EnableAbsoluteComputation, InplaceAbsoluteOnAbsoluteComputable)

TEST_F(EnableAbsoluteComputation, OutplaceAbsoluteOnAbsoluteComputable)
{
auto abs_op = op->get_absolute();
auto abs_op = op->compute_absolute();

ASSERT_EQ(typeid(abs_op),
typeid(std::unique_ptr<gko::remove_complex<dummy_type>>));
Expand Down
8 changes: 4 additions & 4 deletions cuda/test/matrix/coo_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ TEST_F(Coo, InplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_data();

mtx->apply_absolute();
dmtx->apply_absolute();
mtx->compute_absolute_inplace();
dmtx->compute_absolute_inplace();

GKO_ASSERT_MTX_NEAR(mtx.get(), dmtx.get(), 1e-14);
}
Expand All @@ -286,8 +286,8 @@ TEST_F(Coo, OutplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_data();

auto abs_mtx = mtx->get_absolute();
auto dabs_mtx = dmtx->get_absolute();
auto abs_mtx = mtx->compute_absolute();
auto dabs_mtx = dmtx->compute_absolute();

GKO_ASSERT_MTX_NEAR(abs_mtx.get(), dabs_mtx.get(), 1e-14);
}
Expand Down
16 changes: 8 additions & 8 deletions cuda/test/matrix/csr_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,8 @@ TEST_F(Csr, InplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_data(std::make_shared<Mtx::automatical>(cuda));

mtx->apply_absolute();
dmtx->apply_absolute();
mtx->compute_absolute_inplace();
dmtx->compute_absolute_inplace();

GKO_ASSERT_MTX_NEAR(mtx.get(), dmtx.get(), 1e-14);
}
Expand All @@ -755,8 +755,8 @@ TEST_F(Csr, OutplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_data(std::make_shared<Mtx::automatical>(cuda));

auto abs_mtx = mtx->get_absolute();
auto dabs_mtx = dmtx->get_absolute();
auto abs_mtx = mtx->compute_absolute();
auto dabs_mtx = dmtx->compute_absolute();

GKO_ASSERT_MTX_NEAR(abs_mtx.get(), dabs_mtx.get(), 1e-14);
}
Expand All @@ -766,8 +766,8 @@ TEST_F(Csr, InplaceAbsoluteComplexMatrixIsEquivalentToRef)
{
set_up_apply_complex_data(std::make_shared<ComplexMtx::automatical>(cuda));

complex_mtx->apply_absolute();
complex_dmtx->apply_absolute();
complex_mtx->compute_absolute_inplace();
complex_dmtx->compute_absolute_inplace();

GKO_ASSERT_MTX_NEAR(complex_mtx.get(), complex_dmtx.get(), 1e-14);
}
Expand All @@ -777,8 +777,8 @@ TEST_F(Csr, OutplaceAbsoluteComplexMatrixIsEquivalentToRef)
{
set_up_apply_complex_data(std::make_shared<ComplexMtx::automatical>(cuda));

auto abs_mtx = complex_mtx->get_absolute();
auto dabs_mtx = complex_dmtx->get_absolute();
auto abs_mtx = complex_mtx->compute_absolute();
auto dabs_mtx = complex_dmtx->compute_absolute();

GKO_ASSERT_MTX_NEAR(abs_mtx.get(), dabs_mtx.get(), 1e-14);
}
Expand Down
8 changes: 4 additions & 4 deletions cuda/test/matrix/dense_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,8 @@ TEST_F(Dense, InplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_data();

x->apply_absolute();
dx->apply_absolute();
x->compute_absolute_inplace();
dx->compute_absolute_inplace();

GKO_ASSERT_MTX_NEAR(x.get(), dx.get(), 1e-14);
}
Expand All @@ -602,8 +602,8 @@ TEST_F(Dense, OutplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_data();

auto abs_x = x->get_absolute();
auto dabs_x = dx->get_absolute();
auto abs_x = x->compute_absolute();
auto dabs_x = dx->compute_absolute();

GKO_ASSERT_MTX_NEAR(abs_x.get(), dabs_x.get(), 1e-14);
}
Expand Down
8 changes: 4 additions & 4 deletions cuda/test/matrix/diagonal_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ TEST_F(Diagonal, InplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_data();

diag->apply_absolute();
ddiag->apply_absolute();
diag->compute_absolute_inplace();
ddiag->compute_absolute_inplace();

GKO_ASSERT_MTX_NEAR(diag.get(), ddiag.get(), 1e-14);
}
Expand All @@ -264,8 +264,8 @@ TEST_F(Diagonal, OutplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_data();

auto abs_diag = diag->get_absolute();
auto dabs_diag = ddiag->get_absolute();
auto abs_diag = diag->compute_absolute();
auto dabs_diag = ddiag->compute_absolute();

GKO_ASSERT_MTX_NEAR(abs_diag.get(), dabs_diag.get(), 1e-14);
}
Expand Down
8 changes: 4 additions & 4 deletions cuda/test/matrix/ell_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ TEST_F(Ell, InplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_data();

mtx->apply_absolute();
dmtx->apply_absolute();
mtx->compute_absolute_inplace();
dmtx->compute_absolute_inplace();

GKO_ASSERT_MTX_NEAR(mtx.get(), dmtx.get(), 1e-14);
}
Expand All @@ -371,8 +371,8 @@ TEST_F(Ell, OutplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_data();

auto abs_mtx = mtx->get_absolute();
auto dabs_mtx = dmtx->get_absolute();
auto abs_mtx = mtx->compute_absolute();
auto dabs_mtx = dmtx->compute_absolute();

GKO_ASSERT_MTX_NEAR(abs_mtx.get(), dabs_mtx.get(), 1e-14);
}
Expand Down
8 changes: 4 additions & 4 deletions cuda/test/matrix/hybrid_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ TEST_F(Hybrid, InplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_data();

mtx->apply_absolute();
dmtx->apply_absolute();
mtx->compute_absolute_inplace();
dmtx->compute_absolute_inplace();

GKO_ASSERT_MTX_NEAR(mtx.get(), dmtx.get(), 1e-14);
}
Expand All @@ -246,8 +246,8 @@ TEST_F(Hybrid, OutplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_data();

auto abs_mtx = mtx->get_absolute();
auto dabs_mtx = dmtx->get_absolute();
auto abs_mtx = mtx->compute_absolute();
auto dabs_mtx = dmtx->compute_absolute();

GKO_ASSERT_MTX_NEAR(abs_mtx.get(), dabs_mtx.get(), 1e-14);
}
Expand Down
8 changes: 4 additions & 4 deletions cuda/test/matrix/sellp_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ TEST_F(Sellp, InplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_matrix(32, 2);

mtx->apply_absolute();
dmtx->apply_absolute();
mtx->compute_absolute_inplace();
dmtx->compute_absolute_inplace();

GKO_ASSERT_MTX_NEAR(mtx.get(), dmtx.get(), 1e-14);
}
Expand All @@ -365,8 +365,8 @@ TEST_F(Sellp, OutplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_matrix(32, 2);

auto abs_mtx = mtx->get_absolute();
auto dabs_mtx = dmtx->get_absolute();
auto abs_mtx = mtx->compute_absolute();
auto dabs_mtx = dmtx->compute_absolute();

GKO_ASSERT_MTX_NEAR(abs_mtx.get(), dabs_mtx.get(), 1e-14);
}
Expand Down
8 changes: 4 additions & 4 deletions hip/test/matrix/coo_kernels.hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ TEST_F(Coo, InplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_data();

mtx->apply_absolute();
dmtx->apply_absolute();
mtx->compute_absolute_inplace();
dmtx->compute_absolute_inplace();

GKO_ASSERT_MTX_NEAR(mtx.get(), dmtx.get(), 1e-14);
}
Expand All @@ -286,8 +286,8 @@ TEST_F(Coo, OutplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_data();

auto abs_mtx = mtx->get_absolute();
auto dabs_mtx = dmtx->get_absolute();
auto abs_mtx = mtx->compute_absolute();
auto dabs_mtx = dmtx->compute_absolute();

GKO_ASSERT_MTX_NEAR(abs_mtx.get(), dabs_mtx.get(), 1e-14);
}
Expand Down
Loading

0 comments on commit 3ae2b45

Please sign in to comment.