DLAI is a streamlined repository focused on implementing core deep learning algorithms from scratch in C/C++. It is designed primarily for educational purposes and optimized for deployment on embedded systems and microcontrollers, supporting TinyML/EmbeddedAI applications. This repository serves as a foundational reference for understanding core deep learning principles and exploring TinyML applications.
- The project currently supports conversion of sequential neural networks from the PyTorch library only.
- It uses
torch.save()to save the full model, and loads it using:
torch.load(pth_file_path, weight_only=False)- Linear (Fully Connected) Layer
- ReLU Layer
Additional layers and features are actively under development.
- Algorithm Implementations: Basic neural network layers implemented from scratch.
- Embedded Systems Focus: Optimized for TinyML and embedded system deployment.
- Educational Resource: A practical reference for learning deep learning fundamentals and embedded deployment.
git clone https://github.com/Mat-thias/dlai.git
cd dlai
Run the script located in dlai/Models:
python3 dlai/Models/convert_sequential_model_to_c.py <model_file> <model_name> <input_shape> [output_dir]
Note: It is reocommended to create a virtual environment and install the packages in
dlai/Models/venv_requirement.txt
python3 dlai/Models/convert_sequential_model_to_c.py dlai/examples/sine_model/sine_model.pth sine_model "(1,1)" dlai/examples/sine_model/
Layer *graph[LAYER_LEN];
float workspace[MAX_WORKSPACE_SIZE];
Sequential model(sine_model, sine_model_len, graph, LAYER_LEN, workspace, MAX_WORKSPACE_SIZE);
float *input = model.input;
float *output = model.output;
*input = (float)i * 2 * 3.141 / 360;
model.predict();
Serial.println(*output);- Contains C/C++ source code for supported layers.
- Each implemented component includes inline documentation.
We welcome contributions to expand supported layers and improve the tool!
-
Fork the Repository on GitHub.
-
Clone Your Fork:
git clone https://github.com/your-username/dlai.git
-
Create a Feature Branch:
git checkout -b feature/your-feature-name
-
Make Your Changes.
-
Commit Your Changes:
git commit -m "Add your commit message" -
Push to Your Fork:
git push origin feature/your-feature-name
-
Open a Pull Request to the main repository.