Skip to content

High-performance C++20 neural network framework powered by Intel oneAPI MKL 2025.2. Optimized for CPU-based deep learning inference and training.

License

Notifications You must be signed in to change notification settings

Mostafasaad1/KortexDL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

139 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

KortexDL Framework

KortexDL Logo

High-Performance Neural Network Framework
Powered by Intel oneAPI MKL 2025.2 & C++20

Build Status License C++ Standard Intel MKL


πŸš€ Overview

KortexDL is a modern, high-performance deep learning framework written in C++20, leveraging Intel's oneAPI Math Kernel Library (MKL) for optimized linear algebra operations. The framework provides both C++ and Python interfaces, making it suitable for research and production environments.

Key Features

  • ⚑ MKL-Optimized: Built on Intel oneAPI MKL 2025.2 for maximum numerical performance
  • 🎯 Modern C++20: Clean, type-safe implementation using latest C++ features
  • 🐍 Python Bindings: Full-featured Python API via pybind11
  • 🧠 Comprehensive Layers: Dense, CNN, normalization, dropout, and more
  • πŸ“Š 12 Optimizers: SGD, Adam, AdamW, RMSprop, Adadelta, and more
  • πŸ”„ 15 Activations: ReLU, GELU, Swish, Mish, and all standard functions
  • πŸ“ˆ Flexible Training: Custom loss functions, metrics, and learning rate schedulers
  • πŸ—οΈ Modular Design: Easy to extend with custom layers and operations

πŸ“¦ Quick Start

Prerequisites

  • Intel oneAPI Toolkit 2025.2+ (includes MKL)
  • CMake 3.20+
  • C++20 compatible compiler (GCC 12+, Clang 15+, or Intel ICX)
  • Python 3.8+ (for Python bindings)

Installation

# Clone the repository
git clone https://github.com/Mostafasaad1/kortexdl.git
cd kortexdl

# Source Intel oneAPI environment
source ~/intel/oneapi/setvars.sh

# Build C++ library
mkdir build && cd build
cmake .. -DCMAKE_CXX_COMPILER=icpx -DCMAKE_BUILD_TYPE=Release
cmake --build . -j$(nproc)

# Build Python bindings (optional)
cd ..
cmake build -DBUILD_PYTHON_BINDINGS=ON
cmake --build build --target _kortexdl_core -j$(nproc)

For detailed instructions, see Installation Guide.


πŸ”₯ Quick Example

C++ Example

#include "KortexDL.hpp"
using namespace KortexDL;

int main() {
    // Create a simple network
    Network net({784, 128, 64, 10}, ActivationType::ReLU);
    
    // Train on data
    net.train_batch(inputs, targets, LossType::CrossEntropy, 
                    0.001f /*lr*/, 32 /*batch_size*/);
    
    // Make predictions
    auto predictions = net.forward(test_input, 1, false);
    
    return 0;
}

Python Example

import _kortexdl_core as bd
import numpy as np

# Create network
net = bd.Network([784, 128, 64, 10], bd.ActivationType.ReLU)

# Train
net.train_with_monitoring(
    X_train, y_train,
    bd.LossType.CrossEntropy,
    learning_rate=0.001,
    batch_size=32,
    epochs=10
)

# Predict
predictions = net.forward(test_sample, 1, False)

πŸ“‚ Project Structure

KortexDL/
β”œβ”€β”€ include/          # C++ headers
β”‚   β”œβ”€β”€ core/        # Core components (Layer, Network, Tensor)
β”‚   β”œβ”€β”€ cnn/         # CNN layers (Conv2d, MaxPool2d, etc.)
β”‚   └── optimization/# Optimizers and LR schedulers
β”œβ”€β”€ src/             # C++ implementation
β”œβ”€β”€ python_bindings/ # Python API
β”‚   β”œβ”€β”€ src/        # pybind11 bindings
β”‚   β”œβ”€β”€ tests/      # pytest suite
β”‚   └── examples/   # Python examples
β”œβ”€β”€ examples/        # C++ examples
β”œβ”€β”€ tests/           # C++ tests
β”œβ”€β”€ docs/            # Documentation
└── docker/          # Docker configurations

⚠️ Known Issues

  • Nesterov Optimizer Bug: Contains logic error (documented, not fixed). See KNOWN_ISSUES.md
  • Python Optimizer Bindings: Optimizer.update() not accessible from Python
  • Limited Python Activations: Only 8/15 activations exposed to Python

For complete list, see KNOWN_ISSUES.md.


πŸ“š Documentation


πŸ§ͺ Examples

C++ Examples

  • examples/linear_function_examples/regression_example.cpp - Simple regression
  • examples/cnn_demo.cpp - CNN layers demonstration
  • examples/flight_delay_examples/ - Real-world dataset example

Python Examples

  • python_bindings/examples/cnn_demo.py - CNN layers in Python
  • See python_bindings/tests/ for comprehensive usage examples

πŸ› οΈ Development

Building Tests

cmake --build build --target run_tests
cd build && ctest --output-on-failure

Python Tests

cd python_bindings
pytest tests/ -v

Code Style

./scripts/lint.sh --format  # Format code
./scripts/lint.sh --tidy    # Static analysis

🀝 Contributing

Contributions are welcome! Please see the contributing guidelines (coming soon).


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Intel for the oneAPI Math Kernel Library
  • pybind11 team for excellent Python bindings support
  • All contributors and users of KortexDL

Made with ❀️ by Mostafa Saad

GitHub β€’ Documentation β€’ Examples

Releases

No releases published

Packages

No packages published

Languages