Skip to main content

rlx_ocr/
capabilities.rs

1// RLX — versatile ML compiler + runtime.
2// Copyright (C) 2026 Eugene Hauptmann, Nataliya Kosmyna.
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, version 3.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16//! Backend capability checks for OCR graphs.
17//!
18//! Every standard RLX device (`cpu`, `metal`, `mlx`, `cuda`, `rocm`, `gpu`, `vulkan`) is
19//! accepted when the matching `rlx-runtime` feature is enabled at build time.
20
21use anyhow::Result;
22use rlx_core::validate_standard_device;
23pub use rlx_core::{STANDARD_DEVICE_NAMES, STANDARD_DEVICES};
24use rlx_runtime::Device;
25
26/// Validate that `device` is in the workspace standard backend set.
27pub fn validate_device(device: Device) -> Result<()> {
28    validate_standard_device("ocr", device)
29}
30
31#[cfg(test)]
32mod tests {
33    use super::*;
34    use rlx_core::STANDARD_DEVICES;
35
36    #[test]
37    fn all_standard_backends_allowed() {
38        for dev in STANDARD_DEVICES {
39            validate_device(*dev).unwrap();
40        }
41    }
42}