if ne_test_utils_gtest_dep.found()
testenv_23 = environment()
testenv_23.set('LD_LIBRARY_PATH', ne_libdir)
- testenv_23.set('NPU_VER', '2.3')
+ testenv_23.set('NPU_VER', '2.3.8')
testenv_24 = environment()
testenv_24.set('LD_LIBRARY_PATH', ne_libdir)
- testenv_24.set('NPU_VER', '2.4')
+ testenv_24.set('NPU_VER', '2.4.4')
unittest_ne_core_utils = executable('unittest_ne_core_utils',
['ne_core_utils_test.cc'],
#include <unistd.h>
#include <errno.h>
#include <string.h>
+#include <sstream>
#include <dirent.h>
#include <sys/stat.h>
#define ALIGN_SIZE 4096
#define TO_ALIGN_SIZE(size) (((size - 1) / ALIGN_SIZE + 1) * ALIGN_SIZE)
+#define DEFAULT_NPU_VERSION "2.4.4"
+
/** @brief fill program data for testing */
static void
fill_program (void *buf, size_t size) {
return -ENOMEM;
}
- /* default NPU version for testing is 2.4.2 */
- if (npu_ver == NULL || strcmp (npu_ver, "2.4") == 0) {
- devices_[0] = NPUCOND_TRIV24_CONN_UNKNOWN;
- devices_[1] = NPUCOND_TRIV24_CONN_SOCIP;
- version_ = 0x04030402;
- model_ = "/testdata/TRIV243/CONV_2D_000";
- tops_ = 4;
- } else if (strcmp (npu_ver, "2.3") == 0) {
+ /* set default npu version */
+ if (npu_ver == NULL)
+ npu_ver = DEFAULT_NPU_VERSION;
+
+ /* parse npu version */
+ std::string ver (npu_ver);
+ std::string major, minor, extra;
+ std::stringstream ss (ver);
+
+ std::getline (ss, major, '.');
+ std::getline (ss, minor, '.');
+ std::getline (ss, extra, '.');
+
+ if (major.empty ())
+ major = "2";
+ if (minor.empty ())
+ minor = "4";
+ if (extra.empty ())
+ extra = "4";
+
+ if (major == "2" && minor == "3") {
devices_[0] = NPUCOND_TRIV23_CONN_UNKNOWN;
devices_[1] = NPUCOND_TRIV23_CONN_SOCIP;
- version_ = 0x02080302;
- model_ = "/testdata/TRIV238_2TOPS/CONV_2D_000";
tops_ = 2;
+ } else if (major == "2" && minor == "4") {
+ devices_[0] = NPUCOND_TRIV24_CONN_UNKNOWN;
+ devices_[1] = NPUCOND_TRIV24_CONN_SOCIP;
+ tops_ = 4;
} else {
std::cerr << "Incompatible environmental variable npu version : " << npu_ver << "\n";
return -EINVAL;
}
+ model_ = std::string ("/testdata/TRIV") + major + minor + extra + "/CONV_2D_000";
+ version_ = 0;
+ version_ |= std::stoi (major);
+ version_ |= std::stoi (minor) << 8;
+ version_ |= std::stoi (extra) << 16;
+ version_ |= tops_ << 24;
+
return 0;
}