From 0851dba94bf518a764a3b458be6f168fe3730894 Mon Sep 17 00:00:00 2001 From: Dongju Chae Date: Wed, 26 May 2021 13:28:15 +0900 Subject: [PATCH] [Profile/Tests] Add a profile option to select profile level This patch adds a profile option to select profile level in tests. Signed-off-by: Dongju Chae --- tests/utils/ne_test_utils.cc | 26 ++++++++++++++++++++++---- tests/utils/ne_test_utils.h | 2 ++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/tests/utils/ne_test_utils.cc b/tests/utils/ne_test_utils.cc index c22997d..34a777a 100644 --- a/tests/utils/ne_test_utils.cc +++ b/tests/utils/ne_test_utils.cc @@ -213,6 +213,7 @@ UtilTrinity::UtilTrinity (dev_type type, bool need_model, bool verify) { dev_ = nullptr; type_ = type; noti_mode_ = NPU_INTERRUPT; + prof_level_ = PROFILE_LEVEL_VISA; need_model_ = need_model; verify_ = verify; @@ -265,6 +266,7 @@ UtilTrinity::printUsage (const char *prog_name, const char *param_str) { std::cerr << "Options: \n"; std::cerr << " -d \t Set a device node path (e.g., /dev/triv2-0)\n"; std::cerr << " -n \t Set output notimode [intr|polling]\n"; + std::cerr << " -p \t Set profile level [visa|layer]\n"; std::cerr << " -m \t\t Mute stdout/stderr messages\n"; std::cerr << " -s \t\t Enable run sync mode\n"; std::cerr << " -o \t\t Enable output dump mode\n"; @@ -301,6 +303,17 @@ UtilTrinity::setNotiMode (const std::string mode) { } } +/** @brief set profile level */ +void +UtilTrinity::setProfLevel (const std::string level) { + if (level == "visa") { + prof_level_ = PROFILE_LEVEL_VISA; + } else if (level == "layer") { + prof_level_ = PROFILE_LEVEL_LAYER; + } else { + std::cerr << "Unknown profile level: " << level << std::endl; + } +} /** @brief parse/set arguments and get working directory */ int UtilTrinity::parseArgs (int argc, char **argv, char **param, @@ -309,7 +322,7 @@ UtilTrinity::parseArgs (int argc, char **argv, char **param, optind = 0; opterr = 0; - while ((c = getopt (argc, argv, "d:n:msho")) != -1) { + while ((c = getopt (argc, argv, "d:n:p:msho")) != -1) { switch (c) { case 'd': setNodePath (optarg); @@ -317,6 +330,9 @@ UtilTrinity::parseArgs (int argc, char **argv, char **param, case 'n': setNotiMode (optarg); break; + case 'p': + setProfLevel (optarg); + break; case 'm': setMute (); break; @@ -327,8 +343,8 @@ UtilTrinity::parseArgs (int argc, char **argv, char **param, setDump (); break; case '?': - if (optopt == 'd' || optopt == 'n') - std::cerr << "Option 'd' or 'n' requires an extra argument"; + if (optopt == 'd' || optopt == 'n' || optopt == 'p') + std::cerr << "Option 'd', 'n', or 'p' requires an extra argument"; else std::cerr << "Unknown flag: " << c; std::cerr << std::endl; @@ -606,7 +622,9 @@ UtilTrinity::stopInternal (int req_id) { /** @brief get profile information from NPU */ int UtilTrinity::getProfile (int req_id, npu_profile *profile) { - return getNPU_profile (dev_, req_id, profile); + npu_profile_opt opt = {.level = prof_level_}; + + return getNPU_profile_opt (dev_, req_id, opt, profile); } /** @brief configure constraint for the model */ diff --git a/tests/utils/ne_test_utils.h b/tests/utils/ne_test_utils.h index 98bed60..eda61e2 100644 --- a/tests/utils/ne_test_utils.h +++ b/tests/utils/ne_test_utils.h @@ -99,6 +99,7 @@ class UtilTrinity { void setMute (); void setNotiMode (const std::string mode); void setNodePath (const std::string node); + void setProfLevel (const std::string level); int init (uint32_t tops = default_tops); void clear (); @@ -130,6 +131,7 @@ class UtilTrinity { npudev_h dev_; std::vector> models_; npu_notimode noti_mode_; + profile_level_type prof_level_; bool need_model_; bool mute_; -- 2.7.4