csrtable

This is summary documentation for hippynn.layers.pairs.csr_pairs.csrtable module. Click here for full documentation.

Links to Full Documentation:

This file was written with assistance from an LLM.

Light-weight CSRTable container built on PyTorch tensors and utilities.

This module defines: - starts_from_counts() — fast CSR row-pointer construction. - row_and_offset() — decode flat indices to (row, in-row offset). - CSRTable — a minimal, device/dtype-agnostic CSR container with

constructors, filtering, row reindexing, and row-wise Cartesian joins.

Conventions

  • All index tensors are torch.long.

  • Shapes are given in brackets, e.g. [R] for rows, [nnz] for entries.

  • device/dtype follow the tensors you pass in; no implicit moves/casts.

  • We avoid heavyweight validation in hot paths; use lightweight invariants below.

Invariants

Given a CSRTable with starts: [R+1], cols: [nnz], and data:

  • starts is non-decreasing with starts[0] == 0 and starts[-1] == nnz.

  • For each row r, row_len[r] = starts[r+1] - starts[r] >= 0.

  • Every v in data has length nnz and aligns with cols order.

Functions

find_indices(query_vals, keys)

Map query values to their indices in keys, or -1 if not found.

row_and_offset(starts)

Decode the flattened CSR value domain into row ids and in-row offsets.

starts_from_counts(counts)

Build a CSR row-pointer (starts) from per-row counts.

Classes

CSRTable(starts, cols[, data, reorder])

A minimal CSR container allowing for multiple payload arrays..