From: yelini-jeong Date: Thu, 25 Nov 2021 05:49:26 +0000 (+0900) Subject: [Misc] add comments X-Git-Tag: submit/tizen/20220103.094045~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf7849108bcc068bdebd2e97da271971c8caf668;p=platform%2Fadaptation%2Fnpu%2Ftrix-engine.git [Misc] add comments This patch adds comments to handler and scheduler Signed-off-by: yelini-jeong --- diff --git a/src/core/ne-handler.cc b/src/core/ne-handler.cc index 1c6183a..ef03854 100644 --- a/src/core/ne-handler.cc +++ b/src/core/ne-handler.cc @@ -97,7 +97,7 @@ HostHandler::unregisterModel (uint32_t modelid) { /** * @brief remove all registered models - * @return 0 + * @return 0 if device can unset model. otherwise return 1 */ int HostHandler::unregisterModels () { @@ -398,7 +398,6 @@ HostHandler::setRequestMode (int req_id, npu_infer_mode mode) { /** * @brief Set the request's constraint - * @param[in] dev The NPU device handle * @param[in] req_id The request ID * @param[in] constraint inference constraint (e.g., timeout, priority) * @return 0 if no error. Otherwise a negative errno @@ -1079,7 +1078,7 @@ TrinityVision2::unsetModel (Model *model) { /** * @brief Get tensor size that the target model assumes - * @param[in] model_id The target model id + * @param[in] model the model instance * @param[in] input true if it's input tensor * @param[in] index tensor index * @param[out] size tensor size @@ -1099,7 +1098,15 @@ TrinityVision2::getTensorSize (const Model *model, bool input, uint32_t index, u return 0; } -/** @brief implementation of TRIV2's run() */ +/** + * @brief implementation of TRIV2's run() + * @param[in] opmode the opmode of the request + * @param[in] model the model instance + * @param[in] input the input data buffers + * @param[in] output the output data buffers + * @param[in] cb the output callback handler + * @param[out] cb_data the inferecne data of the request + */ int TrinityVision2::run (npu_input_opmode opmode, const Model *model, const input_buffers *input, output_buffers *output, npuOutputNotify cb, void *cb_data) { @@ -1227,6 +1234,12 @@ TrinityVision2::callback (Request *req, npuOutputNotify cb, void *cb_data) { cb (output, req->getID (), cb_data); } +/** + * @brief Create NPU inferance request + * @param[in] model the model instance + * @param[out] req_id the request id + * @return 0 if no error, otherwise a negative errno + */ int TrinityVision2::createRequest (const Model *model, int *req_id) { Request *req; @@ -1250,6 +1263,11 @@ TrinityVision2::createRequest (const Model *model, int *req_id) { return 0; } +/** + * @brief Remove the request instance + * @param[in] req_id The request's ID + * @return 0 if no error. Otherwise a negative errno + */ int TrinityVision2::removeRequest (int req_id) { Request *req = scheduler_->findRequest (req_id); @@ -1268,6 +1286,12 @@ TrinityVision2::removeRequest (int req_id) { return 0; } +/** + * @brief Get the request's model id + * @param[in] req_id The request's ID + * @param[out] model_id The request's model ID + * @return 0 if no error. Otherwise a negative errno + */ int TrinityVision2::getRequestModel (int req_id, uint32_t *model_id) { if (model_id == nullptr) { @@ -1289,6 +1313,15 @@ TrinityVision2::getRequestModel (int req_id, uint32_t *model_id) { return 0; } +/** + * @brief Set request's input/output data + * @param[in] req_id The request ID + * @param[in] input The input data buffers + * @param[in] in_info The input data info (format, type) + * @param[in] output The output data buffers + * @param[in] out_info The output data info (format, type) + * @return 0 if no error. Otherwise a negative errno + */ int TrinityVision2::setRequestData (int req_id, input_buffers *input, tensors_data_info *in_info, output_buffers *output, tensors_data_info *out_info) { @@ -1342,6 +1375,13 @@ TrinityVision2::setRequestData (int req_id, input_buffers *input, tensors_data_i return 0; } +/** + * @brief Set output callback of the request + * @param[in] req_id The request ID + * @param[in] cb The output callback handler + * @param[in] [nullable] data The data to pass to callback handler + * @return 0 if no error. Otherwise a negative errno + */ int TrinityVision2::setRequestCallback (int req_id, npuOutputNotify cb, void *data) { Request *req = scheduler_->findRequest (req_id); @@ -1355,6 +1395,12 @@ TrinityVision2::setRequestCallback (int req_id, npuOutputNotify cb, void *data) return 0; } +/** + * @brief Set the request's inference mode + * @param[in] req_id The request ID + * @param[in] mode Configures how this inference works. + * @return 0 if no error. Otherwise a negative errno + */ int TrinityVision2::setRequestMode (int req_id, npu_infer_mode mode) { Request *req = scheduler_->findRequest (req_id); @@ -1368,6 +1414,12 @@ TrinityVision2::setRequestMode (int req_id, npu_infer_mode mode) { return 0; } +/** + * @brief Set the request's constraint + * @param[in] req_id The request ID + * @param[in] constraint inference constraint (e.g., timeout, priority) + * @return 0 if no error. Otherwise a negative errno + */ int TrinityVision2::setRequestConstraint (int req_id, npu_constraint constraint) { Request *req = scheduler_->findRequest (req_id); @@ -1386,6 +1438,13 @@ TrinityVision2::setRequestConstraint (int req_id, npu_constraint constraint) { return 0; } +/** + * @brief Set the request's scheduler + * @param[in] req_id The request ID + * @param[in] sched npu scheduler + * @param[in] sched_param npu scheduler param + * @return 0 if no error. Otherwise a negative errno + */ int TrinityVision2::setRequestScheduler (int req_id, npu_scheduler sched, npu_scheduler_param sched_param) { @@ -1400,6 +1459,11 @@ TrinityVision2::setRequestScheduler (int req_id, npu_scheduler sched, return 0; } +/** + * @brief Submit the request to the NPU + * @param[in] req_id The request ID + * @return 0 if no error. Otherwise a negative errno + */ int TrinityVision2::submitRequest (int req_id) { Request *req = scheduler_->findRequest (req_id); @@ -1450,6 +1514,11 @@ TrinityVision2::submitRequest (int req_id) { return status; } +/** + * @brief Submit the request to the NPU working with kernel modules + * @param[in] req_id The request ID + * @return 0 if no error. Otherwise a negative errno + */ int TrinityVision2::submitRequestKernel (int req_id) { Request *req = scheduler_->findRequest (req_id); diff --git a/src/core/ne-scheduler.cc b/src/core/ne-scheduler.cc index 1eb25ce..0d83688 100644 --- a/src/core/ne-scheduler.cc +++ b/src/core/ne-scheduler.cc @@ -151,6 +151,7 @@ Scheduler::submitRequest (Request *req) { /** * @brief handle request callback + * @param[in] req the request instance */ void Scheduler::handleCallback (Request *req) { @@ -173,6 +174,7 @@ Scheduler::handleCallback (Request *req) { /** * @brief find request using id + * @param[in] req_id the request id * @return the target request if exists. Otherwise nullptr */ Request *