pub struct PercentileOp<Context> { /* private fields */ }
Expand description

| Operator to calculate percentile values | for an input tensor of data, given samples | of data from the same distribution, | labeled with their percentile values. | | This operator is used to find percentile | representations for raw values, given | a sample set of raw values, labeled with | their corresponding percentiles from | the same distribution. | | In particular, this operator takes | as input a tensor of floats to find the | percentile values for, a 2D tensor of | floats, where the first column of the | tensor represents sampled values, | and the second column represents the | percentile labels, and a tensor of integers | lengths. | | This lengths tensor is used because | the operator works on multiple sets | of raw values at the same time. For example, | for an input: | | original_values=[[3, 5, 3],[5, 1, 6]], | | lengths = [2, 1, 1], | | value_to_pct = [[3, 0.2], [5, 0.5], [1, 0.3], [3. 0.6]] | | Our operator expects that each column | i of the input tensor is sampled from | distribution i. Lengths tells us that | the first two elements in value_to_pct | are sampled from distribution 1, the | next is from distribution two, and the | last is from distribution 3. We expect | the output of our operator to give us | [[0.2, 1.0, 0.6], [0.5, 0.3, 1.0]]. | | To calculate the percentile of an element, | we check to see if its value is already | mapped to a percentile in value_to_pct. | If so, we return that value. If not, we | linearly interpolate between the two | closest values in value_to_pct. If | the value is larger than all values in | value_to_pct, we return 1. If it’s smaller | than all the values, we return 0. |

Implementations§

source§

impl<Context> PercentileOp<Context>

source

pub fn new<Args>(args: Args) -> Self

source§

impl PercentileOp<CPUContext>

source

pub fn run_on_device(&mut self) -> bool

Auto Trait Implementations§

§

impl<Context> !RefUnwindSafe for PercentileOp<Context>

§

impl<Context> !Send for PercentileOp<Context>

§

impl<Context> !Sync for PercentileOp<Context>

§

impl<Context> Unpin for PercentileOp<Context>where Context: Unpin,

§

impl<Context> !UnwindSafe for PercentileOp<Context>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V