#[repr(C, align(4))]pub struct PackedNode {
pub value: f32,
pub children: u32,
pub feature_flags: u16,
pub _reserved: u16,
}Expand description
12-byte packed decision tree node. AoS layout for cache-optimal inference.
5 nodes per 64-byte cache line (60 bytes used, 4 bytes padding).
All fields for one traversal step are adjacent in memory — no cross-vector
striding like the SoA TreeArena used during training.
§Field layout
value: split threshold (internal nodes) or leaf prediction (leaf nodes). For leaves, the learning rate is already baked in:value = lr * leaf_f64 as f32.children: packed left (low u16) and right (high u16) child indices. For leaves, this field is unused (set to 0).feature_flags: bit 15 = is_leaf flag. Bits 14:0 = feature index (max 32767). For leaves, the feature index is unused._reserved: padding for future use (categorical flag, metadata, etc.).
Fields§
§value: f32Split threshold (internal) or prediction value (leaf, with lr baked in).
children: u32Packed children: left = low u16, right = high u16.
feature_flags: u16Bit 15 = is_leaf. Bits 14:0 = feature index.
_reserved: u16Reserved for future use.
Implementations§
Source§impl PackedNode
impl PackedNode
Sourcepub const fn split(
threshold: f32,
feature_idx: u16,
left: u16,
right: u16,
) -> Self
pub const fn split( threshold: f32, feature_idx: u16, left: u16, right: u16, ) -> Self
Create an internal (split) node.
Sourcepub const fn feature_idx(&self) -> u16
pub const fn feature_idx(&self) -> u16
Feature index (bits 14:0). Only meaningful for internal nodes.
Sourcepub const fn left_child(&self) -> u16
pub const fn left_child(&self) -> u16
Left child index (low 16 bits of children).
Sourcepub const fn right_child(&self) -> u16
pub const fn right_child(&self) -> u16
Right child index (high 16 bits of children).
Trait Implementations§
Source§impl Clone for PackedNode
impl Clone for PackedNode
Source§fn clone(&self) -> PackedNode
fn clone(&self) -> PackedNode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PackedNode
impl Debug for PackedNode
Source§impl PartialEq for PackedNode
impl PartialEq for PackedNode
impl Copy for PackedNode
impl StructuralPartialEq for PackedNode
Auto Trait Implementations§
impl Freeze for PackedNode
impl RefUnwindSafe for PackedNode
impl Send for PackedNode
impl Sync for PackedNode
impl Unpin for PackedNode
impl UnsafeUnpin for PackedNode
impl UnwindSafe for PackedNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more