Skip to content

NumPower/numpower-composer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

NumPower

Typing SVG

Inspired by NumPy, the NumPower library was created to provide the foundation for efficient scientific computing in PHP, as well as leverage the machine learning tools and libraries that already exist and can benefit from it.

This C extension developed for PHP can be used to considerably speed up mathematical operations on large datasets and facilitate the manipulation, creation and operation of N-dimensional tensors.

NumPower was designed from the ground up to utilize AVX2 and the GPU to further improve performance. With the use of contiguous single precision arrays, slices, buffer sharing and a specific GC engine, NumPower aims to manage memory more efficiently than a matrix in PHP arrays

Typing SVG

Documentation & Installation

Requirements

Installing

$ composer require numpower/numpower

GPU Support

If you have an NVIDIA graphics card with CUDA support, you can use your graphics card to perform operations. To do this, just copy your array to the GPU memory.

use \NDArray as nd;

$x = nd::ones([10, 10]);
$y = nd::ones([10, 10]);

$x_gpu = $x->gpu();   // Copy $x from RAM to VRAM
$y_gpu = $y->gpu();   // Copy $y from RAM to VRAM

$r = nd::matmul($x_gpu, $y_gpu); // Matmul is performed using CUDA

Both GPU and CPU memory management are done automatically by NumPower, so the memory of both devices will be automatically freed by the garbage collector. You can also bring arrays back from VRAM into RAM:

$x_cpu = $x->cpu();

You must explicitly copy the arrays you want to use in your devices. Cross-array operations (like adding) will raise an exception if the arrays used are on different devices.

About

NumPower extension repository in composer

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages