mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-27 10:30:34 +08:00
[Backend] Add Rockchip RV1126 deploy support through PaddleLite TIM-VX (#439)
* add rk1126 support * update lib * fix compile bugs * update doc * fix complie bug * update doc * update doc * update code * support model bigger than 2G * update code * update code * update code * update doc * update code * fix bug * update code * update code * update code * update doc * update info * code style check * update code * update doc Co-authored-by: Jason <jiangjiajun@baidu.com>
This commit is contained in:
42
fastdeploy/backends/lite/lite_backend.cc
Normal file → Executable file
42
fastdeploy/backends/lite/lite_backend.cc
Normal file → Executable file
@@ -63,6 +63,24 @@ void LiteBackend::BuildOption(const LiteBackendOption& option) {
|
||||
FDWARNING << "This device is not supported fp16, will skip fp16 option.";
|
||||
}
|
||||
}
|
||||
if (!option_.nnadapter_subgraph_partition_config_path.empty()) {
|
||||
std::vector<char> nnadapter_subgraph_partition_config_buffer;
|
||||
if (ReadFile(option_.nnadapter_subgraph_partition_config_path, &nnadapter_subgraph_partition_config_buffer, false)) {
|
||||
if (!nnadapter_subgraph_partition_config_buffer.empty()) {
|
||||
std::string nnadapter_subgraph_partition_config_string(nnadapter_subgraph_partition_config_buffer.data(), nnadapter_subgraph_partition_config_buffer.size());
|
||||
config_.set_nnadapter_subgraph_partition_config_buffer(nnadapter_subgraph_partition_config_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(option_.enable_timvx){
|
||||
config_.set_nnadapter_device_names({"verisilicon_timvx"});
|
||||
valid_places.push_back(
|
||||
paddle::lite_api::Place{TARGET(kNNAdapter), PRECISION(kInt8)});
|
||||
valid_places.push_back(
|
||||
paddle::lite_api::Place{TARGET(kNNAdapter), PRECISION(kFloat)});
|
||||
valid_places.push_back(
|
||||
paddle::lite_api::Place{TARGET(kARM), PRECISION(kInt8)});
|
||||
}
|
||||
valid_places.push_back(
|
||||
paddle::lite_api::Place{TARGET(kARM), PRECISION(kFloat)});
|
||||
config_.set_valid_places(valid_places);
|
||||
@@ -75,6 +93,30 @@ void LiteBackend::BuildOption(const LiteBackendOption& option) {
|
||||
}
|
||||
}
|
||||
|
||||
bool LiteBackend::ReadFile(const std::string& filename,
|
||||
std::vector<char>* contents,
|
||||
const bool binary) {
|
||||
FILE *fp = fopen(filename.c_str(), binary ? "rb" : "r");
|
||||
if (!fp){
|
||||
FDERROR << "Cannot open file " << filename << "." << std::endl;
|
||||
return false;
|
||||
}
|
||||
fseek(fp, 0, SEEK_END);
|
||||
size_t size = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
contents->clear();
|
||||
contents->resize(size);
|
||||
size_t offset = 0;
|
||||
char *ptr = reinterpret_cast<char *>(&(contents->at(0)));
|
||||
while (offset < size) {
|
||||
size_t already_read = fread(ptr, 1, size - offset, fp);
|
||||
offset += already_read;
|
||||
ptr += already_read;
|
||||
}
|
||||
fclose(fp);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LiteBackend::InitFromPaddle(const std::string& model_file,
|
||||
const std::string& params_file,
|
||||
const LiteBackendOption& option) {
|
||||
|
||||
Reference in New Issue
Block a user