Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/matrix/fbcsr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ void Fbcsr<ValueType, IndexType>::read(const mat_data &data)
blocks.size() * bs * bs, bs);

tmp->row_ptrs_.get_data()[0] = 0;
if (data.nonzeros.size() == 0) {
tmp->move_to(this);
return;
}

index_type cur_brow = 0;
index_type cur_bnz = 0;
index_type cur_bcol = blocks.begin()->first.block_column;
Expand Down
18 changes: 18 additions & 0 deletions core/test/matrix/fbcsr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,24 @@ TYPED_TEST(Fbcsr, CanBeReadFromMatrixData)
}


TYPED_TEST(Fbcsr, CanBeReadFromEmptyMatrixData)
{
using Mtx = typename TestFixture::Mtx;
using MtxData = typename TestFixture::MtxData;
auto m = Mtx::create(this->exec);
m->set_block_size(this->fbsample.bs);
MtxData mdata;
mdata.size = gko::dim<2>{0, 0};

m->read(mdata);

ASSERT_EQ(m->get_size(), (gko::dim<2>{0, 0}));
ASSERT_EQ(m->get_const_row_ptrs()[0], 0);
ASSERT_EQ(m->get_const_col_idxs(), nullptr);
ASSERT_EQ(m->get_const_values(), nullptr);
}


TYPED_TEST(Fbcsr, GeneratesCorrectMatrixData)
{
using value_type = typename TestFixture::value_type;
Expand Down