16 #include "fastdeploy/runtime/backends/backend.h" 17 #include "fastdeploy/runtime/backends/rknpu2/option.h" 18 #include "fastdeploy/core/fd_tensor.h" 27 class RKNPU2Backend :
public BaseBackend {
29 RKNPU2Backend() =
default;
31 virtual ~RKNPU2Backend();
33 bool Init(
const RuntimeOption& runtime_option);
35 int NumInputs()
const override {
36 return static_cast<int>(inputs_desc_.size());
39 int NumOutputs()
const override {
40 return static_cast<int>(outputs_desc_.size());
43 TensorInfo GetInputInfo(
int index)
override;
44 TensorInfo GetOutputInfo(
int index)
override;
45 std::vector<TensorInfo> GetInputInfos()
override;
46 std::vector<TensorInfo> GetOutputInfos()
override;
47 bool Infer(std::vector<FDTensor>& inputs, std::vector<FDTensor>* outputs,
48 bool copy_to_fd =
true)
override;
52 void BuildOption(
const RKNPU2BackendOption& option);
55 bool LoadModel(
void* model);
57 bool GetSDKAndDeviceVersion();
59 bool SetCoreMask(
const rknpu2::CoreMask& core_mask)
const;
61 bool GetModelInputOutputInfos();
67 rknn_sdk_version sdk_ver{};
70 rknn_input_output_num io_num{};
71 std::vector<TensorInfo> inputs_desc_;
72 std::vector<TensorInfo> outputs_desc_;
74 rknn_tensor_attr* input_attrs_ =
nullptr;
75 rknn_tensor_attr* output_attrs_ =
nullptr;
77 rknn_tensor_mem** input_mems_;
78 rknn_tensor_mem** output_mems_;
80 bool infer_init =
false;
82 RKNPU2BackendOption option_;
84 static void DumpTensorAttr(rknn_tensor_attr& attr);
85 static FDDataType RknnTensorTypeToFDDataType(rknn_tensor_type type);
86 static rknn_tensor_type FDDataTypeToRknnTensorType(FDDataType type);
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16