未验证 提交 37bdb526 编写于 作者: S silingtong123 提交者: GitHub

test=develop, add log message in the function UpdateDllFlag (#24937)

* test=develop, add log message in the function UpdateDllFlag

* test=develop, add the test
上级 d152d723
......@@ -120,12 +120,19 @@ std::string get_version() {
return ss.str();
}
#if defined(_WIN32) && defined(PADDLE_ON_INFERENCE)
std::string UpdateDllFlag(const char *name, const char *value) {
return google::SetCommandLineOption(name, value);
std::string ret;
LOG(WARNING)
<< "The function \"UpdateDllFlag\" is only used to update the flag "
"on the Windows shared library";
ret = google::SetCommandLineOption(name, value);
PADDLE_ENFORCE_EQ(
ret.empty(), false,
platform::errors::InvalidArgument(
"Fail to update flag: %s, please make sure the flag exists.", name));
LOG(INFO) << ret;
return ret;
}
#endif
} // namespace paddle
......@@ -14,6 +14,7 @@ limitations under the License. */
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <exception>
#include "paddle/fluid/inference/api/paddle_inference_api.h"
namespace paddle {
......@@ -67,4 +68,12 @@ TEST(paddle_inference_api, get_version) {
ASSERT_FALSE(version.empty());
}
TEST(paddle_inference_api, UpdateDllFlag) {
UpdateDllFlag("paddle_num_threads", "10");
try {
UpdateDllFlag("paddle_num_threads2", "10");
} catch (std::exception &e) {
LOG(INFO) << e.what();
}
}
} // namespace paddle
......@@ -429,8 +429,6 @@ PD_INFER_DECL int PaddleDtypeSize(PaddleDType dtype);
PD_INFER_DECL std::string get_version();
#if defined(_WIN32) && defined(PADDLE_ON_INFERENCE)
PD_INFER_DECL std::string UpdateDllFlag(const char* name, const char* value);
#endif
} // namespace paddle
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册