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
84 changes: 84 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
Checks: >
-*,
bugprone-argument-comment,
bugprone-assert-side-effect,
bugprone-branch-clone,
bugprone-copy-constructor-init,
bugprone-dangling-handle,
bugprone-dynamic-static-initializers,
bugprone-macro-parentheses,
bugprone-macro-repeated-side-effects,
bugprone-misplaced-widening-cast,
bugprone-move-forwarding-reference,
bugprone-multiple-statement-macro,
bugprone-suspicious-semicolon,
bugprone-swapped-arguments,
bugprone-terminating-continue,
bugprone-unused-raii,
bugprone-unused-return-value,
clang-analyzer-*,
clang-diagnostic-*,
cppcoreguidelines-*,
-cppcoreguidelines-slicing,
misc-*,
-misc-const-correctness,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
modernize-loop-convert,
modernize-make-shared,
modernize-make-unique,
modernize-raw-string-literal,
modernize-use-auto,
modernize-use-bool-literals,
modernize-use-default-member-init,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-nullptr,
modernize-use-override,
modernize-use-using,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-algorithm,
performance-inefficient-vector-operation,
performance-move-const-arg,
performance-no-automatic-move,
performance-trivially-destructible,
performance-unnecessary-copy-initialization,
performance-unnecessary-value-param,
readability-avoid-const-params-in-decls,
readability-braces-around-statements,
readability-const-return-type,
readability-container-size-empty,
readability-identifier-naming,
readability-inconsistent-declaration-parameter-name,
readability-misleading-indentation,
readability-redundant-control-flow,
readability-redundant-smartptr-get,
readability-simplify-boolean-expr,
readability-simplify-subscript-expr

CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
value: camelBack
# Exclude from scanning as this is an exported symbol used for fuzzing
# throughout the code base.
- key: readability-identifier-naming.FunctionIgnoredRegexp
value: "LLVMFuzzerTestOneInput"
- key: readability-identifier-naming.MemberCase
value: camelBack
- key: readability-identifier-naming.ParameterCase
value: camelBack
- key: readability-identifier-naming.UnionCase
value: CamelCase
- key: readability-identifier-naming.VariableCase
value: camelBack
- key: readability-identifier-naming.IgnoreMainLikeFunctions
value: 1
- key: readability-identifier-naming.PrivateMemberPrefix
value: _
- key: modernize-use-default-member-init.UseAssignment
value: 1
16 changes: 8 additions & 8 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
## Summary
> Please add a short but exhaustive summary why you think your pull request is useful

(Please add a short summary why your pull request is useful)
## Target Platform For Release Notes
> Aids the generation of release notes

## Target Platform For Release Notes (Mandatory)

Aids the generation of release notes

- [ ] VPUX30XX
- [ ] VPUX31XX
- [ ] VPUX37XX
- [ ] NPU37XX
- [ ] NPU40XX
- [ ] NONE (Not included in release notes)

## Classification of this Pull Request
Expand All @@ -18,6 +14,10 @@ Aids the generation of release notes
- [ ] BUG
- [ ] Feature

## Related PRs

* [PR-xxx](https://github.com/intel-innersource/applications.ai.vpu-accelerators.vpux-plugin/pull/xxx) description

## Code Review Survey (Copy and Complete in your code review)

- number_minutes_spent_on_review[0]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ output/
# VS Code
.vscode
CMakeSettings.json
.cache

# CMake user presets
CMakeUserPresets.json
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ if(ENABLE_MLIR_COMPILER)
endif()

add_subdirectory(src)
add_subdirectory(scripts)

if(ENABLE_PRIVATE_TESTS)
include(cmake/lit_tests.cmake)
Expand Down
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"CMAKE_EXPORT_COMPILE_COMMANDS" : true,

"ENABLE_DEVELOPER_BUILD": true,
"ENABLE_IMD_BACKEND": true,
"ENABLE_IMD_BACKEND": false,

"ENABLE_VPUX_DOCS": false
}
Expand Down
1 change: 0 additions & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# 1. Each directory should have a minimum of 2 code owners.
# 2. Order is important as the last matching pattern takes the most precedence.
# Keep folders below sorted in folder hierarchy order (alphabetically).

#
# Repo default owners
#
Expand Down
1 change: 0 additions & 1 deletion Security.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ Intel is committed to rapidly addressing security vulnerabilities affecting our

## Reporting a Vulnerability
Please report any security vulnerabilities in this project [utilizing the guidelines here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html).

2 changes: 1 addition & 1 deletion scripts/extract_layers_info/to_html/body.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020, 2023 Intel Corporation
* Copyright (C) 2020, 2023 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*/
body {
Expand Down
2 changes: 1 addition & 1 deletion scripts/extract_layers_info/to_html/table1.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020, 2023 Intel Corporation
* Copyright (C) 2020, 2023 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*/
table {
Expand Down
2 changes: 1 addition & 1 deletion scripts/extract_layers_info/to_html/table2.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020, 2023 Intel Corporation
* Copyright (C) 2020, 2023 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*/
table {
Expand Down
2 changes: 1 addition & 1 deletion scripts/extract_layers_info/to_html/table3.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020, 2023 Intel Corporation
* Copyright (C) 2020, 2023 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*/
table {
Expand Down
2 changes: 1 addition & 1 deletion scripts/extract_layers_info/to_html/table4.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020, 2023 Intel Corporation
* Copyright (C) 2020, 2023 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*/
table {
Expand Down
18 changes: 7 additions & 11 deletions scripts/run_all_lit_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ then
if [ "$1" = "-h" ] || [ "$1" = "--help" ]
then
USAGE="
Script that runs all lit-tests on VPUX30XX and VPUX37XX platforms.
Script that runs all lit-tests on each platform.

Usage: ./run_all_lit_tests.sh [PATH_TESTS] [PATH_LIT_TOOL]

Expand Down Expand Up @@ -37,21 +37,17 @@ fi
echo "PATH_TESTS=$PATH_TESTS"
echo "PATH_LIT_TOOL=$PATH_LIT_TOOL"

CMD_VPUX30XX_TESTS="python3 $PATH_LIT_TOOL --param arch=VPUX30XX $PATH_TESTS/NPU"
CMD_VPUX37XX_TESTS="python3 $PATH_LIT_TOOL --param arch=VPUX37XX $PATH_TESTS/NPU"
CMD_VPUX40XX_TESTS="python3 $PATH_LIT_TOOL --param arch=VPUX40XX $PATH_TESTS/NPU"
CMD_NPU37XX_TESTS="python3 $PATH_LIT_TOOL --param arch=NPU37XX $PATH_TESTS/NPU"
CMD_NPU40XX_TESTS="python3 $PATH_LIT_TOOL --param arch=NPU40XX $PATH_TESTS/NPU"

EXIT_CODE=0

echo ""
echo "Executing tests on VPUX30XX platform: $CMD_VPUX30XX_TESTS"
eval "$CMD_VPUX30XX_TESTS"; EXIT_CODE=$(($EXIT_CODE + $?))
echo "Executing tests on NPU37XX platform: $CMD_NPU37XX_TESTS"
eval "$CMD_NPU37XX_TESTS"; EXIT_CODE=$(($EXIT_CODE + $?))
echo ""
echo "Executing tests on VPUX37XX platform: $CMD_VPUX37XX_TESTS"
eval "$CMD_VPUX37XX_TESTS"; EXIT_CODE=$(($EXIT_CODE + $?))
echo ""
echo "Executing tests on VPUX40XX platform: $CMD_VPUX40XX_TESTS"
eval "$CMD_VPUX40XX_TESTS"; EXIT_CODE=$(($EXIT_CODE + $?))
echo "Executing tests on NPU40XX platform: $CMD_NPU40XX_TESTS"
eval "$CMD_NPU40XX_TESTS"; EXIT_CODE=$(($EXIT_CODE + $?))
echo ""

if [ $EXIT_CODE -ne 0 ]
Expand Down
4 changes: 0 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ if(BUILD_COMPILER_FOR_DRIVER)
add_subdirectory(vpux_driver_compiler)
endif()

if(ENABLE_IMD_BACKEND)
add_subdirectory(vpux_imd_backend)
endif()

add_subdirectory(vpux_utils)

add_subdirectory(vpux_compiler)
Expand Down
14 changes: 7 additions & 7 deletions src/vpux_compiler/docs/code_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ This guide is not intended to cover all possible coding problems. Its ultimate g
## Resources/Links
- [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines)
- [Clang Format](https://clang.llvm.org/docs/ClangFormat.html)
- [Our Clang-Format configuration](../../../.clang-format)
- [Our Clang-Format configuration](../../../.clang-format)
- [Clang Tidy](https://clang.llvm.org/extra/clang-tidy/)
- [List of checks](https://clang.llvm.org/extra/clang-tidy/checks/list.html)
- [Our Clang-Tidy configuration](../../../.clang-tidy)
- [Our Clang-Tidy configuration](../../../.clang-tidy)

## Naming

Expand Down Expand Up @@ -143,7 +143,7 @@ Check [here](https://en.cppreference.com/w/cpp/language/operator_alternative) fo
### Type Inference

In most cases it should be preferred to use `auto` for the sake of correctness, flexibility and
maintainability.
maintainability.

- Prefer to write code against interfaces rather than implementations (care about "what", not "how")
- Reduces needless verbosity of types like iterators
Expand Down Expand Up @@ -751,7 +751,7 @@ void implementPattern(IE::ConvolutionOp origOp) {
// OK, locations are preserved
auto outReshape = rewriter.replaceOpWithNewOp<IE::ReshapeOp>(origOp, newConvOp->getResult(0), nullptr, false, outputShapeAttr);
extendOpLoc(outReshape, "reshape_out");

// BAD, use extendOpLoc
outReshape->setLoc(appendLoc(outReshape->getLoc(), "reshape_out"));
}
Expand All @@ -769,12 +769,12 @@ _builder.create<mlir::memref::AllocOp>(mlir::NameLoc::get(mlir::StringAttr::get(

### Location format

Each `appendLoc` or similar function adds new element to `FusedLoc` list and should represent new level of transformation or legalization of operation. During serialization all elements are joined with help of `/` symbol, so `/` should not be used in the location parts to avoid misunderstanding.
Each `appendLoc` or similar function adds new element to `FusedLoc` list and should represent new level of transformation or legalization of operation. During serialization all elements are joined with help of `/` symbol, so `/` should not be used in the location parts to avoid misunderstanding.

Use the following guidelines when constructing new location information:

- Use `"{transform}_{operand}"` format for new operations. Prefer tablegen defined operand name of the original operation and a new operation type as transform. Use `in` for main input, `out` for operation result and `in1`/`in2` for eltwise operations. For example `reshape_in`, `transpose_out`, `quantize_filter`.
- Use `"as_{new_op_type}"` format if operation type was changed.
- Use `"{transform}_{operand}"` format for new operations. Prefer tablegen defined operand name of the original operation and a new operation type as transform. Use `in` for main input, `out` for operation result and `in1`/`in2` for eltwise operations. For example `reshape_in`, `transpose_out`, `quantize_filter`.
- Use `"as_{new_op_type}"` format if operation type was changed.
- Split words using `_`. Do not use `_` prefix.
- For splitted or cloned operations use indices. For example `slice_in_{0}_{1}`.
- Provide location and operand name or location suffix to functions, which create new subgraph.
Expand Down
34 changes: 17 additions & 17 deletions src/vpux_compiler/docs/guides/how_to_debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ These tools can be used to call specific parts of the compiler (frontend, backen

`vpux-translate` allows calling the frontend and backend of the compiler. For example:

- importing OpenVINO IR into IE dialect IR: `vpux-translate --vpu-arch=VPUX37XX --import-IE <path to xml> -o <MLIR file name>`
- exporting VPUIP dialect IR into GraphFile blob: `vpux-translate --vpu-arch=VPUX37XX --export-VPUIP <path to MLIR file> -o <graph blob file name>`
- importing OpenVINO IR into IE dialect IR: `vpux-translate --vpu-arch=NPU37XX --import-IE <path to xml> -o <MLIR file name>`
- exporting VPUIP dialect IR into GraphFile blob: `vpux-translate --vpu-arch=NPU37XX --export-VPUIP <path to MLIR file> -o <graph blob file name>`

The full list of supported frontends and backends can be found in [vpux-translate.cpp](../../../../tools/vpux-translate/vpux-translate.cpp).

Expand All @@ -90,13 +90,13 @@ The rest of the options can be found by calling `vpux-translate --help`.

```sh
# Call the ConvertLayersToVPU pass over the input IR found in the file
vpux-opt --vpu-arch=VPUX37XX --convert-layers-to-VPU <MLIR file name>
vpux-opt --vpu-arch=NPU37XX --convert-layers-to-VPU <MLIR file name>

# Call the ExpandActivationChannels and Canonicalizer passes over the IR
vpux-opt --vpu-arch=VPUX37XX --expand-activation-channels --canonicalizer <MLIR file name>
vpux-opt --vpu-arch=NPU37XX --expand-activation-channels --canonicalizer <MLIR file name>

# Call the LowPrecision pipeline over the IR
vpux-opt --vpu-arch=VPUX37XX --low-precision <MLIR file name>
vpux-opt --vpu-arch=NPU37XX --low-precision <MLIR file name>
```

The tool offers some features which can help in debugging the target code:
Expand All @@ -118,13 +118,13 @@ The tools can be used to perform a full compilation of a model:

```sh
# Import an OpenVINO IR into IE dialect
./vpux-translate --vpu-arch=VPUX37XX --import-IE <path to OV IR> -o net.mlir
./vpux-translate --vpu-arch=NPU37XX--import-IE <path to OV IR> -o net.mlir

# Call the DefaultHWMode pipeline over the imported IR
./vpux-opt --vpu-arch=VPUX37XX --default-hw-mode net.mlir -o net_out.mlir
./vpux-opt --vpu-arch=NPU37XX --default-hw-mode net.mlir -o net_out.mlir

# Export the final IR into a GraphFile blob
./vpux-translate --vpu-arch=VPUX37XX --export-VPUIP net_out.mlir > net.blob
./vpux-translate --vpu-arch=NPU37XX --export-VPUIP net_out.mlir > net.blob
```

Since each pass or pipeline can be specified individually, the user can have full control over the calling order of the passes if that is necessary. Options such as `--mlir-print-debuginfo` can also be included for both tools to also track the changes done to the original layers.
Expand Down Expand Up @@ -166,17 +166,17 @@ An example of how to generate and run a reproducer using `compile_tool`, by maki
IE_NPU_CRASH_REPRODUCER_FILE=reproducer.mlir compile_tool -d VPUX.3720 -ip FP16 -op FP16 -il NCHW -iml NCHW -ol NC -oml NC -m net.xml

# Execute the reproducer
vpux-opt --vpu-arch=VPUX37XX reproducer.mlir
vpux-opt --vpu-arch=NPU37XX reproducer.mlir
```

It is also possible to generate reproducers with `vpux-opt` directly, by using the `--mlir-pass-pipeline-crash-reproducer` argument. For example:

```sh
# Generate the reproducer
vpux-opt --vpu-arch=VPUX37XX --convert-layers-to-VPU --mlir-pass-pipeline-crash-reproducer=reproducer.mlir net.mlir
vpux-opt --vpu-arch=NPU37XX --convert-layers-to-VPU --mlir-pass-pipeline-crash-reproducer=reproducer.mlir net.mlir

# Execute the reproducer
vpux-opt --vpu-arch=VPUX37XX reproducer.mlir
vpux-opt --vpu-arch=NPU37XX reproducer.mlir
```

### Local reproducers
Expand All @@ -192,7 +192,7 @@ When compiling a network, the reproducer scope can be controlled using the `IE_N
When using `vpux-opt`, the local reproducer can also be used. For example:

```sh
vpux-opt --vpu-arch=VPUX37XX --low-precision --mlir-pass-pipeline-crash-reproducer=reproducer.mlir --mlir-pass-pipeline-local-reproducer --mlir-disable-threading net.mlir
vpux-opt --vpu-arch=NPU37XX --low-precision --mlir-pass-pipeline-crash-reproducer=reproducer.mlir --mlir-pass-pipeline-local-reproducer --mlir-disable-threading net.mlir
```

MLIR multi-threading has to be disabled when running the local reproducer. Internally, when using `IE_NPU_GEN_LOCAL_REPRODUCER` this is already handled, but using this option with `vpux-opt` requires it to be explicitly disabled.
Expand Down Expand Up @@ -251,15 +251,15 @@ As described in [this section](#compiling-a-model-using-vpux-translate--vpux-opt

```sh
# Import an OpenVINO IR into IE dialect
./vpux-translate --vpu-arch=VPUX37XX --import-IE <path to OV IR> -o net.mlir
./vpux-translate --vpu-arch=NPU37XX --import-IE <path to OV IR> -o net.mlir

# Use the GraphFile backend
./vpux-opt --vpu-arch=VPUX37XX --default-hw-mode net.mlir -o net_out.mlir
./vpux-translate --vpu-arch=VPUX37XX --export-VPUIP net_out.mlir > net.blob
./vpux-opt --vpu-arch=NPU37XX --default-hw-mode net.mlir -o net_out.mlir
./vpux-translate --vpu-arch=NPU37XX --export-VPUIP net_out.mlir > net.blob

# Use the ELF backend
./vpux-opt --vpu-arch=VPUX37XX --default-hw-mode --lower-VPUIP-to-ELF net.mlir -o net_out.mlir
./vpux-translate --vpu-arch=VPUX37XX --export-ELF net_out.mlir > net.blob
./vpux-opt --vpu-arch=NPU37XX --default-hw-mode --lower-VPUIP-to-ELF net.mlir -o net_out.mlir
./vpux-translate --vpu-arch=NPU37XX --export-ELF net_out.mlir > net.blob
```

### Deserializing a GraphFile blob
Expand Down
Loading