Skip to content

Commit

Permalink
review updates:
Browse files Browse the repository at this point in the history
- ensure equal bounds
- don't make row_ptrs owning

Co-authored-by: Tobias Ribizel <[email protected]>
  • Loading branch information
MarcelKoch and upsj committed Nov 28, 2023
1 parent dc1a10f commit 9d106fc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/matrix/csr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ void Csr<ValueType, IndexType>::read(device_mat_data&& data)
auto size = data.get_size();
auto exec = this->get_executor();
auto arrays = data.empty_out();
this->row_ptrs_ = array<IndexType>{exec, size[0] + 1};
this->row_ptrs_.resize_and_reset(size[0] + 1);
this->set_size(size);
this->values_ = std::move(arrays.values);
this->col_idxs_ = std::move(arrays.col_idxs);
Expand Down
2 changes: 1 addition & 1 deletion core/test/matrix/csr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ TYPED_TEST(Csr, CanBeReadFromMovedDeviceMatrixDataIntoViews)
m->read(std::move(device_data));

this->assert_equal_to_original_mtx(m);
ASSERT_NE(row_ptrs.get_data(), m->get_row_ptrs());
ASSERT_EQ(row_ptrs.get_data(), m->get_row_ptrs());
ASSERT_NE(col_idxs.get_data(), m->get_col_idxs());
ASSERT_NE(values.get_data(), m->get_values());
}
Expand Down
6 changes: 3 additions & 3 deletions include/ginkgo/core/base/exception_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,16 +757,16 @@ inline T ensure_allocated_impl(T ptr, const std::string& file, int line,

/**
* Ensures that two dimensions have compatible bounds, in particular before a
* copy operation. This means the target should have at least as much elements
* copy operation. This means the target should have the same number of elements
* as the source.
*
* @param _source the source of the expected copy operation
* @param _target the destination of the expected copy operation
*
* @throw OutOfBoundsError if `_source > _target`
* @throw OutOfBoundsError if `_source != _target`
*/
#define GKO_ENSURE_COMPATIBLE_BOUNDS(_source, _target) \
if (_source > _target) { \
if ((_source) != (_target)) { \
throw ::gko::OutOfBoundsError(__FILE__, __LINE__, _source, _target); \
} \
static_assert(true, \
Expand Down

0 comments on commit 9d106fc

Please sign in to comment.