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

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

* test=develop, add the test
revert-24981-add_device_attr_for_regulization
silingtong123 5 years ago committed by GitHub
parent d152d7231e
commit 37bdb5269f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

Loading…
Cancel
Save