Skip to main content

batch_ml_inference

Function batch_ml_inference 

Source
pub fn batch_ml_inference(
    candidates: &[(&str, &str)],
    config: &ScannerConfig,
) -> Vec<f64>
Expand description

Score multiple (credential, context) pairs in a single batch.

Uses GPU compute shaders when available and the batch is large enough. Falls back to CPU for small batches or when no GPU is present. Score a batch of (text, context) candidates, using GPU when available.

§Examples

use keyhog_scanner::gpu::batch_ml_inference;
use keyhog_scanner::ScannerConfig;
let config = ScannerConfig::default();
let scores = batch_ml_inference(&[("demo_ABC12345", "API_KEY=")], &config);
assert_eq!(scores.len(), 1);

Callers pass (&str, &str) so a hot-path scan with N matches no longer allocates 2N owned strings just to enter ML scoring. The MlPendingMatch String fields stay live for the duration of the call - the borrow is safe.