Skip to main content

PackedNode

Struct PackedNode 

Source
#[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: f32

Split threshold (internal) or prediction value (leaf, with lr baked in).

§children: u32

Packed children: left = low u16, right = high u16.

§feature_flags: u16

Bit 15 = is_leaf. Bits 14:0 = feature index.

§_reserved: u16

Reserved for future use.

Implementations§

Source§

impl PackedNode

Source

pub const LEAF_FLAG: u16 = 0x8000

Bit mask for the is_leaf flag in feature_flags.

Source

pub const fn leaf(value: f32) -> Self

Create a leaf node with a prediction value.

Source

pub const fn split( threshold: f32, feature_idx: u16, left: u16, right: u16, ) -> Self

Create an internal (split) node.

Source

pub const fn is_leaf(&self) -> bool

Returns true if this is a leaf node.

Source

pub const fn feature_idx(&self) -> u16

Feature index (bits 14:0). Only meaningful for internal nodes.

Source

pub const fn left_child(&self) -> u16

Left child index (low 16 bits of children).

Source

pub const fn right_child(&self) -> u16

Right child index (high 16 bits of children).

Trait Implementations§

Source§

impl Clone for PackedNode

Source§

fn clone(&self) -> PackedNode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PackedNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PackedNode

Source§

fn eq(&self, other: &PackedNode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for PackedNode

Source§

impl StructuralPartialEq for PackedNode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.