Skip to main content

NeuronBackend

Struct NeuronBackend 

Source
pub struct NeuronBackend { /* private fields */ }
Expand description

Neuron-resident histogram, stable partition and binned tree-scoring backend. Objectives, stochastic quantization, bag draws and fixed-point encoding use core’s host helpers; no CPU backend is constructed or used.

Implementations§

Source§

impl NeuronBackend

Source

pub fn new(ordinal: Option<usize>) -> Result<Self>

Trait Implementations§

Source§

impl Backend for NeuronBackend

Source§

fn name(&self) -> String

Human-readable device name for logs (cpu (14 threads), Apple M4 Pro (metal)).
Source§

fn set_thread_pool(&mut self, pool: Arc<ThreadPool>)

The pool host-side parallel work runs on when num_threads is set; backends without host-side parallelism ignore it. Called before load.
Source§

fn load( &mut self, train: &BinnedDataset, valid: &[&BinnedDataset], objective: &ObjectiveSetup, ) -> Result<()>

Takes the training set and validation sets; called once, before anything else.
Source§

fn init_scores(&mut self, dataset: usize, value: f64) -> Result<()>

Sets every score of dataset to value.
Source§

fn compute_gradients(&mut self) -> Result<GradientStats>

Computes f32 gradients and hessians of the training scores; returns their local maxima.
Source§

fn quantize(&mut self, spec: &QuantSpec) -> Result<()>

Quantizes the gradients and hessians with spec (quantize::quantize_row, keyed by global row id).
Source§

fn reset_partition(&mut self, bag: &BagSpec) -> Result<u32>

Refills the partition with the bagged training rows in ascending order; returns their count.
Source§

fn histogram( &mut self, leaf: LeafRange, quantized: bool, out: &mut [f64], ) -> Result<()>

Histogram of the rows of leaf into out (2 * total_bins, overwritten): quantized units when quantized, else float sums of gradients and hessians.
Source§

fn partition(&mut self, leaf: LeafRange, split: &BinSplit) -> Result<u32>

Stable in-place partition of leaf’s rows by split; returns the number of rows going left.
Source§

fn leaf_sums( &mut self, leaves: &[LeafRange], grad_scale: f32, hess_scale: f32, ) -> Result<Vec<[i64; 2]>>

Exact fixed-point sums [sum rint(g * scale), sum rint(h * scale)] of each leaf’s float gradients (quantize::to_fixed), for leaf renewal.
Source§

fn add_tree(&mut self, tree: &DeviceTree) -> Result<()>

Adds tree to the scores of every dataset, traversing binned rows.
Source§

fn scores(&mut self, dataset: usize) -> Result<Vec<f32>>

The current scores of dataset.
Source§

fn set_histogram_features(&mut self, used: &[bool])

Histograms from now on only need the bins of the features with used[feature] (LightGBM is_feature_used: the tree’s feature mask and the parent’s splittable features); the other bins may hold anything. Every rank passes the same mask. Backends may ignore it.
Source§

fn partition_and_histogram( &mut self, leaf: LeafRange, split: &BinSplit, side: Side, quantized: bool, out: &mut [f64], ) -> Result<u32, SilvicError>

partition, then the histogram of the side child into out; returns the left count. A device overrides it to run both without waiting for the count in between: the side is chosen before partitioning (from the split’s estimated counts, the same on every rank), so the histogram’s row range can stay on the device.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more