From 37692065837b2d635d2eb9e7ce3e4e1d439f7028 Mon Sep 17 00:00:00 2001 From: zachcp Date: Mon, 11 Nov 2024 16:13:52 -0500 Subject: [PATCH] Update docs (#2553) * add module docs for candle-core * doc each of the candle-nn modules and add the links to the doc page --- candle-core/src/lib.rs | 14 ++++++++++++++ candle-nn/src/activation.rs | 2 ++ candle-nn/src/kv_cache.rs | 2 ++ candle-nn/src/lib.rs | 17 +++++++++++++++++ candle-nn/src/loss.rs | 2 ++ candle-nn/src/ops.rs | 3 +++ candle-nn/src/rotary_emb.rs | 2 ++ candle-nn/src/sequential.rs | 2 ++ candle-nn/src/var_builder.rs | 2 ++ candle-nn/src/var_map.rs | 2 ++ 10 files changed, 48 insertions(+) diff --git a/candle-core/src/lib.rs b/candle-core/src/lib.rs index 39ca909d88..4b73d00696 100644 --- a/candle-core/src/lib.rs +++ b/candle-core/src/lib.rs @@ -32,6 +32,20 @@ //! Python can really add overhead in more complex workflows and the [GIL](https://www.backblaze.com/blog/the-python-gil-past-present-and-future/) is a notorious source of headaches. //! //! Rust is cool, and a lot of the HF ecosystem already has Rust crates [safetensors](https://github.com/huggingface/safetensors) and [tokenizers](https://github.com/huggingface/tokenizers) +//! +//! ## Other Crates +//! +//! Candle consists of a number of crates. This crate holds core the common data structures but you may wish +//! to look at the docs for the other crates which can be found here: +//! +//! - [candle-core](https://docs.rs/candle-core/). Core Datastructures and DataTypes. +//! - [candle-nn](https://docs.rs/candle-nn/). Building blocks for Neural Nets. +//! - [candle-datasets](https://docs.rs/candle-datasets/). Rust access to commonly used Datasets like MNIST. +//! - [candle-examples](https://docs.rs/candle-examples/). Examples of Candle in Use. +//! - [candle-onnx](https://docs.rs/candle-onnx/). Loading and using ONNX models. +//! - [candle-pyo3](https://docs.rs/candle-pyo3/). Access to Candle from Python. +//! - [candle-transformers](https://docs.rs/candle-transformers/). Candle implemntation of many published transformer models. +//! #[cfg(feature = "accelerate")] mod accelerate; diff --git a/candle-nn/src/activation.rs b/candle-nn/src/activation.rs index fc1819f5e0..772548a01a 100644 --- a/candle-nn/src/activation.rs +++ b/candle-nn/src/activation.rs @@ -1,3 +1,5 @@ +//! Activation Functions +//! use candle::{Result, Tensor}; use serde::Deserialize; diff --git a/candle-nn/src/kv_cache.rs b/candle-nn/src/kv_cache.rs index 68addb98bf..918dca702f 100644 --- a/candle-nn/src/kv_cache.rs +++ b/candle-nn/src/kv_cache.rs @@ -1,3 +1,5 @@ +//! Cache Implementations +//! use candle::{Device, Result, Tensor}; #[derive(Debug, Clone)] diff --git a/candle-nn/src/lib.rs b/candle-nn/src/lib.rs index fcac58308c..eb3cde4a75 100644 --- a/candle-nn/src/lib.rs +++ b/candle-nn/src/lib.rs @@ -1,3 +1,20 @@ +//! candle-nn +//! +//! ## Other Crates +//! +//! Candle consists of a number of crates. This crate holds structs and functions +//! that allow you to build and train neural nets. You may wish +//! to look at the docs for the other crates which can be found here: +//! +//! - [candle-core](https://docs.rs/candle-core/). Core Datastructures and DataTypes. +//! - [candle-nn](https://docs.rs/candle-nn/). Building blocks for Neural Nets. +//! - [candle-datasets](https://docs.rs/candle-datasets/). Rust access to commonly used Datasets like MNIST. +//! - [candle-examples](https://docs.rs/candle-examples/). Examples of Candle in Use. +//! - [candle-onnx](https://docs.rs/candle-onnx/). Loading and using ONNX models. +//! - [candle-pyo3](https://docs.rs/candle-pyo3/). Access to Candle from Python. +//! - [candle-transformers](https://docs.rs/candle-transformers/). Candle implemntation of many published transformer models. +//! + pub mod activation; pub mod batch_norm; pub mod conv; diff --git a/candle-nn/src/loss.rs b/candle-nn/src/loss.rs index fb1e11f413..03e8524d6d 100644 --- a/candle-nn/src/loss.rs +++ b/candle-nn/src/loss.rs @@ -1,3 +1,5 @@ +//! Loss Calculations +//! use candle::{Result, Tensor}; /// The negative log likelihood loss. diff --git a/candle-nn/src/ops.rs b/candle-nn/src/ops.rs index 0f35285d0b..c84e297b99 100644 --- a/candle-nn/src/ops.rs +++ b/candle-nn/src/ops.rs @@ -1,3 +1,6 @@ +//! Tensor ops. +//! + use candle::{CpuStorage, DType, Layout, Module, Result, Shape, Tensor, D}; use rayon::prelude::*; diff --git a/candle-nn/src/rotary_emb.rs b/candle-nn/src/rotary_emb.rs index 1084cfb512..0191bd7e6a 100644 --- a/candle-nn/src/rotary_emb.rs +++ b/candle-nn/src/rotary_emb.rs @@ -1,3 +1,5 @@ +//! Rotary Embeddings +//! use candle::{CpuStorage, Layout, Result, Shape, Tensor, D}; use rayon::prelude::*; diff --git a/candle-nn/src/sequential.rs b/candle-nn/src/sequential.rs index bef9975287..de5ae4971b 100644 --- a/candle-nn/src/sequential.rs +++ b/candle-nn/src/sequential.rs @@ -1,3 +1,5 @@ +//! Sequential Layer +//! //! A sequential layer used to chain multiple layers and closures. use candle::{Module, Result, Tensor}; diff --git a/candle-nn/src/var_builder.rs b/candle-nn/src/var_builder.rs index 00669468d6..0d836c7fd4 100644 --- a/candle-nn/src/var_builder.rs +++ b/candle-nn/src/var_builder.rs @@ -1,3 +1,5 @@ +//! A `VarBuilder` for variable retrieval from models +//! //! A `VarBuilder` is used to retrieve variables used by a model. These variables can either come //! from a pre-trained checkpoint, e.g. using `VarBuilder::from_mmaped_safetensors`, or initialized //! for training, e.g. using `VarBuilder::from_varmap`. diff --git a/candle-nn/src/var_map.rs b/candle-nn/src/var_map.rs index 3cb27c632e..ba020746b5 100644 --- a/candle-nn/src/var_map.rs +++ b/candle-nn/src/var_map.rs @@ -1,3 +1,5 @@ +//! A `VarMap` is a store that holds named variables. +//! use candle::{DType, Device, Result, Shape, Tensor, Var}; use std::collections::HashMap; use std::sync::{Arc, Mutex};