pub struct UniquePlan<T: Element> { /* private fields */ }Expand description
unique plan.
Sort-then-dedup composition (PyTorch torch.unique(x, sorted=True)).
At the plan layer chains SortPlan into a
caller-supplied scratch buffer, then
UniqueConsecutivePlan to collapse
runs.
When to use: per-row distinct-value extraction. Set-valued — no BW (output dimensionality is data-dependent).
Dtypes: {f32, f64, i32}.
Shape limits: input [batch, row_len]; row_len ≤ 1024 (sort
cap). Outputs [batch, max_unique]; the caller’s max_unique
bounds the output; rows with more uniques have the overflow
dropped (the counter[] reports the actual count).
Workspace: zero in Workspace; caller supplies
sorted_scratch, sorted_idx_scratch, and counter in
UniqueArgs.
Precision guarantee: deterministic, bit-stable.
Implementations§
Source§impl<T: Element> UniquePlan<T>
impl<T: Element> UniquePlan<T>
Sourcepub fn select(
_stream: &Stream,
desc: &UniqueDescriptor,
_pref: PlanPreference,
) -> Result<Self>
pub fn select( _stream: &Stream, desc: &UniqueDescriptor, _pref: PlanPreference, ) -> Result<Self>
Pick a kernel for desc.
Sourcepub fn can_implement(&self, args: &UniqueArgs<'_, T>) -> Result<()>
pub fn can_implement(&self, args: &UniqueArgs<'_, T>) -> Result<()>
Validate args.
Sourcepub fn workspace_size(&self) -> usize
pub fn workspace_size(&self) -> usize
Workspace size in bytes (the sorted-scratch buffers are caller- supplied as Args fields, so the plan reports 0 here).
Sourcepub fn precision_guarantee(&self) -> PrecisionGuarantee
pub fn precision_guarantee(&self) -> PrecisionGuarantee
Numerical guarantees for this plan’s kernel.