EzTensors is a neural network library written in C / C++ from scratch. This project is not intended to be used for production but mainly for educational and research purposes. This project uses GTest as the testing suite and CMake as the build tool for the project, all CMake configurations can be found in CMakeLists.txt. The optimizations chosen are still limited at the moment since this is still a work in progress as I continously learn more and more about neural network libraries and modern AI engines.
[] Llama 3.2 - (50% done)
- https://salykova.github.io/matmul-cpu
- https://github.com/meta-llama/llama
- https://andrewkchan.dev/posts/yalm.html
- https://mesozoic-egg.github.io/tinygrad-notes/
- Tensors are arranged in row-major format in memory, meaning accessing elements sequentially is equivalent to a index-by-index increment from smallest dimension to largest.
- Tensors have a
data
attribute that is encapsulated with a shared pointer. - Just like torch,
view
only works on contiguous tensors and points to the same memory as the original tensor just with different stride and shape metadata,reshape
returns a view if the tensor is contiguous. If the tensor was not contiguous it performs a copy with contiguous layout then returns a view - Matrix Muliplitcaions
- Tensors have 4 main operations
-
- Tensor Manipulations
-
- Element-Wise Operations
-
- Reduction Operations
-
- Matrix Mulitplications and Convolutions
-
- (Bonus) Fused operations (TBD)
-
- First clone the repository
git clone https://github.com/ambroseling/eztensors.git
- Install CMake
brew install cmake
- Build and compile the project
// Generate build files in the build directory based on the CMakeLists.txt in the source directory in .
// CMake scans CMakeLists.txt to find the compiler, look for dependencies, generate build rules and configures builkd targets for executables
cmake -S . -B build
// Compiles the project using the generated build files
cmake --build build
- Run Tests
// This runs all the tests registed under `add_test()` in CMakeLists.txt
cd build && ctest