Skip to main content

PackedNodeI16

Struct PackedNodeI16 

Source
#[repr(C, align(4))]
pub struct PackedNodeI16 { pub value: i16, pub feature_flags: u16, pub children: u32, }
Expand description

8-byte quantized decision tree node. Integer-only traversal for FPU-less targets.

8 nodes per 64-byte cache line. All comparisons are i16 — no floating point in the hot loop. On Cortex-M0+ (no FPU), this is ~25x faster than f32.

§Field layout

  • value: quantized split threshold (internal nodes) or quantized leaf prediction (leaf nodes). For splits: (threshold * feature_scale[feat_idx]) as i16. For leaves: (lr * leaf_f64 * leaf_scale) as i16.
  • feature_flags: bit 15 = is_leaf flag. Bits 14:0 = feature index (max 32767). For leaves, the feature index is unused.
  • children: packed left (low u16) and right (high u16) child indices. For leaves, this field is unused (set to 0).

Fields§

§value: i16

Quantized split threshold (internal) or quantized leaf prediction (leaf).

§feature_flags: u16

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

§children: u32

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

Implementations§

Source§

impl PackedNodeI16

Source

pub const LEAF_FLAG: u16 = 0x8000

Bit mask for the is_leaf flag in feature_flags.

Source

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

Create a leaf node with a quantized prediction value.

Source

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

Create an internal (split) node with a quantized threshold.

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 PackedNodeI16

Source§

fn clone(&self) -> PackedNodeI16

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 PackedNodeI16

Source§

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

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

impl Hash for PackedNodeI16

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for PackedNodeI16

Source§

fn eq(&self, other: &PackedNodeI16) -> 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 PackedNodeI16

Source§

impl Eq for PackedNodeI16

Source§

impl StructuralPartialEq for PackedNodeI16

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.