1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! Execution providers — session `ExecutionProvider` analogy for PMML scoring.
//!
//! Providers own batch sharding and per-row evaluation. `Session` only materializes
//! `Value[FieldId]` via `with_value_buffer` and maps outputs; providers do `DerivedFields`
//! + model dispatch.
//!
//! The unified `Cpu` provider auto-chooses serial vs `rayon` sharding based on batch size.
use crate;
use crateIr;
use crate;
/// Execution provider trait — mirrors `ExecutionProvider` in session runtime.
///
/// Providers are `Send + Sync` so a single `Session` can be shared across threads.
/// `Session` builds a [`BatchCtx`] (no per-row allocation) and delegates to `eval_batch`;
/// for tiny batches (`<256` rows) the `Cpu` provider falls back to serial to avoid `rayon` overhead.
///
/// # Contract for implementors
///
/// - `eval_row` must handle `DerivedFields` and model dispatch for a single `&mut [Value]`.
/// - `eval_batch` must shard by `Batch::len()` and return `BatchResult::Rows` preserving order.
/// - `preferred_format` is a hint (`Columnar` for Arrow, `RowMajor` for `HashMap`). `Session` may still
/// pass either format; provider must handle both via `Batch::materialize_row`.
/// - `evaluate` is a backward-compat alias for `eval_row`.
///
/// # Concurrency
///
/// `eval_row` is called with a thread-local `&mut [Value]` slice, so it must not retain
/// references beyond the call. `eval_batch` may use `rayon` internally; it must not hold
/// `&Ir` mutably and must respect `BatchCtx` being `Send+Sync`.
///
/// # Examples
///
/// ```
/// use pmmlruntime::session::providers::{ExecutionProvider, CpuProvider};
/// use pmmlruntime::base::Value;
/// use pmmlruntime::ir::{Ir, ModelIr, TreeIr, MiningSchemaIr, MissingValueStrategy, NoTrueChildStrategy};
/// use std::collections::HashMap;
///
/// let provider = CpuProvider::new();
/// assert_eq!(provider.name(), "CPU");
/// ```
pub use CpuProvider;