Skip to content

Commit

Permalink
Intel NPU acceleration Library release
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandropalla committed Feb 28, 2024
1 parent ff2e389 commit bb4a4f8
Show file tree
Hide file tree
Showing 86 changed files with 7,270 additions and 8 deletions.
30 changes: 30 additions & 0 deletions .clang-format
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']
38 changes: 38 additions & 0 deletions .githooks/check-license.py
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)
11 changes: 11 additions & 0 deletions .github/dependabot.yml
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"
26 changes: 26 additions & 0 deletions .github/workflows/documentation.yml
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
24 changes: 24 additions & 0 deletions .github/workflows/style.yml
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
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
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
22 changes: 22 additions & 0 deletions .gitignore
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
61 changes: 61 additions & 0 deletions .pre-commit-config.yaml
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'
97 changes: 97 additions & 0 deletions CMakeLists.txt
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)


2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ For answers to common questions about this code of conduct, see the FAQ at
[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[FAQ]: https://www.contributor-covenant.org/faq
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Contributing

### License
## License

<PROJECT NAME> is licensed under the terms in [LICENSE]<link to license file in repo>. By contributing to the project, you agree to the license and copyright terms therein and release your contribution under these terms.
Intel® NPU Acceleration Library is licensed under the terms in [LICENSE](LICENSE). By contributing to the project, you agree to the license and copyright terms therein and release your contribution under these terms.

### Sign your work
## Sign your work

Please use the sign-off line at the end of the patch. Your signature certifies that you wrote the patch or otherwise have the right to pass it on as an open-source patch. The rules are pretty simple: if you can certify
the below (from [developercertificate.org](http://developercertificate.org/)):

```
```text
Developer Certificate of Origin
Version 1.1
Expand Down Expand Up @@ -54,4 +54,4 @@ Then you just add a line to every git commit message:
Use your real name (sorry, no pseudonyms or anonymous contributions.)

If you set your `user.name` and `user.email` git configs, you can sign your
commit automatically with `git commit -s`.
commit automatically with `git commit -s`.
Loading

0 comments on commit bb4a4f8

Please sign in to comment.