wgblas
    Preparing search index...

    Class GpuMatrix

    Represents a row-major Float32Array matrix stored in GPU memory.

    The buffer holds rows * lda elements. lda (leading dimension) is the number of floats between the start of consecutive rows — must be >= cols. When lda === cols the matrix is dense with no padding.

    Index

    Properties

    Methods

    Properties

    _buf: GPUBuffer
    cols: number

    Number of columns.

    lda: number

    Leading dimension — stride between row starts (>= cols).

    rows: number

    Number of rows.

    Methods

    • Destroys the underlying GPU buffer. Call when the matrix is no longer needed to free GPU memory.

      Returns void

      import { init, GpuMatrix } from "wgblas";

      await init();
      const mat = GpuMatrix.from(new Float32Array([1,2,3,4,5,6]), 2, 3);
      mat.destroy();
    • Uploads a row-major Float32Array matrix to GPU memory.

      lda defaults to cols (dense, no padding between rows). data must have at least rows * lda elements.

      Parameters

      • data: Float32Array

        matrix data in row-major order

      • rows: number

        number of rows

      • cols: number

        number of columns

      • Optionallda: number

        leading dimension (default: cols)

      Returns GpuMatrix

      import { init, GpuMatrix } from "wgblas";

      await init();
      // 2×3 matrix: [[1,2,3],[4,5,6]]
      const mat = GpuMatrix.from(new Float32Array([1,2,3,4,5,6]), 2, 3);
      console.log(mat.rows, mat.cols, mat.lda); // 2 3 3