This patch applies npu version check logic to both api.
checkVersion is moved to handler from emul API.
Signed-off-by: Yelin Jeong <yelini.jeong@samsung.com>
return 0;
}
+/**
+ * @brief check if npu_version matches dev_type
+ * @param[in] npu_version the npu version of model
+ * @return 0 if no error, otherwise a negative errno
+ */
+int
+TrinityVision2::checkVersion (uint64_t npu_version) const {
+ uint32_t major, minor;
+ bool match = false;
+
+ major = NPU_VERSION_MAJOR (npu_version);
+ minor = NPU_VERSION_MINOR (npu_version);
+
+ if (major == 2) {
+ if (type_ == dev_type::NPUCOND_TRIV2_CONN_UNKNOWN ||
+ type_ == dev_type::NPUCOND_TRIV2_CONN_SOCIP) {
+ match = true;
+ } else if (minor == 3 && (type_ == NPUCOND_TRIV23_CONN_SOCIP ||
+ type_ == NPUCOND_TRIV23_CONN_UNKNOWN)) {
+ match = true;
+ } else if (minor == 4 && (type_ == NPUCOND_TRIV24_CONN_SOCIP ||
+ type_ == NPUCOND_TRIV24_CONN_UNKNOWN)) {
+ match = true;
+ }
+ }
+
+ if (!match) {
+ logerr (TAG, "npu version(0x%llx), dev_type(0x%x)", npu_version, type_);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
/**
* @brief implementation of TRIV2's setModel ()
* @param[in] model_buf the model generic buffer
if (status != 0)
goto delete_exit;
+ status = checkVersion (model->getMetadata ()->getNPUVersion ());
+ if (status != 0)
+ goto delete_exit;
+
/** allocate program (optional; NOP) */
if (model->getMetadata ()->getProgramSize () > 0) {
HWmem *hwmem_prog = new HWmem (new HWmemDevice);
int getTensorSize (const Model *model, bool input, uint32_t index, uint32_t *size);
int checkDspmSize (const Model *model);
+ int checkVersion (uint64_t npu_version) const;
int run (npu_input_opmode opmode, const Model *model, const input_buffers *input,
output_buffers *output = nullptr, npuOutputNotify cb = nullptr, void *cb_data = nullptr);
int getProfile (int req_id, npu_profile *profile, const std::string path = "") const;
void manipulateProfile (EmulReq *req, npu_profile *profile) const;
- int checkVersion (uint64_t npu_version) const;
private:
static std::atomic<int> global_fd_;
return 0;
}
-int
-TrinityEmulAPI::checkVersion (uint64_t npu_version) const {
- uint32_t major, minor;
- bool match = false;
-
- major = NPU_VERSION_MAJOR (npu_version);
- minor = NPU_VERSION_MINOR (npu_version);
-
- if (major == 2) {
- if (dev_type_ == dev_type::NPUCOND_TRIV2_CONN_UNKNOWN ||
- dev_type_ == dev_type::NPUCOND_TRIV2_CONN_SOCIP) {
- match = true;
- } else if (minor == 3 && (dev_type_ == NPUCOND_TRIV23_CONN_SOCIP ||
- dev_type_ == NPUCOND_TRIV23_CONN_UNKNOWN)) {
- match = true;
- } else if (minor == 4 && (dev_type_ == NPUCOND_TRIV24_CONN_SOCIP ||
- dev_type_ == NPUCOND_TRIV24_CONN_UNKNOWN)) {
- match = true;
- }
- }
-
- if (!match) {
- logerr (TAG, "npu version(0x%lx), dev_type(0x%x)", npu_version, dev_type_);
- return -1;
- }
-
- return 0;
-}
-
/**
* @brief register model config to the driver
* @param[in] model_config model configuration to be registered
if (model_config == nullptr || model_config->dbuf_fd < 0)
return -EINVAL;
- if (checkVersion (model_config->npu_version)) {
- logerr (TAG, "model npu version is not matched to device");
- return -EINVAL;
- }
-
EmulElement *elem = elem_map_.find (model_config->dbuf_fd);
if (elem == nullptr)
return -ENOENT;
meta.output_seg_dims[0][2] = 64;
meta.output_seg_dims[0][3] = 64;
+ meta.npu_version = testenv.get_version ();
+
model_buf.type = BUFFER_MAPPED;
model_buf.size = meta.size;
model_buf.addr = new char[meta.size];