未验证 提交 3066636d 编写于 作者: J Jason 提交者: GitHub

Merge pull request #189 from joey12300/develop

add use_ir_optim cmd args
......@@ -37,6 +37,7 @@ DEFINE_int32(batch_size, 1, "Batch size of infering");
DEFINE_int32(thread_num,
omp_get_num_procs(),
"Number of preprocessing threads");
DEFINE_bool(use_ir_optim, true, "use ir optimization");
int main(int argc, char** argv) {
// Parsing command-line
......@@ -57,7 +58,8 @@ int main(int argc, char** argv) {
FLAGS_use_gpu,
FLAGS_use_trt,
FLAGS_gpu_id,
FLAGS_key);
FLAGS_key,
FLAGS_use_ir_optim);
// 进行预测
double total_running_time_s = 0.0;
......
......@@ -43,6 +43,7 @@ DEFINE_double(threshold,
DEFINE_int32(thread_num,
omp_get_num_procs(),
"Number of preprocessing threads");
DEFINE_bool(use_ir_optim, true, "use ir optimization");
int main(int argc, char** argv) {
// 解析命令行参数
......@@ -62,7 +63,8 @@ int main(int argc, char** argv) {
FLAGS_use_gpu,
FLAGS_use_trt,
FLAGS_gpu_id,
FLAGS_key);
FLAGS_key,
FLAGS_use_ir_optim);
double total_running_time_s = 0.0;
double total_imread_time_s = 0.0;
......
......@@ -39,6 +39,7 @@ DEFINE_int32(batch_size, 1, "Batch size of infering");
DEFINE_int32(thread_num,
omp_get_num_procs(),
"Number of preprocessing threads");
DEFINE_bool(use_ir_optim, false, "use ir optimization");
int main(int argc, char** argv) {
// 解析命令行参数
......@@ -59,7 +60,8 @@ int main(int argc, char** argv) {
FLAGS_use_gpu,
FLAGS_use_trt,
FLAGS_gpu_id,
FLAGS_key);
FLAGS_key,
FLAGS_use_ir_optim);
double total_running_time_s = 0.0;
double total_imread_time_s = 0.0;
......
......@@ -72,20 +72,23 @@ class Model {
* @param use_trt: use Tensor RT or not when infering
* @param gpu_id: the id of gpu when infering with using gpu
* @param key: the key of encryption when using encrypted model
* @param use_ir_optim: use ir optimization when infering
* */
void Init(const std::string& model_dir,
bool use_gpu = false,
bool use_trt = false,
int gpu_id = 0,
std::string key = "") {
create_predictor(model_dir, use_gpu, use_trt, gpu_id, key);
std::string key = "",
bool use_ir_optim = true) {
create_predictor(model_dir, use_gpu, use_trt, gpu_id, key, use_ir_optim);
}
void create_predictor(const std::string& model_dir,
bool use_gpu = false,
bool use_trt = false,
int gpu_id = 0,
std::string key = "");
std::string key = "",
bool use_ir_optim = true);
/*
* @brief
......
......@@ -22,9 +22,14 @@
#include <io.h>
#else // Linux/Unix
#include <dirent.h>
#include <sys/io.h>
// #include <sys/io.h>
#ifdef __arm__ // for arm
#include <aarch64-linux-gpu/sys/stat.h>
#include <aarch64-linux-gpu/sys/types.h>
#else
#include <sys/stat.h>
#include <sys/types.h>
#endif
#include <unistd.h>
#endif
#include <string>
......
......@@ -22,7 +22,8 @@ void Model::create_predictor(const std::string& model_dir,
bool use_gpu,
bool use_trt,
int gpu_id,
std::string key) {
std::string key,
bool use_ir_optim) {
paddle::AnalysisConfig config;
std::string model_file = model_dir + OS_PATH_SEP + "__model__";
std::string params_file = model_dir + OS_PATH_SEP + "__params__";
......@@ -63,6 +64,8 @@ void Model::create_predictor(const std::string& model_dir,
}
config.SwitchUseFeedFetchOps(false);
config.SwitchSpecifyInputNames(true);
// 开启图优化
config.SwitchIrOptim(use_ir_optim);
// 开启内存优化
config.EnableMemoryOptim();
if (use_trt) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册