install_dir : join_paths(ne_bindir, 'unittests')
)
test('unittest_ne_libnpuhost', unittest_ne_libnpuhost, env: testenv, suite: ['fast-test'])
+
+ unittest_ne_core_profiler = executable('unittest_ne_core_profiler',
+ ['ne_core_profiler_test.cc'],
+ include_directories: [ne_host_inc, ne_common_inc],
+ dependencies: [ne_test_utils_gtest_dep, ne_host_dep, ne_core_dep],
+ install : true,
+ install_rpath : ne_libdir,
+ install_dir : join_paths(ne_bindir, 'unittests')
+ )
+ test('unittest_ne_core_profiler', unittest_ne_core_profiler, env: testenv, suite: ['fast-test'])
endif
--- /dev/null
+/* SPDX-License-Identifier: Apache-2.0 */
+/**
+ * Copyright (C) 2022 Samsung Electronics
+ * Copyright (C) 2022 Yelin Jeong <yelini.jeong@samsung.com>
+ */
+/**
+ * @file ne_core_profiler_test.cc
+ * @date 23 Nov 2022
+ * @brief Test npu profiler
+ * @author Yelin Jeong <yelini.jeong@samsung.com>
+ * @bug No known bugs except for NYI items
+ */
+
+#include <ne_test_utils_gtest.h>
+#include <ne-profiler.h>
+#include <ne-handler.h>
+
+#define REC_PATH NE_BINDIR "/testdata/triv2.4_nodlp_284.rec"
+#define DLP_REC_PATH NE_BINDIR "/testdata/triv2.4_dlp_284_485.rec"
+
+/**
+ * @brief check mergeProfile
+ */
+TEST (ne_core_profiler_test, merge_profile) {
+ const npu_profile_opt opt_visa = {.level = PROFILE_LEVEL_VISA};
+
+ int ret, num_devices = DriverAPI::getNumDevices (NPUCOND_TRIV2_CONN_SOCIP);
+ ASSERT_GT (num_devices, 0);
+
+ auto api = DriverAPI::createDriverAPI (NPUCOND_TRIV2_CONN_SOCIP, 0);
+ ModelProfiler *profiler = new ModelProfiler (api.get ());
+ ASSERT_NE (api.get (), nullptr);
+
+ npu_profile profile = {0};
+
+ if (!std::ifstream (REC_PATH)) {
+ printf ("no rec file %s found\n", REC_PATH);
+ return;
+ }
+
+ ret = profiler->getProfile (1, opt_visa, &profile, REC_PATH);
+ ASSERT_EQ (ret, 0);
+
+ npu_profile profile_dlp = {0};
+
+ if (!std::ifstream (DLP_REC_PATH)) {
+ printf ("no rec file %s found\n", DLP_REC_PATH);
+ return;
+ }
+
+ ret = profiler->getProfile (1, opt_visa, &profile_dlp, DLP_REC_PATH);
+ ASSERT_EQ (ret, 0);
+
+ ASSERT_EQ (profile.num_layers, profile_dlp.num_layers);
+ for (int i = 0; i < profile.num_layers; i++) {
+ EXPECT_EQ (profile.layers[i].visa_opcode, profile_dlp.layers[i].visa_opcode);
+ }
+}
+
+/**
+ * @brief check mergeProfile
+ */
+TEST (ne_core_profiler_test, profile_level_visa_dlp) {
+ const npu_profile_opt opt_dlp = {.level = PROFILE_LEVEL_VISA_DLP};
+ const npu_profile_opt opt_visa = {.level = PROFILE_LEVEL_VISA};
+
+ int ret, num_devices = DriverAPI::getNumDevices (NPUCOND_TRIV2_CONN_SOCIP);
+ ASSERT_GT (num_devices, 0);
+
+ auto api = DriverAPI::createDriverAPI (NPUCOND_TRIV2_CONN_SOCIP, 0);
+ ModelProfiler *profiler = new ModelProfiler (api.get ());
+ ASSERT_NE (api.get (), nullptr);
+
+ npu_profile profile_dlp = {0};
+ npu_profile profile_visa = {0};
+
+ if (!std::ifstream (DLP_REC_PATH)) {
+ printf ("no rec file %s found\n", DLP_REC_PATH);
+ return;
+ }
+
+ ret = profiler->getProfile (1, opt_dlp, &profile_dlp, DLP_REC_PATH);
+ ASSERT_EQ (ret, 0);
+ ASSERT_EQ (profile_dlp.num_layers, 485);
+
+ ret = profiler->getProfile (1, opt_visa, &profile_visa, DLP_REC_PATH);
+ ASSERT_EQ (ret, 0);
+ ASSERT_EQ (profile_visa.num_layers, 284);
+}
+
+/**
+ * @brief main function for unit test
+ */
+int
+main (int argc, char **argv) {
+ return start_gtest (argc, argv);
+}