Skip to content

Commit

Permalink
[Backend] Refactoring RKNPU2 Backend code (PaddlePaddle#1772)
Browse files Browse the repository at this point in the history
* update rknpu2 runtime

* update rknpu2 runtime

* update rknpu2 runtime

* update for rknpu2 backend

* update for rknpu2 backend

---------

Co-authored-by: DefTruth <[email protected]>
  • Loading branch information
Zheng-Bicheng and DefTruth authored Apr 13, 2023
1 parent 60a44f5 commit b30f62a
Show file tree
Hide file tree
Showing 4 changed files with 422 additions and 231 deletions.
2 changes: 1 addition & 1 deletion docs/cn/build_and_install/rknpu2.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ cd FastDeploy
git checkout develop

mkdir build && cd build
cmake .. -DENABLE_ORT_BACKEND=ON \
cmake .. -DENABLE_ORT_BACKEND=OFF \
-DENABLE_RKNPU2_BACKEND=ON \
-DENABLE_VISION=ON \
-DRKNN2_TARGET_SOC=RK3588 \
Expand Down
34 changes: 15 additions & 19 deletions fastdeploy/runtime/backends/rknpu2/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,28 @@ typedef enum _rknpu2_cpu_name {
UNDEFINED,
} CpuName;

/*! RKNPU2 core mask for mobile device. */
/* The specification of NPU core setting.It has the following choices :
* RKNN_NPU_CORE_AUTO : Referring to automatic mode, meaning that it will
* select the idle core inside the NPU.
* RKNN_NPU_CORE_0 : Running on the NPU0 core.
* RKNN_NPU_CORE_1: Runing on the NPU1 core.
* RKNN_NPU_CORE_2: Runing on the NPU2 core.
* RKNN_NPU_CORE_0_1: Running on both NPU0 and NPU1 core simultaneously.
* RKNN_NPU_CORE_0_1_2: Running on both NPU0, NPU1 and NPU2 simultaneously.
*/
typedef enum _rknpu2_core_mask {
RKNN_NPU_CORE_AUTO = 0, //< default, run on NPU core randomly.
RKNN_NPU_CORE_0 = 1, //< run on NPU core 0.
RKNN_NPU_CORE_1 = 2, //< run on NPU core 1.
RKNN_NPU_CORE_2 = 4, //< run on NPU core 2.
RKNN_NPU_CORE_0_1 =
RKNN_NPU_CORE_0 | RKNN_NPU_CORE_1, //< run on NPU core 1 and core 2.
RKNN_NPU_CORE_0_1_2 =
RKNN_NPU_CORE_0_1 | RKNN_NPU_CORE_2, //< run on NPU core 1 and core 2.
RKNN_NPU_CORE_AUTO = 0,
RKNN_NPU_CORE_0 = 1,
RKNN_NPU_CORE_1 = 2,
RKNN_NPU_CORE_2 = 4,
RKNN_NPU_CORE_0_1 = RKNN_NPU_CORE_0 | RKNN_NPU_CORE_1,
RKNN_NPU_CORE_0_1_2 = RKNN_NPU_CORE_0_1 | RKNN_NPU_CORE_2,
RKNN_NPU_CORE_UNDEFINED,
} CoreMask;
} // namespace rknpu2

struct RKNPU2BackendOption {
rknpu2::CpuName cpu_name = rknpu2::CpuName::RK3588;

// The specification of NPU core setting.It has the following choices :
// RKNN_NPU_CORE_AUTO : Referring to automatic mode, meaning that it will
// select the idle core inside the NPU.
// RKNN_NPU_CORE_0 : Running on the NPU0 core
// RKNN_NPU_CORE_1: Runing on the NPU1 core
// RKNN_NPU_CORE_2: Runing on the NPU2 core
// RKNN_NPU_CORE_0_1: Running on both NPU0 and NPU1 core simultaneously.
// RKNN_NPU_CORE_0_1_2: Running on both NPU0, NPU1 and NPU2 simultaneously.
rknpu2::CoreMask core_mask = rknpu2::CoreMask::RKNN_NPU_CORE_AUTO;
};

} // namespace fastdeploy
Loading

0 comments on commit b30f62a

Please sign in to comment.