wgblas
    Preparing search index...

    Class GpuVector

    Represents a Float32Array stored in GPU memory.

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    _buf: GPUBuffer
    dtype: Float32ArrayConstructor

    Typed array constructor used when reading data back from the GPU.

    length: number

    Number of elements in the vector.

    Methods

    • Destroys the underlying GPU buffer. Call when the vector is no longer needed to free GPU memory — especially important in long-running programs.

      Returns void

      import { init, GpuVector } from "wgblas";

      await init();
      const vec = GpuVector.from(new Float32Array([1, 2, 3, 4]));
      vec.destroy();
      console.log("GPU buffer released");
    • Reads the vector data back from GPU memory.

      Returns Promise<Float32Array<ArrayBufferLike>>

      vector data as a Float32Array

      import { init, GpuVector } from "wgblas";

      await init();
      const vec = GpuVector.from(new Float32Array([1, 2, 3, 4]));
      const data = await vec.read();
      console.log(data);
    • Uploads a Float32Array to GPU memory.

      Parameters

      • data: Float32Array

        input vector data

      Returns GpuVector

      GpuVector backed by a GPU buffer

      import { init, GpuVector } from "wgblas";

      await init();
      const vec = GpuVector.from(new Float32Array([1, 2, 3, 4]));
      console.log("length:", vec.length, "dtype:", vec.dtype.name);