22 #include "paddle_api.h" 24 #include "fastdeploy/runtime/backends/backend.h" 26 #include "fastdeploy/runtime/backends/lite/option.h" 30 class LiteBackend :
public BaseBackend {
33 virtual ~LiteBackend() =
default;
35 bool Init(
const RuntimeOption& option)
override;
37 bool Infer(std::vector<FDTensor>& inputs,
38 std::vector<FDTensor>* outputs,
39 bool copy_to_fd =
true)
override;
41 int NumInputs()
const override {
return inputs_desc_.size(); }
43 int NumOutputs()
const override {
return outputs_desc_.size(); }
45 TensorInfo GetInputInfo(
int index)
override;
46 TensorInfo GetOutputInfo(
int index)
override;
47 std::vector<TensorInfo> GetInputInfos()
override;
48 std::vector<TensorInfo> GetOutputInfos()
override;
51 void BuildOption(
const LiteBackendOption& option);
53 void ConfigureCpu(
const LiteBackendOption& option);
54 void ConfigureTimvx(
const LiteBackendOption& option);
55 void ConfigureAscend(
const LiteBackendOption& option);
56 void ConfigureKunlunXin(
const LiteBackendOption& option);
57 void ConfigureNNAdapter(
const LiteBackendOption& option);
59 paddle::lite_api::CxxConfig config_;
60 std::shared_ptr<paddle::lite_api::PaddlePredictor> predictor_;
61 std::vector<TensorInfo> inputs_desc_;
62 std::vector<TensorInfo> outputs_desc_;
63 std::map<std::string, int> inputs_order_;
64 LiteBackendOption option_;
68 FDDataType LiteDataTypeToFD(
const paddle::lite_api::PrecisionType& dtype);
71 bool ReadFile(
const std::string& filename,
72 std::vector<char>* contents,
A brief file description. More details.
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16