mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 00:57:33 +08:00
[Other] Enable to hidden INFO/WARNING log informations (#1368)
* Enable to hidden INFO/WARNING log informations * Fix build error --------- Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>
This commit is contained in:
@@ -26,7 +26,8 @@ namespace function {
|
||||
@param out The output tensor which stores the result.
|
||||
@param axis Axis which will be gathered.
|
||||
*/
|
||||
void GatherAlongAxis(const FDTensor& x, const FDTensor& index, FDTensor* result,
|
||||
FASTDEPLOY_DECL void GatherAlongAxis(const FDTensor& x,
|
||||
const FDTensor& index, FDTensor* result,
|
||||
int axis);
|
||||
|
||||
} // namespace function
|
||||
|
@@ -156,6 +156,8 @@ PYBIND11_MODULE(@PY_LIBRARY_NAME@, m) {
|
||||
"Make programer easier to deploy deeplearning model, save time to save "
|
||||
"the world!";
|
||||
|
||||
m.def("set_logger", &SetLogger);
|
||||
|
||||
BindFDTensor(m);
|
||||
BindRuntime(m);
|
||||
BindFDModel(m);
|
||||
|
@@ -13,10 +13,19 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include "fastdeploy/utils/utils.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace fastdeploy {
|
||||
|
||||
bool FDLogger::enable_info = true;
|
||||
bool FDLogger::enable_warning = true;
|
||||
|
||||
void SetLogger(bool enable_info, bool enable_warning) {
|
||||
FDLogger::enable_info = enable_info;
|
||||
FDLogger::enable_warning = enable_warning;
|
||||
}
|
||||
|
||||
FDLogger::FDLogger(bool verbose, const std::string& prefix) {
|
||||
verbose_ = verbose;
|
||||
line_ = "";
|
||||
|
@@ -43,6 +43,9 @@ namespace fastdeploy {
|
||||
|
||||
class FASTDEPLOY_DECL FDLogger {
|
||||
public:
|
||||
static bool enable_info;
|
||||
static bool enable_warning;
|
||||
|
||||
FDLogger() {
|
||||
line_ = "";
|
||||
prefix_ = "[FastDeploy]";
|
||||
@@ -90,11 +93,12 @@ FASTDEPLOY_DECL bool ReadBinaryFromFile(const std::string& file,
|
||||
<< __REL_FILE__ << "(" << __LINE__ << ")::" << __FUNCTION__ << "\t"
|
||||
|
||||
#define FDWARNING \
|
||||
FDLogger(true, "[WARNING]") \
|
||||
FDLogger(fastdeploy::FDLogger::enable_warning, "[WARNING]") \
|
||||
<< __REL_FILE__ << "(" << __LINE__ << ")::" << __FUNCTION__ << "\t"
|
||||
|
||||
#define FDINFO \
|
||||
FDLogger(true, "[INFO]") << __REL_FILE__ << "(" << __LINE__ \
|
||||
FDLogger(fastdeploy::FDLogger::enable_info, "[INFO]") \
|
||||
<< __REL_FILE__ << "(" << __LINE__ \
|
||||
<< ")::" << __FUNCTION__ << "\t"
|
||||
|
||||
#define FDASSERT(condition, format, ...) \
|
||||
@@ -214,6 +218,10 @@ std::string Str(const std::vector<T>& shape) {
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/// Set behaviour of logging while using FastDeploy
|
||||
FASTDEPLOY_DECL void SetLogger(bool enable_info = true,
|
||||
bool enable_warning = true);
|
||||
|
||||
template <typename T>
|
||||
void CalculateStatisInfo(const void* src_ptr, int size, double* mean,
|
||||
double* max, double* min) {
|
||||
|
@@ -30,6 +30,17 @@ from .c_lib_wrap import (
|
||||
is_built_with_trt,
|
||||
get_default_cuda_directory, )
|
||||
|
||||
|
||||
def set_logger(enable_info=True, enable_warning=True):
|
||||
"""Set behaviour of logger while using FastDeploy
|
||||
|
||||
:param enable_info: (boolean)Whether to print out log level of INFO
|
||||
:param enable_warning: (boolean)Whether to print out log level of WARNING, recommend to set to True
|
||||
"""
|
||||
from .c_lib_wrap import set_logger
|
||||
set_logger(enable_info, enable_warning)
|
||||
|
||||
|
||||
from .runtime import Runtime, RuntimeOption
|
||||
from .model import FastDeployModel
|
||||
from . import c_lib_wrap as C
|
||||
|
Reference in New Issue
Block a user