Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

This file records user-visible changes to `light-ocr`. Published artifact details and immutable hashes remain in [`docs/releases/`](docs/releases/).

## [Unreleased]

### Added

- Added a source-level Intel NPU backend (`provider: "openvino"`) for Linux x64.
Builds configured with `LIGHT_OCR_OPENVINO_SDK_DIR` load the OpenVINO C
runtime at run time, run detection and 20-bucket recognition on the NPU, and
place `openvino` first in a qualification-only Auto policy
(`openvino → webgpu → cpu`); hosts without an NPU skip it with
`adapter_unavailable`. Published npm packages do not include OpenVINO yet, so
`provider: "openvino"` returns `unsupported_capability` there. See
[Intel NPU 加速技术方案](docs/intel-npu-acceleration.md).

## [0.5.8] - 2026-09-24

### Added
Expand Down
35 changes: 35 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ set(LIGHT_OCR_ORACLE_PYTHON "" CACHE FILEPATH "Pinned Python interpreter for par
set(LIGHT_OCR_NODE_INCLUDE_DIR "" CACHE PATH "Directory containing node_api.h")
set(LIGHT_OCR_NODE_LIBRARY "" CACHE FILEPATH "Windows Node import library")
set(LIGHT_OCR_NODE_EXECUTABLE "" CACHE FILEPATH "Node.js executable used for adapter tests")
set(LIGHT_OCR_OPENVINO_SDK_DIR "" CACHE PATH
"OpenVINO SDK root with include/openvino/c; enables the Intel NPU backend on Linux x64")
set(LIGHT_OCR_OPENVINO_C_LIBRARY "" CACHE FILEPATH
"OpenVINO C runtime loaded by direct C++ callers; defaults to <SDK>/lib/libopenvino_c.so")

if(LIGHT_OCR_ENABLE_SANITIZERS AND LIGHT_OCR_ENABLE_THREAD_SANITIZER)
message(FATAL_ERROR "Address/Undefined sanitizers and ThreadSanitizer require separate builds")
Expand Down Expand Up @@ -138,6 +142,34 @@ if(LIGHT_OCR_HAS_WEBGPU)
endif()
endif()

set(LIGHT_OCR_HAS_OPENVINO OFF)
if(LIGHT_OCR_OPENVINO_SDK_DIR)
if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$"))
message(FATAL_ERROR "The OpenVINO NPU backend currently targets Linux x64 only")
endif()
set(_light_ocr_openvino_include "${LIGHT_OCR_OPENVINO_SDK_DIR}/include")
if(NOT EXISTS "${_light_ocr_openvino_include}/openvino/c/openvino.h")
message(FATAL_ERROR
"LIGHT_OCR_OPENVINO_SDK_DIR has no include/openvino/c/openvino.h: ${LIGHT_OCR_OPENVINO_SDK_DIR}")
endif()
if(NOT LIGHT_OCR_OPENVINO_C_LIBRARY)
set(LIGHT_OCR_OPENVINO_C_LIBRARY "${LIGHT_OCR_OPENVINO_SDK_DIR}/lib/libopenvino_c.so")
endif()
if(NOT EXISTS "${LIGHT_OCR_OPENVINO_C_LIBRARY}")
message(FATAL_ERROR "OpenVINO C runtime not found: ${LIGHT_OCR_OPENVINO_C_LIBRARY}")
endif()
set(LIGHT_OCR_HAS_OPENVINO ON)
# Headers only: the runtime is loaded with dlopen so the library never
# becomes a link-time dependency of the Core or the Node addon.
target_sources(light_ocr_core PRIVATE src/inference/openvino/backend.cpp)
target_include_directories(light_ocr_core SYSTEM PRIVATE "${_light_ocr_openvino_include}")
target_compile_definitions(light_ocr_core PRIVATE
LIGHT_OCR_HAS_OPENVINO=1
LIGHT_OCR_OPENVINO_DEFAULT_LIBRARY="${LIGHT_OCR_OPENVINO_C_LIBRARY}")
target_link_libraries(light_ocr_core PRIVATE ${CMAKE_DL_LIBS})
endif()

if(MSVC)
target_compile_options(light_ocr_core PRIVATE /W4 /WX /permissive- /EHsc /fp:strict)
else()
Expand Down Expand Up @@ -210,6 +242,9 @@ if(LIGHT_OCR_BUILD_TESTS)
target_compile_definitions(light_ocr_unit_tests PRIVATE
LIGHT_OCR_WEBGPU_QUALIFICATION_BUILD=1)
endif()
if(LIGHT_OCR_HAS_OPENVINO)
target_compile_definitions(light_ocr_unit_tests PRIVATE LIGHT_OCR_HAS_OPENVINO=1)
endif()
light_ocr_stage_onnxruntime(light_ocr_unit_tests)
add_test(NAME light_ocr_unit_tests COMMAND light_ocr_unit_tests)

Expand Down
4 changes: 3 additions & 1 deletion bindings/node/src/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,10 @@ ExecutionProvider parse_execution_provider(napi_env env, napi_value value) {
if (provider == "cpu") return ExecutionProvider::cpu;
if (provider == "apple") return ExecutionProvider::apple;
if (provider == "webgpu") return ExecutionProvider::webgpu;
if (provider == "openvino") return ExecutionProvider::openvino;
throw AddonFailure(
"invalid_argument",
"execution.provider must be auto, cpu, apple, or webgpu");
"execution.provider must be auto, cpu, apple, webgpu, or openvino");
}

SessionFallback parse_session_fallback(napi_env env, napi_value value) {
Expand Down Expand Up @@ -1621,6 +1622,7 @@ const char* execution_provider_string(ExecutionProvider provider) {
case ExecutionProvider::cpu: return "cpu";
case ExecutionProvider::apple: return "apple";
case ExecutionProvider::webgpu: return "webgpu";
case ExecutionProvider::openvino: return "openvino";
}
return "auto";
}
Expand Down
2 changes: 1 addition & 1 deletion docs/cli-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ light-ocr detect image.png --provider webgpu
| `--format` | json \| jsonl \| text | 默认 `json` |
| `--region` | `x,y,w,h` | pageSpace 轴对齐矩形,整数像素;详见 §7 |
| `--no-exif` | flag | 关闭默认 EXIF orientation 修正;详见 §6 |
| `--provider` | auto \| cpu \| apple \| webgpu | 映射 `execution.provider` |
| `--provider` | auto \| cpu \| apple \| webgpu \| openvino | 映射 `execution.provider`;`openvino` 仅在包含 OpenVINO NPU runtime 的构建中可用 |
| `--schema-version` | 1 | 请求精确输出 schema;不支持则稳定失败 |

`--help` 第二层(高级):
Expand Down
Loading
Loading