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§
Trait Implementations§
Source§impl Backend for NeuronBackend
impl Backend for NeuronBackend
Source§fn name(&self) -> String
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>)
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<()>
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<()>
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>
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<()>
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>
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<()>
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>
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]>>
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<()>
fn add_tree(&mut self, tree: &DeviceTree) -> Result<()>
Adds
tree to the scores of every dataset, traversing binned rows.Source§fn set_histogram_features(&mut self, used: &[bool])
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>
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§
impl !RefUnwindSafe for NeuronBackend
impl !Sync for NeuronBackend
impl !UnwindSafe for NeuronBackend
impl Forget for NeuronBackend
impl Freeze for NeuronBackend
impl Move for NeuronBackend
impl Send for NeuronBackend
impl Unpin for NeuronBackend
impl UnsafeUnpin for NeuronBackend
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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