How godrays/aix works
Project type and purpose
• This is a C++ machine-learning framework library (AIX) with accompanying CLI tools (benchmarks, tests) and example applications.
• Its primary goal is to provide a highly-readable, single-header API for tensors, dynamic graphs, autodiff, and plug-and-play hardware acceleration.
File structure
• Top-level:
• CMakeLists.txt + build.py → Build system orchestrator (configures, compiles, links).
• Externals/Externals.cmake → Third-party dependency hooks (though AIX is header-only).
• Targets/ → All build targets, subdivided into:
– AIXLib → Core library source (aix.hpp, device implementations, floats, version).
– AIXExamples → Example apps demonstrating API usage.
– AIXTests → Unit tests for Tensor, Autograd, Devices, Ops.
– AIXBenchmarks → Benchmark CLI.
README insights
• Core classes: Tensor, TensorValue, Device.
• Layers built on core: nn::Sequential, Linear, Activations, Losses, Optimizers.
• Device plugin model: reference device in aix.hpp, Metal device in aixDeviceMetal.cpp, and guidelines for adding more.
• Build flags: AIX_BUILD_STATIC, AIX_BUILD_EXAMPLES, AIX_BUILD_TESTS.
Main components
a. AIX Core Library
• Tensor & dynamic computation graph subsystem
• TensorValue for device-side data
• Device abstract base + reference device implementation
b. Hardware Acceleration Layer
• Metal device implementation (aixDeviceMetal.{cpp,hpp})
• DeviceCache, Shaders
• Hook for custom devices
c. Neural-Network API Layer
• nn::Module (Sequential, Linear, Activations, Losses)
• optim::Optimizer subclasses (SGD, Adam)
d. Build System & Packaging
• CMake + Externals.cmake
• build.py script (build targets: library, tests, benchmarks, examples)
e. CLI Tools & Examples
• AIXTests (unit-test runner)
• AIXBenchmarks (benchmarking CLI)
• AIXExamples (XORApp, XORLayerApp, etc.)
Relationships and interactions
• Build system compiles AIXLib → static/dynamic library.
• CLI tools and examples link against AIXLib → execute Tensor/Device/nn APIs.
• During runtime: Examples/Benchmarks → call Model.forward/backward → Tensor operations → dispatched to Device implementation → hardware or reference.
• Extensibility: New devices derive from Device base and plug into core via factory (createDevice).
Architectural patterns & design principles
• Layered modular design: Core → Device → NN/Optim → Applications
• Plugin pattern for Device implementations
• Single-header façade with optional .cpp for devices
• Separation of compute graph (Tensor) vs. compute backends (Device)
Essential details to capture
• All four Targets subfolders as separate components.
• Core classes and the plugin device factory.
• Example apps as clients of the API.
• Build system’s dual role: static vs. examples/tests toggles.
• Clearly labels each module, target, and script.
• Captures the plug-and-play nature of devices and the layering from Tensor → Device → Application.