pub trait RuntimeSelector:
Send
+ Sync
+ Debug {
// Provided method
fn select<'a>(&self, set: &'a AlternativeSet) -> Option<&'a Candidate> { ... }
}Expand description
Dispatch-time selector over a plan’s per-node AlternativeSet.
Phase 5.1 of the picker-work arc.
§Contract
selectis called exactly once per kernel-bearing node, at dispatch time, by the executor’sresolve_compiled.- Implementors return
Noneonly when the set is empty — every non-empty set MUST have a pick. The default implementation (WinnerSelector) returnsset.winner()(the first entry). - The selected
Candidate’skernel,caps, andbackendbecome the executor’s dispatch parameters for that node. - Selectors are queried per-node and may make different picks for different nodes in the same realize — the trait carries no per-realize state.
§Sendness
Implementations must be Send + Sync so the executor can share
a single selector across the compiler thread and the executor
thread.
§Why not pass NodeId / OpKind / dtypes?
The Candidate already carries backend, precision,
static_cost, and op_params; selectors that need op identity
can derive it from these fields. If a future selector needs the
graph-level NodeId or OpKind, we add a SelectorContext
param — but Phase 5.1 keeps the surface minimal so the trait
stays usable by selectors that only care about set contents.
Provided Methods§
Sourcefn select<'a>(&self, set: &'a AlternativeSet) -> Option<&'a Candidate>
fn select<'a>(&self, set: &'a AlternativeSet) -> Option<&'a Candidate>
Pick one candidate from the set. None only when the set is
empty; non-empty sets MUST produce a pick.
The default implementation returns set.winner() — the top-N’s
first entry, which is Picker 1’s static-cost winner after
rank+truncate.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".