pub trait InputGenerator<K, I: TuneInputs>:
Send
+ Sync
+ 'static {
// Required method
fn generate<'a>(&self, key: &K, inputs: &I::At<'a>) -> I::At<'a>;
}Expand description
Produces the benchmark inputs for a given key and reference inputs.
A tuner runs each candidate on the value generate returns, not on the real call
inputs directly, so callers can synthesize test inputs (for example, allocate fresh
output buffers) without mutating the real ones. The common case is just cloning the
reference inputs; use CloneInputGenerator for that.
There’s no Fn-based blanket impl for arbitrary TuneInputs families because
for<'a> Fn(&K, &I::At<'a>) -> I::At<'a> runs into E0582 (Fn’s Output cannot
depend on the higher-ranked lifetime). For the owned-input case the HRTB collapses
and the Fn blanket below works; borrowed-input families implement this trait
directly.
Required Methods§
Implementors§
impl<K, Func, A> InputGenerator<K, A> for Func
Fn(&K, &A) -> A acts as an InputGenerator when A is an owned type. For
multi-input kernels, A is a tuple that the closure destructures internally.