Skip to content

Commit

Permalink
[NPUW] Add initial unpack and partitioning unit tests on NPUW (openvi…
Browse files Browse the repository at this point in the history
…notoolkit#25780)

This PR adds unit tests on
1) unpack routines within NPUW
2) main online partitioning functionality (smaller unit tests on
`Graph`, `Group`, `Repeated`, etc will be added separately)

Local run:
```
[----------] Global test environment tear-down
[==========] 334 tests from 6 test suites ran. (3379 ms total)
[  PASSED  ] 334 tests.
```
  • Loading branch information
smirnov-alexey authored Oct 1, 2024
1 parent 9284684 commit ad448dd
Show file tree
Hide file tree
Showing 6 changed files with 1,478 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ namespace ov {
namespace npuw {
namespace online {

class Group; // forward declaration

namespace detail {
// At partitioning level we exclude some "non-Ops" to not interfere with the passes.
// We include some of them back to properly link everything at plugin level
Expand All @@ -33,6 +31,8 @@ class Snapshot : public std::enable_shared_from_this<Snapshot> {
m_node_to_prod_cons(std::make_shared<detail::OVNodeMap>()),
m_node_to_gr(std::make_shared<detail::OVNodeToGroupMap>()) {}

friend class Group; // forward declaration

// Simple passes
void singleGroup();

Expand All @@ -49,27 +49,27 @@ class Snapshot : public std::enable_shared_from_this<Snapshot> {
void repeatedBlocks();
void earlyAvoids();
void earlyRegroup();
void markInternalCompute();
void resetExcludedRep();

// Utility
std::shared_ptr<own::ade::Graph> getGraph() const;
size_t graphSize() const;
const detail::OVNodeSet& getNodeProducers(const detail::OVNodePtr& node) const;
const detail::OVNodeSet& getNodeConsumers(const detail::OVNodePtr& node) const;
const detail::OVPortsMap& getPortsMap() const;
const detail::OVNodeToGroupMapPtr& getNodeToGroupMap() const;
const std::map<std::string, std::vector<std::set<std::string>>>& getMatches() const;
detail::GPtrSet getRepGroups(const std::shared_ptr<Group>& group) const;
void repeat(detail::Pass&& pass);
void setCtx(const PassContext& ctx);
size_t graphSize() const;

private:
detail::GPtrSet getRepGroups(const std::shared_ptr<Group>& group) const;
const detail::OVNodeSet& getNodeProducers(const detail::OVNodePtr& node) const;
const detail::OVNodeSet& getNodeConsumers(const detail::OVNodePtr& node) const;
void identifyUniques();
void mergeUniques();
void mergeTriangles();
void cleanUpUniques();
void afterUniques();
void markInternalCompute();
void resetExcludedRep();
bool cleanUpUniquesImpl(const detail::GPtrSet& gset);
std::shared_ptr<Repeated> tryGrowRepeatingGroups(const detail::GPtrSet& repeating_groups);
std::shared_ptr<Repeated> tryMergeTriangles(const detail::GPtrSet& repeating_groups);
Expand Down
1 change: 1 addition & 0 deletions src/plugins/intel_npu/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ if (MSVC)
ov_add_compiler_flags(/wd5105)
endif()
add_subdirectory(functional)
add_subdirectory(unit)
49 changes: 49 additions & 0 deletions src/plugins/intel_npu/tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

set(TARGET_NAME "ov_npu_unit_tests")

set(MANDATORY_UNIT_TESTS_LIBS
"openvino::commonTestUtils"
"openvino::gmock"
"openvino::gtest"
"openvino::gtest_main"
"openvino::runtime"
"openvino::npu_al"
"openvino::npu_logger_utils"
)

ov_add_test_target(
NAME ${TARGET_NAME}
ROOT ${CMAKE_CURRENT_SOURCE_DIR}
ADDITIONAL_SOURCE_DIRS
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw/
DEPENDENCIES
openvino::runtime
INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/npuw
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/npuw
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/utils/include
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/plugin/include
${OpenVINO_SOURCE_DIR}/src/plugins/intel_npu/src/al/include
LINK_LIBRARIES
${MANDATORY_UNIT_TESTS_LIBS}
LABELS
NPUW
)

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(${TARGET_NAME} PRIVATE -mavx2 -mf16c)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(${TARGET_NAME} PRIVATE /arch:AVX2)
else()
message(AUTHOR_WARNING "Unknown compiler, may miss the AVX2 baseline setting")
endif()

install(TARGETS ${TARGET_NAME}
RUNTIME DESTINATION tests
COMPONENT tests
EXCLUDE_FROM_ALL
)
Loading

0 comments on commit ad448dd

Please sign in to comment.