diff --git a/.github/workflows/book-cd.yml b/.github/workflows/book-cd.yml new file mode 100644 index 000000000..fc693a789 --- /dev/null +++ b/.github/workflows/book-cd.yml @@ -0,0 +1,42 @@ +name: Deploy Rust book +on: + # TODO put this back only when merging after this PR lands. + pull_request: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: write # To push a branch + pull-requests: write # To create a PR from that branch + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Install latest mdbook + run: | + tag=$(curl 'https://github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name') + url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz" + mkdir mdbook + curl -sSL $url | tar -xz --directory=./mdbook + echo `pwd`/mdbook >> $GITHUB_PATH + - name: Deploy GitHub Pages + run: | + # This assumes your book is in the root of your repository. + # Just add a `cd` here if you need to change to another directory. + cd candle-book + mdbook build + git worktree add gh-pages + git config user.name "Deploy from CI" + git config user.email "" + cd gh-pages + # Delete the ref to avoid keeping history. + git update-ref -d refs/heads/gh-pages + rm -rf * + mv ../book/* . + git add . + git commit -m "Deploy $GITHUB_SHA to gh-pages" + git push --force --set-upstream origin gh-pages diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml new file mode 100644 index 000000000..895a68dbc --- /dev/null +++ b/.github/workflows/book.yml @@ -0,0 +1,29 @@ +name: CI +on: + pull_request: + +jobs: + test: + name: Test candle-book + runs-on: ubuntu-latest + permissions: + contents: write # To push a branch + pull-requests: write # To create a PR from that branch + steps: + - uses: actions/checkout@master + - name: Install Rust + run: | + rustup set profile minimal + rustup toolchain install stable + rustup default stable + - name: Install latest mdbook + run: | + tag=$(curl 'https://github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name') + url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz" + mkdir bin + curl -sSL $url | tar -xz --directory=bin + echo "$(pwd)/bin" >> $GITHUB_PATH + - name: Run tests + run: cd candle-book && mdbook test + + diff --git a/candle-book/.gitignore b/candle-book/.gitignore new file mode 100644 index 000000000..7585238ef --- /dev/null +++ b/candle-book/.gitignore @@ -0,0 +1 @@ +book diff --git a/candle-book/book.toml b/candle-book/book.toml new file mode 100644 index 000000000..f3b680bc3 --- /dev/null +++ b/candle-book/book.toml @@ -0,0 +1,6 @@ +[book] +authors = ["Nicolas Patry"] +language = "en" +multilingual = false +src = "src" +title = "Candle Documentation" diff --git a/candle-book/src/README.md b/candle-book/src/README.md new file mode 100644 index 000000000..e10b99d01 --- /dev/null +++ b/candle-book/src/README.md @@ -0,0 +1 @@ +# Introduction diff --git a/candle-book/src/SUMMARY.md b/candle-book/src/SUMMARY.md new file mode 100644 index 000000000..24e2b25ae --- /dev/null +++ b/candle-book/src/SUMMARY.md @@ -0,0 +1,26 @@ +# Summary + +[Introduction](README.md) + +# User Guide + +- [Installation](guide/installation.md) +- [Hello World - MNIST](guide/hello_world.md) +- [PyTorch cheatsheet](guide/hello_world.md) + +# Reference Guide + +- [Running a model](inference/README.md) + - [Serialization](inference/serialization.md) + - [Using the hub](inference/hub.md) + - [Advanced Cuda usage](inference/cuda/README.md) + - [Writing a custom kernel](inference/cuda/writing.md) + - [Porting a custom kernel](inference/cuda/porting.md) +- [Error management](error_manage.md) +- [Creating apps](apps/README.md) + - [Creating a WASM app](apps/wasm.md) + - [Creating a REST api webserver](apps/rest.md) + - [Creating a desktop Tauri app](apps/dekstop.md) +- [Training](training/README.md) + - [MNIST](training/mnist.md) + - [Fine-tuning](training/finetuning.md) diff --git a/candle-book/src/apps/README.md b/candle-book/src/apps/README.md new file mode 100644 index 000000000..e321eafaf --- /dev/null +++ b/candle-book/src/apps/README.md @@ -0,0 +1 @@ +# Creating apps diff --git a/candle-book/src/apps/dekstop.md b/candle-book/src/apps/dekstop.md new file mode 100644 index 000000000..32cc4441f --- /dev/null +++ b/candle-book/src/apps/dekstop.md @@ -0,0 +1 @@ +# Creating a desktop Tauri app diff --git a/candle-book/src/apps/rest.md b/candle-book/src/apps/rest.md new file mode 100644 index 000000000..c99e04dc7 --- /dev/null +++ b/candle-book/src/apps/rest.md @@ -0,0 +1 @@ +# Creating a REST api webserver diff --git a/candle-book/src/apps/wasm.md b/candle-book/src/apps/wasm.md new file mode 100644 index 000000000..d56cd1487 --- /dev/null +++ b/candle-book/src/apps/wasm.md @@ -0,0 +1 @@ +# Creating a WASM app diff --git a/candle-book/src/chapter_1.md b/candle-book/src/chapter_1.md new file mode 100644 index 000000000..b743fda35 --- /dev/null +++ b/candle-book/src/chapter_1.md @@ -0,0 +1 @@ +# Chapter 1 diff --git a/candle-book/src/error_manage.md b/candle-book/src/error_manage.md new file mode 100644 index 000000000..042e191f4 --- /dev/null +++ b/candle-book/src/error_manage.md @@ -0,0 +1 @@ +# Error management diff --git a/candle-book/src/guide/hello_world.md b/candle-book/src/guide/hello_world.md new file mode 100644 index 000000000..c370cdd3b --- /dev/null +++ b/candle-book/src/guide/hello_world.md @@ -0,0 +1 @@ +# PyTorch cheatsheet diff --git a/candle-book/src/guide/installation.md b/candle-book/src/guide/installation.md new file mode 100644 index 000000000..25267fe2b --- /dev/null +++ b/candle-book/src/guide/installation.md @@ -0,0 +1 @@ +# Installation diff --git a/candle-book/src/inference/README.md b/candle-book/src/inference/README.md new file mode 100644 index 000000000..c82f85e18 --- /dev/null +++ b/candle-book/src/inference/README.md @@ -0,0 +1 @@ +# Running a model diff --git a/candle-book/src/inference/cuda/README.md b/candle-book/src/inference/cuda/README.md new file mode 100644 index 000000000..68434cbfe --- /dev/null +++ b/candle-book/src/inference/cuda/README.md @@ -0,0 +1 @@ +# Advanced Cuda usage diff --git a/candle-book/src/inference/cuda/porting.md b/candle-book/src/inference/cuda/porting.md new file mode 100644 index 000000000..e332146d7 --- /dev/null +++ b/candle-book/src/inference/cuda/porting.md @@ -0,0 +1 @@ +# Porting a custom kernel diff --git a/candle-book/src/inference/cuda/writing.md b/candle-book/src/inference/cuda/writing.md new file mode 100644 index 000000000..0fe1f3dc7 --- /dev/null +++ b/candle-book/src/inference/cuda/writing.md @@ -0,0 +1 @@ +# Writing a custom kernel diff --git a/candle-book/src/inference/hub.md b/candle-book/src/inference/hub.md new file mode 100644 index 000000000..6242c0701 --- /dev/null +++ b/candle-book/src/inference/hub.md @@ -0,0 +1 @@ +# Using the hub diff --git a/candle-book/src/inference/serialization.md b/candle-book/src/inference/serialization.md new file mode 100644 index 000000000..0dfc62d35 --- /dev/null +++ b/candle-book/src/inference/serialization.md @@ -0,0 +1 @@ +# Serialization diff --git a/candle-book/src/training/README.md b/candle-book/src/training/README.md new file mode 100644 index 000000000..8977de34d --- /dev/null +++ b/candle-book/src/training/README.md @@ -0,0 +1 @@ +# Training diff --git a/candle-book/src/training/finetuning.md b/candle-book/src/training/finetuning.md new file mode 100644 index 000000000..f0af33f9f --- /dev/null +++ b/candle-book/src/training/finetuning.md @@ -0,0 +1 @@ +# Fine-tuning diff --git a/candle-book/src/training/mnist.md b/candle-book/src/training/mnist.md new file mode 100644 index 000000000..642960a48 --- /dev/null +++ b/candle-book/src/training/mnist.md @@ -0,0 +1 @@ +# MNIST