Skip to content

Commit

Permalink
Fix docs (#1229)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielsimard authored and syl20bnr committed Feb 1, 2024
1 parent 23d653a commit d646417
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
9 changes: 8 additions & 1 deletion burn-autodiff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/tracel-ai/burn/tree/main/burn-autodiff"
version.workspace = true

[features]
default = ["export_tests"]
default = []
export_tests = ["burn-tensor-testgen"]

[dependencies]
Expand All @@ -21,3 +21,10 @@ burn-tensor-testgen = { path = "../burn-tensor-testgen", version = "0.12.1", opt

derive-new = { workspace = true }
spin = { workspace = true }

[dev-dependencies]
burn-tensor = { path = "../burn-tensor", version = "0.12.1", default-features = false, features = [
"export_tests",
] }


10 changes: 10 additions & 0 deletions burn-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ std = [
]
doc = [
"std",
# Backends
"dataset",
"candle",
"fusion",
"ndarray",
"tch",
"wgpu",
"vision",
"autodiff",
# Doc features
"burn-candle/doc",
"burn-common/doc",
"burn-dataset/doc",
Expand Down
16 changes: 10 additions & 6 deletions burn-ndarray/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,9 @@ blas-openblas-system = [

# ** Please make sure all dependencies support no_std when std is disabled **

burn-autodiff = { path = "../burn-autodiff", version = "0.12.1", features = [
"export_tests",
], optional = true }
burn-autodiff = { path = "../burn-autodiff", version = "0.12.1", optional = true }
burn-common = { path = "../burn-common", version = "0.12.1", default-features = false }
burn-tensor = { path = "../burn-tensor", version = "0.12.1", default-features = false, features = [
"export_tests",
] }
burn-tensor = { path = "../burn-tensor", version = "0.12.1", default-features = false }

matrixmultiply = { workspace = true, default-features = false }
rayon = { workspace = true, optional = true }
Expand All @@ -67,5 +63,13 @@ openblas-src = { workspace = true, optional = true }
rand = { workspace = true }
spin = { workspace = true } # using in place of use std::sync::Mutex;

[dev-dependencies]
burn-autodiff = { path = "../burn-autodiff", version = "0.12.1", default-features = false, features = [
"export_tests",
] }
burn-tensor = { path = "../burn-tensor", version = "0.12.1", default-features = false, features = [
"export_tests",
] }

[package.metadata.docs.rs]
features = ["doc"]
1 change: 1 addition & 0 deletions burn-tensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mod tensor;
mod tests;

pub use half::{bf16, f16};
pub(crate) use tensor::check::macros::check;
pub use tensor::*;

pub use burn_common::reader::Reader; // Useful so that backends don't have to add `burn_common` as
24 changes: 14 additions & 10 deletions burn-tensor/src/tensor/api/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,21 +818,25 @@ impl TensorError {
}
}

/// We use a macro for all checks, since the panic message file and line number will match the
/// function that does the check instead of a the generic error.rs crate private unrelated file
/// and line number.
#[macro_export(local_inner_macros)]
macro_rules! check {
($check:expr) => {
if let TensorCheck::Failed(check) = $check {
core::panic!("{}", check.format());
}
};
/// Module where we defined macros that can be used only in the project.
pub(crate) mod macros {
/// We use a macro for all checks, since the panic message file and line number will match the
/// function that does the check instead of a the generic error.rs crate private unrelated file
/// and line number.
macro_rules! check {
($check:expr) => {
if let TensorCheck::Failed(check) = $check {
core::panic!("{}", check.format());
}
};
}
pub(crate) use check;
}

#[cfg(test)]
mod tests {
use super::*;
use macros::check;

#[test]
#[should_panic]
Expand Down

0 comments on commit d646417

Please sign in to comment.