daphne-project/daphne

Slicing column segments out of CSRMatrix

开放

#219 创建于 2022年3月11日

 (1 条评论) (0 个反应) (0 位负责人)C++ (84 个派生)auto 404
good first issue

仓库指标

星标
 (80 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

In GitLab by @pdamme on Mar 11, 2022, 13:11

DAPHNE data types need to support extracting rectangular fragments out of them. This is required at several points, e.g.

  • in the vectorized engine, where we split the input into segments for multi-threaded and cache-conscious processing
  • for so-called right indexing in DaphneDSL, where a user might want to extract a certain part out of a data object (for instance, x[100:200, 3:5]; extracts rows 100 to 199 of columns 3 to 4 from x)

For that reason, Structure, the superclass of all DAPHNE data types, defines the following slicing methods:

  • sliceRow(rl, ru) -> extracts a row segment (all columns, but only a segment of the rows)
  • sliceCol(cl, cu) -> extracts a column segment (all rows, but only a segment of the columns)
  • slice(rl, ru, cl, cu) -> extracts the intersection of a row and a column segment

We already have implementations for DenseMatrix and Frame, but CSRMatrix supports only sliceRow so far.

The Task:

  1. Implement CSRMatrix::sliceCol().
  2. Optionally implement CSRMatrix::slice().

Hints:

  • In contrast to the existing slice/sliceRow/sliceCol implementations, sliceCol on CSRMatrix is no zero-copy operation, in the general case. Thus, you need to create a fresh CSRMatrix.
  • A possible approach could be as follows: For each row: find the range of colIdx-value pairs which are within the bounds of the column segment to extract (note that column indexes are sorted within each row), and copy those over to the output CSRMatrix.
  • Optionally, you may also implement the general slice on CSRMatrix, that should be straightforward once you've implemented sliceCol.

贡献者指南