mirror of
https://github.com/RapidAI/RapidOCR.git
synced 2026-11-10 21:10:55 +08:00
src/metal_driver.mm implements the compute subset of the Vulkan entry points on Metal, so the existing GPU graph, fusions and shaders run unchanged. Shaders go GLSL -> SPIR-V -> MSL (spirv-cross) at build time and compile at runtime with fast math off; per-mode pipelines are specialized on the low 16 mode bits. Weights and activations live in shared-storage MTLBuffers; each queue submit is one command buffer. - CMake: PPOCR_ENABLE_METAL (default ON on Apple), works with Vulkan OFF. - API: Backend::metal / MetalAvailable(), PPOCR_BACKEND_METAL / ppocr_metal_available(), Python backend "metal" / use_metal. Missing Metal falls back to CPU (PPOCR_DISABLE_METAL=1 forces that). - ppocr_metal_check, tests/run_metal_macos.sh, python/tests/test_metal.py and a macos-14 CI job. - README / README-CN: Metal usage and M4 numbers. M4, idle: page 538 ms (MoltenVK 706 ms, NEON 209 ms); hello 76 ms. Text and boxes equal to CPU on hello and page (IoU 1), 4-thread determinism, 0 errors under MTL_DEBUG_LAYER=1, pytest passes.