-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Intel NPU acceleration Library release
- Loading branch information
1 parent
ff2e389
commit bb4a4f8
Showing
86 changed files
with
7,270 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
BasedOnStyle: Google | ||
|
||
Language: Cpp | ||
Standard: Cpp11 | ||
|
||
AccessModifierOffset: -4 | ||
AlignAfterOpenBracket: Align | ||
AllowAllArgumentsOnNextLine: false | ||
AllowAllConstructorInitializersOnNextLine: true | ||
AllowShortBlocksOnASingleLine: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: None | ||
AllowShortIfStatementsOnASingleLine: Never | ||
AllowShortLambdasOnASingleLine: Empty | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakBeforeMultilineStrings: false | ||
BreakInheritanceList: AfterColon | ||
ColumnLimit: 120 | ||
ConstructorInitializerIndentWidth: 8 | ||
ContinuationIndentWidth: 8 | ||
DerivePointerAlignment: false | ||
FixNamespaceComments: true | ||
IncludeBlocks: Preserve | ||
IndentCaseLabels: false | ||
IndentWidth: 4 | ||
PointerAlignment: Left | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: false | ||
UseTab: Never | ||
StatementMacros: ['CASE', 'HW_OPS_CASE'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#! python | ||
# | ||
# Copyright © 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache 2.0 | ||
# | ||
|
||
import datetime | ||
import sys | ||
import os | ||
|
||
LICENSE_TYPE = "Apache 2.0" | ||
LICENSE_STR = f"SPDX-License-Identifier: {LICENSE_TYPE}" | ||
|
||
COPYRIGHT = f"Copyright © {datetime.datetime.now().year} Intel Corporation" | ||
|
||
if __name__ == "__main__": | ||
ret = 0 | ||
for filename in sys.argv: | ||
_, file_extension = os.path.splitext(filename) | ||
if "CMakeLists.txt" in filename or file_extension in [ | ||
".h", | ||
".hpp", | ||
".cpp", | ||
".c", | ||
".py", | ||
".js", | ||
".sh", | ||
]: | ||
with open(filename, encoding="utf-8") as fp: | ||
text = fp.read() | ||
if LICENSE_STR not in text: | ||
print(f"[pre-commit] {filename} does not have a valid license!") | ||
ret = 1 | ||
if COPYRIGHT not in text: | ||
print(f"[pre-commit] {filename} does not have a valid copyright!") | ||
ret = 1 | ||
|
||
sys.exit(ret) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Documentation | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: [linux] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
- name: Install packet | ||
run: | | ||
sudo apt-get install -y doxygen | ||
python -m pip install --upgrade pip | ||
pip install .[dev] | ||
- name: Run tests | ||
run: | | ||
cd docs | ||
python build_doc.py gh-deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Style | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: [linux] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
- name: Install packet | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install .[dev] | ||
- name: Run tests | ||
run: pre-commit run --all-files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Test | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: [linux] | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install packet | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox tox-gh-actions | ||
- name: Run tests | ||
run: tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
__pycache__ | ||
cache | ||
logs | ||
models | ||
ov | ||
*.json | ||
build | ||
*.egg-info | ||
dist | ||
lib | ||
*.csv | ||
*.png | ||
*.bin | ||
*.xml | ||
|
||
_build | ||
site | ||
data | ||
xml | ||
.coverage* | ||
coverity | ||
.tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# | ||
# Copyright (C) 2022 Intel Corporation | ||
# SPDX-License-Identifier: Apache 2.0 | ||
# | ||
|
||
default_install_hook_types: [pre-commit, commit-msg] | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: check-license | ||
name: Check license | ||
entry: ./.githooks/check-license.py | ||
language: python | ||
stages: [commit] | ||
|
||
- repo: https://github.com/pre-commit/mirrors-clang-format | ||
rev: v10.0.1 | ||
hooks: | ||
- id: clang-format | ||
- repo: https://github.com/psf/black | ||
rev: 22.6.0 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/PyCQA/bandit | ||
rev: 1.7.7 | ||
hooks: | ||
- id: bandit | ||
args: ["-c", "bandit.yaml"] | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.1.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: check-json | ||
- id: check-executables-have-shebangs | ||
- id: check-symlinks | ||
- id: debug-statements | ||
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 6.1.0 | ||
hooks: | ||
- id: flake8 | ||
additional_dependencies: [ | ||
'flake8-blind-except', | ||
'flake8-docstrings', | ||
'flake8-bugbear', | ||
'flake8-comprehensions', | ||
'flake8-docstrings-complete', | ||
'flake8-implicit-str-concat', | ||
'pydocstyle>=5.0.0', | ||
] | ||
exclude: docs/.*|setup.py|test/.*|script/.*|examples/.* | ||
- repo: https://github.com/regebro/pyroma | ||
rev: "4.2" | ||
hooks: | ||
- id: pyroma | ||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: 'v1.8.0' | ||
hooks: | ||
- id: mypy | ||
exclude: 'docs|script|test|venv' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# | ||
# Copyright © 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache 2.0 | ||
# | ||
|
||
cmake_minimum_required(VERSION 3.16) | ||
include(FetchContent) | ||
|
||
project(intel_npu_acceleration_library) | ||
|
||
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to") | ||
|
||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") | ||
# lots of warnings and all warnings as errors | ||
message(STATUS "Setting GCC/Clang specific flags for the entire build") | ||
add_compile_options(-Wall -Wextra -Werror -pedantic -Wdouble-promotion -Wfloat-conversion -march=native) | ||
set(CMAKE_CXX_FLAGS_DEBUG "-g") | ||
set(CMAKE_CXX_FLAGS_RELEASE "-O3") | ||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") | ||
message(STATUS "Setting Visual Studio specific flags for the entire build") | ||
add_compile_options(/W3 /WX /arch:AVX2 /arch:SSE2) | ||
add_link_options(/WX) | ||
else() | ||
message(AUTHOR_WARNING "-- Building with unrecognised compiler, not setting any specific flags") | ||
endif() | ||
|
||
function(get_linux_lsb_release_information) | ||
find_program(LSB_RELEASE_CMD lsb_release) | ||
if(NOT LSB_RELEASE_CMD) | ||
message(FATAL_ERROR "Command lsb_release cannot be found") | ||
endif() | ||
|
||
execute_process(COMMAND "${LSB_RELEASE_CMD}" --short --id OUTPUT_VARIABLE LSB_RELEASE_ID OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
execute_process(COMMAND "${LSB_RELEASE_CMD}" --short --release OUTPUT_VARIABLE LSB_RELEASE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
set(LSB_RELEASE_ID "${LSB_RELEASE_ID}" PARENT_SCOPE) | ||
set(LSB_RELEASE_VERSION "${LSB_RELEASE_VERSION}" PARENT_SCOPE) | ||
endfunction() | ||
|
||
if (WIN32) | ||
if(NOT OV_LIBRARY_URL) | ||
set(OV_LIBRARY_URL "https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.3/windows/w_openvino_toolkit_windows_2023.3.0.13775.ceeafaf64f3_x86_64.zip") | ||
endif() | ||
elseif(UNIX) | ||
if(NOT OV_LIBRARY_URL) | ||
get_linux_lsb_release_information() | ||
if (LSB_RELEASE_ID STREQUAL "Ubuntu") | ||
if (${LSB_RELEASE_VERSION} STREQUAL "18.04" OR ${LSB_RELEASE_VERSION} STREQUAL "20.04" OR ${LSB_RELEASE_VERSION} STREQUAL "22.04") | ||
string(REPLACE ".04" "" LSB_RELEASE_VERSION_SHORT ${LSB_RELEASE_VERSION}) | ||
set(OV_LIBRARY_URL "https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.3/linux/l_openvino_toolkit_ubuntu${LSB_RELEASE_VERSION_SHORT}_2023.3.0.13775.ceeafaf64f3_x86_64.tgz") | ||
else() | ||
message(FATAL_ERROR "Ubuntu version ${LSB_RELEASE_VERSION} is unsupported") | ||
endif() | ||
else() | ||
message(FATAL_ERROR "Linux distribution ${LSB_RELEASE_ID} is unsupported") | ||
endif() | ||
|
||
endif() | ||
else() | ||
message(FATAL_ERROR "Unsupported architecture") | ||
endif () | ||
|
||
|
||
FetchContent_Declare( | ||
openvino | ||
URL ${OV_LIBRARY_URL} | ||
) | ||
FetchContent_MakeAvailable(openvino) | ||
|
||
find_package(OpenVINO REQUIRED PATHS ${openvino_SOURCE_DIR}/runtime/cmake) | ||
|
||
if (WIN32) | ||
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) | ||
file(GLOB OpenVINObin ${openvino_SOURCE_DIR}/runtime/bin/intel64/Release/*) | ||
file(COPY ${OpenVINObin} DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/Release) | ||
|
||
file(GLOB TBBlib ${openvino_SOURCE_DIR}/runtime/3rdparty/tbb/bin/*) | ||
file(COPY ${TBBlib} DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/Release) | ||
else() | ||
file(GLOB OpenVINObin ${openvino_SOURCE_DIR}/runtime/lib/intel64/*) | ||
file(COPY ${OpenVINObin} DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) | ||
endif() | ||
|
||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
||
include_directories(include) | ||
|
||
# Create the Python module | ||
add_library(intel_npu_acceleration_library SHARED src/bindings.cpp) | ||
|
||
# Link the OpenVINO libraries | ||
target_link_libraries(intel_npu_acceleration_library PRIVATE openvino::runtime) | ||
if (UNIX) | ||
set_target_properties(intel_npu_acceleration_library PROPERTIES LINK_FLAGS "-Wl,-rpath,./") | ||
endif (UNIX) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.