pub struct DiffSortNet {
pub network_type: NetworkType,
pub size: usize,
pub steepness: f64,
pub dist: RelaxDist,
/* private fields */
}Expand description
A differentiable sorting network.
Fields§
§network_type: NetworkTypeNetwork topology type.
size: usizeInput size (padded to power-of-2 for bitonic).
steepness: f64Inverse temperature (steepness). Higher = sharper, closer to hard sort.
dist: RelaxDistDistribution for the relaxed comparator.
Implementations§
Source§impl DiffSortNet
impl DiffSortNet
Sourcepub fn new(
network_type: NetworkType,
size: usize,
steepness: f64,
dist: RelaxDist,
) -> Self
pub fn new( network_type: NetworkType, size: usize, steepness: f64, dist: RelaxDist, ) -> Self
Create a new differentiable sorting network.
For Bitonic, the size must be a power of 2. If not, inputs will be
padded with -inf to the next power of 2.
§Arguments
network_type- Bitonic or OddEvensize- Number of elements to sortsteepness- Inverse temperature (higher = sharper)dist- Distribution family for comparator relaxation
Sourcepub fn sort(&self, x: &[f64]) -> Result<(Vec<f64>, Vec<Vec<f64>>)>
pub fn sort(&self, x: &[f64]) -> Result<(Vec<f64>, Vec<Vec<f64>>)>
Sort the input, returning (sorted_values, soft_permutation_matrix).
The permutation matrix P satisfies: sorted ≈ x @ P (row convention).
P[i][j] is the soft weight of input position i contributing to output position j.
Sourcepub fn num_comparators(&self) -> usize
pub fn num_comparators(&self) -> usize
Return the number of comparators in this sorting network.
Sourcepub fn comparator_pairs(&self) -> &[(usize, usize)]
pub fn comparator_pairs(&self) -> &[(usize, usize)]
Return the comparator pairs as a slice.
Each pair (a, b) means “min at a, max at b”.
Trait Implementations§
Source§impl Clone for DiffSortNet
impl Clone for DiffSortNet
Source§fn clone(&self) -> DiffSortNet
fn clone(&self) -> DiffSortNet
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 moreAuto Trait Implementations§
impl Freeze for DiffSortNet
impl RefUnwindSafe for DiffSortNet
impl Send for DiffSortNet
impl Sync for DiffSortNet
impl Unpin for DiffSortNet
impl UnsafeUnpin for DiffSortNet
impl UnwindSafe for DiffSortNet
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