int unregisterNPUmodel_all (npudev_h dev);
/**
+ * @brief Get tensor size that the target model assumes
+ * @param[in] dev The NPU device handle
+ * @param[in] model_id The target model id
+ * @param[in] input true if it's input tensor
+ * @param[in] index tensor index
+ * @param[out] size tensor size
+ * @return 0 if no error. otherwise a negative error value
+ */
+int getNPUmodel_tensorSize (npudev_h dev, uint32_t model_id, bool input,
+ uint32_t index, uint32_t *size);
+
+/**
* @brief [OPTIONAL] Set the data layout for input/output tensors
* @param[in] dev The NPU device handle
* @param[in] model_id The ID of model whose layouts are set
}
/**
+ * @brief Get tensor size that the target model assumes
+ * @param[in] model_id The target model id
+ * @param[in] input true if it's input tensor
+ * @param[in] index tensor index
+ * @param[out] size tensor size
+ * @return 0 if no error. otherwise a negative error value
+ */
+int
+HostHandler::getTensorSize (uint32_t modelid, bool input, uint32_t index,
+ uint32_t *size) {
+ Model *model = models_.find (modelid);
+ if (model == nullptr)
+ return -ENOENT;
+
+ return device_->getTensorSize (model, input, index, size);
+}
+
+/**
* @brief Get the profile information from NPU
* @param[in] req_id The identifier for each inference
* @param[in] opt Profile options
return 0;
}
+/**
+ * @brief Get tensor size that the target model assumes
+ * @param[in] model_id The target model id
+ * @param[in] input true if it's input tensor
+ * @param[in] index tensor index
+ * @param[out] size tensor size
+ * @return 0 if no error. otherwise a negative error value
+ */
+int
+TrinityVision2::getTensorSize (const Model *model, bool input, uint32_t index,
+ uint32_t *size) {
+ const Metadata *meta = model->getMetadata ();
+ if (meta == nullptr)
+ return -EINVAL;
+
+ if (input)
+ *size = meta->getInputTensorSize (index, DATA_LAYOUT_TRIV2);
+ else
+ *size = meta->getOutputTensorSize (index, DATA_LAYOUT_TRIV2);
+
+ return 0;
+}
+
/** @brief implementation of TRIV2's run() */
int
TrinityVision2::run (npu_input_opmode opmode, const Model *model,
int unregisterModel (uint32_t modelid);
int unregisterModels ();
+ int getTensorSize (uint32_t modelid, bool input, uint32_t index,
+ uint32_t *size);
+
int getProfile (int req_id, const npu_profile_opt &opt, npu_profile *profile);
int getAPILevel (uint32_t *level);
int getTops (uint32_t *tops);
}
virtual int unsetModel (Model *model) { return -EPERM; }
+ virtual int getTensorSize (const Model *model, bool input, uint32_t index,
+ uint32_t *size) {
+ return -EPERM;
+ }
+
virtual int run (npu_input_opmode opmode, const Model *model,
const input_buffers *input, npuOutputNotify cb = nullptr,
void *cb_data = nullptr, uint64_t *sequence = nullptr) = 0;
int setModel (const generic_buffer *model, Model **model_ptr);
int unsetModel (Model *model);
+
+ int getTensorSize (const Model *model, bool input, uint32_t index,
+ uint32_t *size);
+
int run (npu_input_opmode opmode, const Model *model,
const input_buffers *input, npuOutputNotify cb = nullptr,
void *cb_data = nullptr, uint64_t *sequence = nullptr);
}
/**
+ * @brief Get tensor size that the target model assumes
+ * @param[in] dev The NPU device handle
+ * @param[in] model_id The target model id
+ * @param[in] input true if it's input tensor
+ * @param[in] index tensor index
+ * @param[out] size tensor size
+ * @return 0 if no error. otherwise a negative error value
+ */
+int
+getNPUmodel_tensorSize (npudev_h dev, uint32_t model_id, bool input,
+ uint32_t index, uint32_t *size) {
+ INIT_HOST_HANDLER (host_handler, dev);
+
+ return host_handler->getTensorSize (model_id, input, index, size);
+}
+
+/**
* @brief [OPTIONAL] Set the data layout for input/output tensors
* @param[in] dev The NPU device handle
* @param[in] modelid The ID of model whose layouts are set