return allocNPU_genericBuffers (dev_, output);
#endif
}
+
+UtilTestEnv::UtilTestEnv () {
+ int status = set_info ();
+
+ if (status < 0) {
+ std::cerr << "Failed to create UtilTestEnv instance\n";
+ return;
+ }
+}
+
+UtilTestEnv::~UtilTestEnv () {
+ if (devices_ != NULL)
+ free (devices_);
+}
+
+int
+UtilTestEnv::set_info () {
+ const char *npu_ver = getenv ("NPU_VER");
+
+ if (devices_ != NULL)
+ free (devices_);
+
+ dev_len_ = 2;
+ devices_ = (dev_type *) calloc (dev_len_, sizeof (dev_type));
+
+ if (!devices_) {
+ std::cerr << "Failed to allocate device list\n";
+ return -ENOMEM;
+ }
+
+ /* default NPU version for testing is 2.4 */
+ if (npu_ver == NULL || strcmp (npu_ver, "2.4") == 0) {
+ devices_[0] = NPUCOND_TRIV24_CONN_UNKNOWN;
+ devices_[1] = NPUCOND_TRIV24_CONN_SOCIP;
+ version_ = 0x04000402;
+ model_ = "/testdata/TRIV242/CONV_2D_000";
+ tops_ = 4;
+ } else if (strcmp (npu_ver, "2.3") == 0) {
+ devices_[0] = NPUCOND_TRIV23_CONN_UNKNOWN;
+ devices_[1] = NPUCOND_TRIV23_CONN_SOCIP;
+ version_ = 0x02080302;
+ model_ = "/testdata/TRIV238_2TOPS/CONV_2D_000";
+ tops_ = 2;
+ } else {
+ std::cerr << "Incompatible environmental variable npu version : " << npu_ver << "\n";
+ return -EINVAL;
+ }
+
+ return 0;
+}
class UtilTRIV2 : public UtilTrinity {
public:
UtilTRIV2 () : UtilTrinity (NPUCOND_TRIV24_CONN_SOCIP, true, true) {}
+ UtilTRIV2 (dev_type type) : UtilTrinity (type, true, true) {}
private:
bool check_version (npubin_meta *meta);
bool extract_node_id (uint32_t *id);
};
+class UtilTestEnv {
+ public:
+ UtilTestEnv ();
+ ~UtilTestEnv ();
+ int set_info ();
+ dev_type *get_devices () { return devices_; }
+ int get_dev_len () { return dev_len_; }
+ uint64_t get_version () { return version_; }
+ std::string get_model () { return model_; }
+ uint32_t get_tops () { return tops_; }
+
+ private:
+ dev_type *devices_;
+ int dev_len_;
+ uint64_t version_;
+ std::string model_;
+ uint32_t tops_;
+};
+
extern "C" {
#endif