-
Notifications
You must be signed in to change notification settings - Fork 931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation fixes and improvements #2289
base: main
Are you sure you want to change the base?
Changes from all commits
1237fb9
175a52e
6773de8
cb90310
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
//! Support for the GGUF file format. | ||
//! | ||
//! Spec: https://github.com/philpax/ggml/blob/gguf-spec/docs/gguf.md | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
//! Spec: <https://github.com/philpax/ggml/blob/gguf-spec/docs/gguf.md> | ||
|
||
use super::{GgmlDType, QTensor}; | ||
use crate::{Device, Result}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
//! ``` | ||
use candle::{Result, Tensor}; | ||
|
||
/// See the documentation for [`mod@super::linear`] for more information. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
#[derive(Clone, Debug)] | ||
pub struct Linear { | ||
weight: Tensor, | ||
|
@@ -76,6 +77,7 @@ pub fn linear_no_bias(in_dim: usize, out_dim: usize, vb: crate::VarBuilder) -> R | |
Ok(Linear::new(ws, None)) | ||
} | ||
|
||
/// Create or initialize a new linear layer, bias depending on the argument. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function was the only one in the module without a line of documentation. THe function just switches between the other two based on the |
||
pub fn linear_b( | ||
in_dim: usize, | ||
out_dim: usize, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
//! Loss functions. | ||
use candle::{Result, Tensor}; | ||
|
||
/// The negative log likelihood loss. | ||
/// | ||
/// Arguments | ||
/// | ||
/// * [inp]: The input tensor of dimensions `N, C` where `N` is the batch size and `C` the number | ||
/// * `inp`: The input tensor of dimensions `N, C` where `N` is the batch size and `C` the number | ||
/// of categories. This is expected to contain log probabilities. | ||
/// * [target]: The ground truth labels as a tensor of u32 of dimension `N`. | ||
/// * `target`: The ground truth labels as a tensor of u32 of dimension `N`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These were all unresolved links:
There is no current official way to document function arguments, I followed rust-lang/rust#57525. Rendered: |
||
/// | ||
/// The resulting tensor is a scalar containing the average value over the batch. | ||
pub fn nll(inp: &Tensor, target: &Tensor) -> Result<Tensor> { | ||
|
@@ -31,9 +32,9 @@ pub fn nll(inp: &Tensor, target: &Tensor) -> Result<Tensor> { | |
/// | ||
/// Arguments | ||
/// | ||
/// * [inp]: The input tensor of dimensions `N, C` where `N` is the batch size and `C` the number | ||
/// * `inp`: The input tensor of dimensions `N, C` where `N` is the batch size and `C` the number | ||
/// of categories. This is expected to raw logits. | ||
/// * [target]: The ground truth labels as a tensor of u32 of dimension `N`. | ||
/// * `target`: The ground truth labels as a tensor of u32 of dimension `N`. | ||
/// | ||
/// The resulting tensor is a scalar containing the average value over the batch. | ||
pub fn cross_entropy(inp: &Tensor, target: &Tensor) -> Result<Tensor> { | ||
|
@@ -53,9 +54,9 @@ pub fn mse(inp: &Tensor, target: &Tensor) -> Result<Tensor> { | |
/// | ||
/// Arguments | ||
/// | ||
/// * [inp]: The input tensor of dimensions `N, C` where `N` is the batch size and `C` the number | ||
/// * `inp`: The input tensor of dimensions `N, C` where `N` is the batch size and `C` the number | ||
/// of categories. This is expected to raw logits. | ||
/// * [target]: The ground truth labels as a tensor of u32 of dimension `N, C` where `N` is the batch size and `C` the number | ||
/// * `target`: The ground truth labels as a tensor of u32 of dimension `N, C` where `N` is the batch size and `C` the number | ||
/// of categories. | ||
/// | ||
/// The resulting tensor is a scalar containing the average value over the batch. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -497,7 +497,7 @@ impl<'a> VarBuilder<'a> { | |
/// | ||
/// # Safety | ||
/// | ||
/// The unsafe is inherited from [`memmap2::MmapOptions`]. | ||
/// The unsafe is inherited from [`candle::safetensors::MmapedSafetensors::multi`]. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Presumably a copy paste from the documentation of multi itself, changed to point at the reason why this function is unsafe. |
||
pub unsafe fn from_mmaped_safetensors<P: AsRef<std::path::Path>>( | ||
paths: &[P], | ||
dtype: DType, | ||
|
@@ -589,7 +589,7 @@ impl ShardedSafeTensors { | |
/// | ||
/// # Safety | ||
/// | ||
/// The unsafe is inherited from [`memmap2::MmapOptions`]. | ||
/// The unsafe is inherited from [`candle::safetensors::MmapedSafetensors::multi`]. | ||
pub unsafe fn var_builder<P: AsRef<std::path::Path>>( | ||
paths: &[P], | ||
dtype: DType, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.