forked from mindspore-Ecosystem/mindspore
!48336 Fix code check warnings
Merge pull request !48336 from zyli2020/bug_fix
This commit is contained in:
commit
511d1e66cf
|
@ -23,12 +23,12 @@ namespace mindspore {
|
|||
namespace device {
|
||||
namespace cpu {
|
||||
#define CHECK_RET_WITH_EXCEPT(expression, status, message) \
|
||||
{ \
|
||||
do { \
|
||||
auto ret = (expression); \
|
||||
if (ret != (status)) { \
|
||||
MS_LOG(EXCEPTION) << (message); \
|
||||
} \
|
||||
}
|
||||
} while (0);
|
||||
} // namespace cpu
|
||||
} // namespace device
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -133,6 +133,10 @@ class TrtLogger : public nvinfer1::ILogger {
|
|||
{Severity::kERROR, {MsLogLevel::kError, google::GLOG_ERROR, "ERROR"}},
|
||||
{Severity::kINTERNAL_ERROR, {MsLogLevel::kError, google::GLOG_ERROR, "INTERNAL ERROR"}}};
|
||||
|
||||
static const size_t kMsLogLevelIndex = 0;
|
||||
static const size_t kGoogleLogLevelIndex = 1;
|
||||
static const size_t kLogLevelDescriptionIndex = 2;
|
||||
|
||||
auto iter = logger_map.find(severity);
|
||||
if (iter == logger_map.end()) {
|
||||
google::LogMessage("", 0, google::GLOG_WARNING).stream() << "Unrecognized severity type: " << msg << std::endl;
|
||||
|
@ -141,12 +145,12 @@ class TrtLogger : public nvinfer1::ILogger {
|
|||
|
||||
auto level = iter->second;
|
||||
// discard log
|
||||
if (std::get<0>(level) < log_level_) {
|
||||
if (std::get<kMsLogLevelIndex>(level) < log_level_) {
|
||||
return;
|
||||
}
|
||||
|
||||
google::LogMessage("", 0, std::get<1>(level)).stream()
|
||||
<< "[TensorRT " << std::get<2>(level) << "] " << msg << std::endl;
|
||||
google::LogMessage("", 0, std::get<kGoogleLogLevelIndex>(level)).stream()
|
||||
<< "[TensorRT " << std::get<kLogLevelDescriptionIndex>(level) << "] " << msg << std::endl;
|
||||
#undef google
|
||||
#endif // USE_GLOG
|
||||
}
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace opt {
|
||||
// The const number 4GB in bytes.
|
||||
constexpr size_t kFourGBytes = 4UL << 30;
|
||||
|
||||
// Class transform ANF graph to Tensor-RT network.
|
||||
// It converts the operators in ANF graph to Tensor-RT layer according to the topological order.
|
||||
// During the conversion, the cache keep the map between ANF node outputs and Tensor-RT layer outputs.
|
||||
|
@ -43,7 +46,7 @@ class TrtConverterContext : public std::enable_shared_from_this<TrtConverterCont
|
|||
explicit TrtConverterContext(FuncGraphPtr fg)
|
||||
: func_graph_(fg),
|
||||
batch_size_(1),
|
||||
workspace_size_(4UL << 30),
|
||||
workspace_size_(kFourGBytes),
|
||||
builder_(nullptr),
|
||||
network_(nullptr),
|
||||
config_(nullptr),
|
||||
|
|
|
@ -374,7 +374,7 @@ void EmbeddingCachePrefetchActor::LookupEmbeddingTable(size_t indices_num, size_
|
|||
for (size_t i = 0; i < indices_num; ++i) {
|
||||
int index = indices_addr[i];
|
||||
if (index >= 0 && index < SizeToInt(first_dim_size)) {
|
||||
size_t pos = index * embedding_size;
|
||||
size_t pos = IntToSize(index) * embedding_size;
|
||||
auto ret = memcpy_s(output_addr, (indices_num - i) * lens, input_addr + pos, lens);
|
||||
if (ret != EOK) {
|
||||
MS_LOG(ERROR) << "Memcpy failed, errno[" << ret << "]";
|
||||
|
|
Loading…
Reference in New Issue