koladata

Home
Overview
Fundamentals
Glossary
Cheatsheet
API Reference
Quick Recipes
Deep Dive
Common Pitfalls and Gotchas
Persistent Storage

View the Project on GitHub google/koladata

kd.matrix API

Matrix operations for Koda.

The kd.matrix library provides fully vectorized support of batches of
independent matrices. Leading dimensions are interpreted as batch dimensions.
In operators that take 2 or more matrix arguments, the batch dimensions are
subject to standard Koda broadcasting rules.

kd.matrix.transpose(x)

Transpose a matrix (swap last two dimensions).

Supports leading batch dimensions: (..., m, n) -> (..., n, m).
Leading batch dimensions (all except the last two) can be jagged.
The last two dimensions must be uniform within each matrix entry (i.e.,
every row of a given matrix must have the same number of columns), but
different matrix entries can have different shapes.
Preserves sparsity: None values remain None.
Works with any schema, including numeric, TEXT, BYTES, and entities.

Args:
  x: A DataSlice with at least 2 dimensions. The last two dimensions must be
    uniform within each matrix entry, but leading batch dimensions can be
    jagged.

Returns:
  The transposed DataSlice.