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
/// Thread-local side-channel for passing granular inference timings from model
/// implementations back to the [`crate::layout::engine::LayoutEngine`] caller.
///
/// This avoids changing the [`crate::layout::models::LayoutModel`] trait signature
/// while still providing per-step timing data to callers that need it.
///
/// Usage:
/// - Model implementations (e.g. `RtDetrModel`) call [`set`] with measured timings.
/// - `LayoutEngine::detect_timed()` calls [`take`] after the model returns to retrieve them.
use Cell;
thread_local!
/// Record granular timings from the current inference call.
///
/// Called by model implementations immediately before returning results.
/// Retrieve and reset the timings recorded by the most recent [`set`] call.
///
/// Returns `(preprocess_ms, onnx_ms)`. Resets both values to 0 after reading.