Skip to content

Commit

Permalink
Add delete pass, disable_trt_ops and enable_fixed_size_opt for serving
Browse files Browse the repository at this point in the history
  • Loading branch information
joey12300 committed Mar 9, 2023
1 parent ad14d0e commit f88b06a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
12 changes: 12 additions & 0 deletions serving/src/fastdeploy_backend_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@ TRITONSERVER_Error* FDParseShape(triton::common::TritonJson::Value& io,
return nullptr; // success
}

int SplitStringByDelimiter(const std::string& s, char delimiter,
std::vector<std::string>* results) {
std::string token;
std::istringstream token_stream(s);
int number_of_tokens = 0;
while (std::getline(token_stream, token, delimiter)) {
results->push_back(token);
number_of_tokens += 1;
}
return number_of_tokens;
}

} // namespace fastdeploy_runtime
} // namespace backend
} // namespace triton
4 changes: 4 additions & 0 deletions serving/src/fastdeploy_backend_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ TRITONSERVER_Error* FDParseShape(triton::common::TritonJson::Value& io,
const std::string& name,
std::vector<int32_t>* shape);

int SplitStringByDelimiter(const std::string& s,
char delimiter,
std::vector<std::string>* results);

} // namespace fastdeploy_runtime
} // namespace backend
} // namespace triton
23 changes: 21 additions & 2 deletions serving/src/fastdeploy_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ ModelState::ModelState(TRITONBACKEND_Model* triton_model)
bool use_paddle_log;
THROW_IF_BACKEND_MODEL_ERROR(
ParseBoolValue(value_string, &use_paddle_log));
runtime_options_->paddle_infer_option.enable_log_info = use_paddle_log;
runtime_options_->paddle_infer_option.enable_log_info =
use_paddle_log;
} else if (param_key == "num_streams") {
int num_streams;
THROW_IF_BACKEND_MODEL_ERROR(
Expand Down Expand Up @@ -320,12 +321,30 @@ ModelState::ModelState(TRITONBACKEND_Model* triton_model)
bool use_paddle_log;
THROW_IF_BACKEND_MODEL_ERROR(
ParseBoolValue(value_string, &use_paddle_log));
runtime_options_->paddle_infer_option.enable_log_info = use_paddle_log;
runtime_options_->paddle_infer_option.enable_log_info =
use_paddle_log;
} else if (param_key == "is_clone") {
THROW_IF_BACKEND_MODEL_ERROR(
ParseBoolValue(value_string, &is_clone_));
} else if (param_key == "encryption_key") {
runtime_options_->SetEncryptionKey(value_string);
} else if (param_key == "disable_trt_ops") {
std::vector<std::string> disable_trt_ops;
SplitStringByDelimiter(value_string, ' ', &disable_trt_ops);
runtime_options_->paddle_infer_option.DisablePaddleTrtOPs(
disable_trt_ops);
} else if (param_key == "delete_passes") {
std::vector<std::string> delete_passes;
SplitStringByDelimiter(value_string, ' ', &disable_trt_ops);
for (auto&& pass : delete_passes) {
runtime_options_->paddle_infer_option.DeletePass(pass);
}
} else if (param_key == "enable_fixed_size_opt") {
bool enable_fixed_size_opt = false;
THROW_IF_BACKEND_MODEL_ERROR(
ParseBoolValue(value_string, &enable_fixed_size_opt));
runtime_options_->paddle_infer_option.enable_fixed_size_opt =
enable_fixed_size_opt;
}
}
}
Expand Down

0 comments on commit f88b06a

Please sign in to comment.