Skip to content

Kaweees/kiwigrad

Repository files navigation

Contributors Forks Stargazers

Zig Logo

A scalar-valued automatic differentiation (autograd) engine for deep learning written in Zig.

Built With

Zig NixOS GitHub Actions

Preview

MLP Perceptron

Getting Started

Prerequisites

Before attempting to build this project, make sure you have Nix with Flake support installed on your machine.

Installation

To get a local copy of the project up and running on your machine, follow these simple steps:

  1. Clone the project repository

    git clone https://github.com/Kaweees/kiwigrad.git
    cd kiwigrad
  2. Install the project dependencies

    nix-shell --max-jobs $(nproc) # Linux / Windows (WSL)
    nix-shell --max-jobs $(sysctl -n hw.ncpu) # macOS
  3. Build the project

    just build
  4. Run the project

    just run

Add as a dependency

To include kiwigrad in your Zig project, follow these steps:

  1. Add to your build.zig.zon file via zig fetch:

    zig fetch --save git+https://github.com/Kaweees/kiwigrad.git
  2. Add the following line to your build.zig file:

    const kiwigrad = @import("kiwigrad");
    
    pub fn build(b: *std.Build) void {
        // exe setup...
    
        const KiwiGrad_dep = b.dependency("kiwigrad", .{
            .target = target,
            .optimize = optimize,
        });
    
        const KiwiGrad_module = KiwiGrad_dep.module("kiwigrad");
        exe.root_module.addImport("kiwigrad", KiwiGrad_module);
    
        // additional build steps...
    }
    

Usage

kiwigrad is designed to be easy to use. You can include the library in your Zig project by adding the following line to your source files:

const kiwigrad = @import("kiwigrad");

Benchmarks

kiwigrad is capable of rendering 3D scenes with thousands of triangles at interactive frame rates. The following benchmarks were conducted on a 2019 MacBook Pro with a 2.3 GHz 8-Core Intel Core i9 processor and 16 GB of RAM.

Benchmark Description Result
cube Render a cube with 12 triangles 60 FPS
sphere Render a sphere with 960 triangles 60 FPS
bunny Render a Stanford Bunny with 69451 triangles 60 FPS
dragon Render a Stanford Dragon with 871306 triangles 60 FPS

Project Structure

kiwigrad/
├── .github/                       # GitHub Actions CI/CD workflows
├── src/                           # Library source files
│   ├── lib.zig                      # Public API entry point
│   └── ...
├── examples/                      # Example projects
│   ├── benchmark.zig                # Benchmarking the library
│   └── train.zig                    # Training a model on MNIST
├── build.zig                      # Zig build script
├── build.zig.zon                  # Zig build script dependencies
├── LICENSE                        # Project license
└── README.md                      # You are here

License

The source code for Kaweees/kiwigrad is distributed under the terms of the MIT License, as I firmly believe that collaborating on free and open-source software fosters innovations that mutually and equitably beneficial to both collaborators and users alike. See LICENSE for details and more information.

About

A scalar-valued automatic differentiation (autograd) engine for deep learning written in Zig.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages