C++ High-Performance ML

C++

High-performance neural network implementation with CUDA acceleration

Tech Stack

C++ 23
CUDA 12.4
CMake
pybind11
Python

Features

Tensor & Matrix operations
Neural network from scratch
CUDA-accelerated computations
Python bindings via pybind11
Comprehensive benchmarks

Code Sample

tensor.cpp
#include "tensor.h"
#include <cuda_runtime.h>

__global__ void matmul_kernel(float* A, float* B, float* C,
                               int M, int N, int K) {
    int row = blockIdx.y * blockDim.y + threadIdx.y;
    int col = blockIdx.x * blockDim.x + threadIdx.x;

    if (row < M && col < N) {
        float sum = 0.0f;
        for (int k = 0; k < K; k++) {
            sum += A[row * K + k] * B[k * N + col];
        }
        C[row * N + col] = sum;
    }
}

Tensor Tensor::matmul(const Tensor& other) {
    Tensor result(rows_, other.cols_);
    matmul_kernel<<<grid, block>>>(
        data_, other.data_, result.data_,
        rows_, other.cols_, shared_dim_
    );
    return result;
}
View Source Docker Hub Live Demo