[Other] Refine Paddle Lite backend (#1202)

* Refine Paddle Lite backend

* fix error

* Fix compile error

* Fix build error

* modify cpu configure

* fix error

* Fix comment

* Fix error
This commit is contained in:
Jason
2023-02-02 17:40:03 +08:00
committed by GitHub
parent 56e4e56abc
commit 3c5824c862
5 changed files with 258 additions and 198 deletions

View File

@@ -19,13 +19,12 @@
#include <string>
#include <vector>
#include "fastdeploy/runtime/backends/backend.h"
#include "fastdeploy/runtime/backends/lite/option.h"
#include "paddle_api.h" // NOLINT
#include "fastdeploy/runtime/backends/backend.h"
#include "fastdeploy/runtime/backends/lite/option.h"
namespace fastdeploy {
// Convert data type from paddle lite to fastdeploy
FDDataType LiteDataTypeToFD(const paddle::lite_api::PrecisionType& dtype);
class LiteBackend : public BaseBackend {
public:
@@ -51,15 +50,26 @@ class LiteBackend : public BaseBackend {
std::vector<TensorInfo> GetOutputInfos() override;
private:
void ConfigureCpu(const LiteBackendOption& option);
void ConfigureTimvx(const LiteBackendOption& option);
void ConfigureAscend(const LiteBackendOption& option);
void ConfigureKunlunXin(const LiteBackendOption& option);
void ConfigureNNAdapter(const LiteBackendOption& option);
paddle::lite_api::CxxConfig config_;
std::shared_ptr<paddle::lite_api::PaddlePredictor> predictor_;
std::vector<TensorInfo> inputs_desc_;
std::vector<TensorInfo> outputs_desc_;
std::map<std::string, int> inputs_order_;
LiteBackendOption option_;
bool supported_fp16_ = false;
bool ReadFile(const std::string& filename,
std::vector<char>* contents,
const bool binary = true);
};
// Convert data type from paddle lite to fastdeploy
FDDataType LiteDataTypeToFD(const paddle::lite_api::PrecisionType& dtype);
// Helper function to read file
bool ReadFile(const std::string& filename,
std::vector<char>* contents,
bool binary = true);
} // namespace fastdeploy