Getting Started

This page describes the environment setup, build path, and runtime validation for the framework.

Requirements

Debian/Ubuntu

sudo apt update
sudo apt install php-cli php-ffi gcc libopenblas-dev liblapacke-dev composer

Install the repository

cd /home/ghost/projects/php/lab/ffi
composer install

Build and verify the native backend

The native backend is built automatically when Pml\Lib\TensorEngine::get() is first called.

Manual build:

cd src/Lib
gcc -O3 -march=native -mtune=native -mfma -fno-math-errno -funsafe-math-optimizations \
    -fopenmp -funroll-loops -fomit-frame-pointer -D_GNU_SOURCE -shared -fPIC \
    -o libtensor.so.7 tensor.c dataset_io.c inference.c autograd.c graph.c \
    -lopenblas -llapacke -lm
ln -sf libtensor.so.7 libtensor.so

Verify runtime

php -r 'require "vendor/autoload.php"; echo Pml\Lib\TensorEngine::get() ? "OK\n" : "FAIL\n";'

Validate dataset ingestion

<?php
require 'vendor/autoload.php';
use Pml\Dataset;

$dataset = Dataset::load('datasets/housing/train.csv');
var_dump($dataset->numRows());

Validate tensor operations

<?php
require 'vendor/autoload.php';
use Pml\Tensor;

$t = Tensor::zeros(4, 4);
$t->fill(1.0);
var_export($t->shape());

Runtime checklist