Skip to content

Commit

Permalink
Review updates
Browse files Browse the repository at this point in the history
Co-authored-by: Terry Cojean <terry.cojean@kit.edu>
  • Loading branch information
pratikvn and tcojean committed Oct 11, 2023
1 parent 927e8c8 commit 190a010
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 32 deletions.
1 change: 0 additions & 1 deletion core/matrix/batch_dense_kernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#include <ginkgo/core/base/batch_multi_vector.hpp>
#include <ginkgo/core/base/math.hpp>
#include <ginkgo/core/base/types.hpp>


Expand Down
8 changes: 2 additions & 6 deletions core/test/matrix/batch_dense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ TYPED_TEST(Dense, CanBeConstructedFromDenseMatrices)
using value_type = typename TestFixture::value_type;
using DenseMtx = typename TestFixture::DenseMtx;
using size_type = gko::size_type;

auto mat1 = gko::initialize<DenseMtx>({{-1.0, 2.0, 3.0}, {-1.5, 2.5, 3.5}},
this->exec);
auto mat2 = gko::initialize<DenseMtx>({{1.0, 2.5, 3.0}, {1.0, 2.0, 3.0}},
Expand All @@ -275,16 +274,15 @@ TYPED_TEST(Dense, CanBeConstructedFromDenseMatricesByDuplication)
using value_type = typename TestFixture::value_type;
using DenseMtx = typename TestFixture::DenseMtx;
using size_type = gko::size_type;

auto mat1 = gko::initialize<DenseMtx>(
4, {{-1.0, 2.0, 3.0}, {-1.5, 2.5, 3.5}}, this->exec);
auto mat2 = gko::initialize<DenseMtx>({{1.0, 2.5, 3.0}, {1.0, 2.0, 3.0}},
this->exec);

auto bat_m =
gko::batch::create_from_item<gko::batch::matrix::Dense<value_type>>(
this->exec,
std::vector<DenseMtx*>{mat1.get(), mat1.get(), mat1.get()});

auto m =
gko::batch::create_from_item<gko::batch::matrix::Dense<value_type>>(
this->exec, 3, mat1.get());
Expand All @@ -298,12 +296,10 @@ TYPED_TEST(Dense, CanBeConstructedByDuplicatingDenseMatrices)
using value_type = typename TestFixture::value_type;
using DenseMtx = typename TestFixture::DenseMtx;
using size_type = gko::size_type;

auto mat1 = gko::initialize<DenseMtx>({{-1.0, 2.0, 3.0}, {-1.5, 2.5, 3.5}},
this->exec);
auto mat2 = gko::initialize<DenseMtx>({{1.0, 2.5, 3.0}, {1.0, 2.0, 3.0}},
this->exec);

auto m =
gko::batch::create_from_item<gko::batch::matrix::Dense<value_type>>(
this->exec, std::vector<DenseMtx*>{mat1.get(), mat2.get()});
Expand Down Expand Up @@ -342,6 +338,7 @@ TYPED_TEST(Dense, CanBeUnbatchedIntoDenseMatrices)
TYPED_TEST(Dense, CanBeListConstructed)
{
using value_type = typename TestFixture::value_type;

auto m = gko::batch::initialize<gko::batch::matrix::Dense<TypeParam>>(
{{1.0, 2.0}, {1.0, 3.0}}, this->exec);

Expand Down Expand Up @@ -406,7 +403,6 @@ TYPED_TEST(Dense, CanBeReadFromMatrixData)
{
using value_type = typename TestFixture::value_type;
using index_type = int;

auto vec_data = std::vector<gko::matrix_data<value_type, index_type>>{};
vec_data.emplace_back(gko::matrix_data<value_type, index_type>(
{2, 2}, {{0, 0, 1.0}, {0, 1, 3.0}, {1, 0, 0.0}, {1, 1, 5.0}}));
Expand Down
3 changes: 0 additions & 3 deletions cuda/matrix/batch_dense_kernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#include <thrust/functional.h>
#include <thrust/transform.h>


#include <ginkgo/core/base/math.hpp>
Expand All @@ -44,8 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "core/matrix/batch_struct.hpp"
#include "cuda/base/batch_struct.hpp"
#include "cuda/base/config.hpp"
#include "cuda/base/cublas_bindings.hpp"
#include "cuda/base/pointer_mode_guard.hpp"
#include "cuda/base/thrust.cuh"
#include "cuda/components/cooperative_groups.cuh"
#include "cuda/components/reduction.cuh"
Expand Down
3 changes: 0 additions & 3 deletions cuda/matrix/batch_struct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "core/matrix/batch_struct.hpp"


#include <ginkgo/core/base/batch_multi_vector.hpp>
#include <ginkgo/core/base/math.hpp>
#include <ginkgo/core/matrix/batch_dense.hpp>


#include "core/base/batch_struct.hpp"
#include "cuda/base/config.hpp"
#include "cuda/base/types.hpp"


Expand Down
2 changes: 0 additions & 2 deletions dpcpp/matrix/batch_struct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "core/matrix/batch_struct.hpp"


#include <ginkgo/core/base/math.hpp>
#include <ginkgo/core/matrix/batch_dense.hpp>


#include "core/base/batch_struct.hpp"
#include "dpcpp/base/config.hpp"


namespace gko {
Expand Down
3 changes: 0 additions & 3 deletions hip/matrix/batch_dense_kernels.hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <hip/hip_runtime.h>
#include <thrust/functional.h>
#include <thrust/transform.h>


#include <ginkgo/core/base/math.hpp>
Expand All @@ -46,8 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "core/matrix/batch_struct.hpp"
#include "hip/base/batch_struct.hip.hpp"
#include "hip/base/config.hip.hpp"
#include "hip/base/hipblas_bindings.hip.hpp"
#include "hip/base/pointer_mode_guard.hip.hpp"
#include "hip/base/thrust.hip.hpp"
#include "hip/components/cooperative_groups.hip.hpp"
#include "hip/components/reduction.hip.hpp"
Expand Down
3 changes: 0 additions & 3 deletions hip/matrix/batch_struct.hip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "core/matrix/batch_struct.hpp"


#include <ginkgo/core/base/batch_multi_vector.hpp>
#include <ginkgo/core/base/math.hpp>
#include <ginkgo/core/matrix/batch_dense.hpp>


#include "core/base/batch_struct.hpp"
#include "hip/base/config.hip.hpp"
#include "hip/base/types.hip.hpp"


Expand Down
3 changes: 3 additions & 0 deletions include/ginkgo/core/matrix/batch_dense.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class Dense final : public EnableBatchLinOp<Dense<ValueType>>,
*/
size_type get_cumulative_offset(size_type batch_id) const
{
GKO_ASSERT(batch_id < this->get_num_batch_items());

Check warning on line 136 in include/ginkgo/core/matrix/batch_dense.hpp

View check run for this annotation

Codecov / codecov/patch

include/ginkgo/core/matrix/batch_dense.hpp#L136

Added line #L136 was not covered by tests
return batch_id * this->get_common_size()[0] *
this->get_common_size()[1];
}
Expand Down Expand Up @@ -198,6 +199,7 @@ class Dense final : public EnableBatchLinOp<Dense<ValueType>>,
*/
ValueType& at(size_type batch_id, size_type idx) noexcept
{
GKO_ASSERT(batch_id < this->get_num_batch_items());

Check warning on line 202 in include/ginkgo/core/matrix/batch_dense.hpp

View check run for this annotation

Codecov / codecov/patch

include/ginkgo/core/matrix/batch_dense.hpp#L202

Added line #L202 was not covered by tests
return values_.get_data()[linearize_index(batch_id, idx)];
}

Expand All @@ -206,6 +208,7 @@ class Dense final : public EnableBatchLinOp<Dense<ValueType>>,
*/
ValueType at(size_type batch_id, size_type idx) const noexcept

Check warning on line 209 in include/ginkgo/core/matrix/batch_dense.hpp

View check run for this annotation

Codecov / codecov/patch

include/ginkgo/core/matrix/batch_dense.hpp#L209

Added line #L209 was not covered by tests
{
GKO_ASSERT(batch_id < this->get_num_batch_items());
return values_.get_const_data()[linearize_index(batch_id, idx)];

Check warning on line 212 in include/ginkgo/core/matrix/batch_dense.hpp

View check run for this annotation

Codecov / codecov/patch

include/ginkgo/core/matrix/batch_dense.hpp#L211-L212

Added lines #L211 - L212 were not covered by tests
}

Expand Down
2 changes: 0 additions & 2 deletions reference/matrix/batch_struct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "core/matrix/batch_struct.hpp"


#include <ginkgo/core/base/batch_multi_vector.hpp>
#include <ginkgo/core/base/math.hpp>
#include <ginkgo/core/base/types.hpp>
#include <ginkgo/core/matrix/batch_dense.hpp>

Expand Down
16 changes: 8 additions & 8 deletions test/matrix/batch_dense_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ class Dense : public CommonTestFixture {
{
const int num_rows = 252;
const int num_cols = 32;
x = gen_mtx<BMtx>(batch_size, num_rows, num_cols);
mat = gen_mtx<BMtx>(batch_size, num_rows, num_cols);
y = gen_mtx<BMVec>(batch_size, num_cols, num_vecs);
alpha = gen_mtx<BMVec>(batch_size, 1, 1);
beta = gen_mtx<BMVec>(batch_size, 1, 1);
dx = gko::clone(exec, x);
dmat = gko::clone(exec, mat);
dy = gko::clone(exec, y);
dalpha = gko::clone(exec, alpha);
dbeta = gko::clone(exec, beta);
Expand All @@ -93,13 +93,13 @@ class Dense : public CommonTestFixture {
std::default_random_engine rand_engine;

const size_t batch_size = 11;
std::unique_ptr<BMtx> x;
std::unique_ptr<BMtx> mat;
std::unique_ptr<BMVec> y;
std::unique_ptr<BMVec> alpha;
std::unique_ptr<BMVec> beta;
std::unique_ptr<BMVec> expected;
std::unique_ptr<BMVec> dresult;
std::unique_ptr<BMtx> dx;
std::unique_ptr<BMtx> dmat;
std::unique_ptr<BMVec> dy;
std::unique_ptr<BMVec> dalpha;
std::unique_ptr<BMVec> dbeta;
Expand All @@ -110,8 +110,8 @@ TEST_F(Dense, SingleVectorApplyIsEquivalentToRef)
{
set_up_apply_data(1);

x->apply(y.get(), expected.get());
dx->apply(dy.get(), dresult.get());
mat->apply(y.get(), expected.get());
dmat->apply(dy.get(), dresult.get());

GKO_ASSERT_BATCH_MTX_NEAR(dresult, expected, r<value_type>::value);
}
Expand All @@ -121,8 +121,8 @@ TEST_F(Dense, SingleVectorAdvancedApplyIsEquivalentToRef)
{
set_up_apply_data(1);

x->apply(alpha.get(), y.get(), beta.get(), expected.get());
dx->apply(dalpha.get(), dy.get(), dbeta.get(), dresult.get());
mat->apply(alpha.get(), y.get(), beta.get(), expected.get());
dmat->apply(dalpha.get(), dy.get(), dbeta.get(), dresult.get());

GKO_ASSERT_BATCH_MTX_NEAR(dresult, expected, r<value_type>::value);
}
2 changes: 1 addition & 1 deletion test/test_install/test_install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ int main()
// core/base/batch_dense.hpp
{
using type1 = float;
using batch_dense_type = gko::batch::Dense<type1>;
using batch_dense_type = gko::batch::matrix::Dense<type1>;
auto test = batch_dense_type::create(exec);
}

Expand Down

0 comments on commit 190a010

Please sign in to comment.