Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions crates/mohu-buffer/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ fn e_reversed_empty(start: usize, stop: usize) -> bool {
/// array view.
///
/// Does not own memory — it is always paired with a backing `Buffer`.
///
/// # Example
///
/// ```
/// use mohu_buffer::layout::Layout;
///
/// let shape = [2, 3];
/// let itemsize = 4; // e.g., f32
/// let layout = Layout::new_c(&shape, itemsize).unwrap();
///
/// assert_eq!(layout.shape(), &[2, 3]);
/// assert_eq!(layout.strides(), &[12, 4]); // C-contiguous strides
/// ```
#[derive(Clone, PartialEq, Eq)]
pub struct Layout {
shape: ShapeVec,
Expand All @@ -136,12 +149,28 @@ impl Layout {
// ─── Constructors ─────────────────────────────────────────────────────────

/// Creates a C-contiguous (row-major) layout for `shape`.
///
/// # Example
///
/// ```
/// use mohu_buffer::layout::Layout;
/// let layout = Layout::new_c(&[2, 3], 4).unwrap();
/// assert_eq!(layout.strides(), &[12, 4]);
/// ```
pub fn new_c(shape: &[usize], itemsize: usize) -> MohuResult<Self> {
let strides = c_strides(shape, itemsize);
Self::new_custom(shape, &strides, 0, itemsize)
}

/// Creates a Fortran-contiguous (column-major) layout for `shape`.
///
/// # Example
///
/// ```
/// use mohu_buffer::layout::Layout;
/// let layout = Layout::new_f(&[2, 3], 4).unwrap();
/// assert_eq!(layout.strides(), &[4, 8]);
/// ```
pub fn new_f(shape: &[usize], itemsize: usize) -> MohuResult<Self> {
let strides = f_strides(shape, itemsize);
Self::new_custom(shape, &strides, 0, itemsize)
Expand Down
1 change: 1 addition & 0 deletions docs/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ src = "src"
site-url = "/mohu/"
git-repository-url = "https://github.com/mohu-org/mohu"
edit-url-template = "https://github.com/mohu-org/mohu/edit/main/docs/{path}"
additional-css = ["theme/custom.css"]

[output.html.fold]
enable = true
37 changes: 37 additions & 0 deletions docs/theme/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* docs/theme/custom.css */
:root {
--fonts: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
Comment thread
Xploit-Ghost marked this conversation as resolved.

body {
font-family: var(--fonts);
letter-spacing: -0.01em;
}

/* Improve readability of main content */
.content main {
max-width: 850px;
line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
font-weight: 700;
letter-spacing: -0.02em;
}

/* Make code blocks look slightly cleaner */
pre {
border-radius: 6px;
}

/* Sticky transparent menu on mobile */
@media (max-width: 1080px) {
.menu-bar {
position: sticky;
top: 0;
z-index: 50;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
border-bottom: 1px solid var(--sidebar-border);
}
}
Loading