UNPKG

cuda.js

Version:

CUDA bindings for Node.js

72 lines 1.54 kB
/** * GPU array wrapper similar to PyCuda's GPUArray */ export declare class GpuArray { private buffer; private _shape; private _dtype; private _size; /** * Create a new GPU array * @param data - Initial data or size * @param dtype - Data type (default: 'float32') */ constructor(data?: number[] | Float32Array | number, dtype?: string); /** * Get the shape of the array */ get shape(): number[]; /** * Get the data type */ get dtype(): string; /** * Get the total number of elements */ get size(): number; /** * Get bytes per element based on dtype */ private getBytesPerElement; /** * Upload data to GPU */ upload(data: number[] | Float32Array): void; /** * Download data from GPU */ download(): Float32Array; /** * Get data as regular array */ toArray(): number[]; /** * Fill array with zeros */ zero(): void; /** * Fill array with a value */ fill(value: number): void; /** * Copy data from another GPU array */ copyFrom(other: GpuArray): void; /** * Create a copy of this array */ copy(): GpuArray; /** * Reshape the array (view only, doesn't change memory layout) */ reshape(shape: number[]): GpuArray; /** * Free GPU memory */ free(): void; /** * String representation */ toString(): string; } //# sourceMappingURL=gpu-array.d.ts.map