!18613 fix issues for code check
Merge pull request !18613 from jiangshuqiang/fix_code_check
This commit is contained in:
commit
97fa0e6398
|
@ -6,5 +6,4 @@ approvers:
|
|||
- stsuteng
|
||||
- c_34
|
||||
- liangchenghui
|
||||
- wuxuejian
|
||||
- yelihua
|
||||
- wuxuejian
|
|
@ -392,7 +392,7 @@ void DebugServices::ReadTensorFromNpy(const std::string &file_name, std::string
|
|||
}
|
||||
uint64_t file_size = infile.tellg();
|
||||
infile.seekg(0, std::ios::beg);
|
||||
std::unique_ptr<std::vector<char>> buffer(new std::vector<char>(file_size));
|
||||
auto buffer = std::make_unique<std::vector<char>>(file_size);
|
||||
if (!infile.read(buffer->data(), file_size)) {
|
||||
MS_LOG(ERROR) << "Failed to read file (In ReadTensorFromNpy) " << file_path;
|
||||
return;
|
||||
|
@ -415,7 +415,7 @@ void DebugServices::ReadTensorFromNpy(const std::string &file_name, std::string
|
|||
std::size_t data_size = data_len * word_size;
|
||||
infile.seekg(header_len + 10);
|
||||
*data_buffer = new std::vector<char>(data_size);
|
||||
if (!infile.read((*data_buffer)->data(), data_size)) {
|
||||
if (data_buffer == nullptr || !infile.read((*data_buffer)->data(), data_size)) {
|
||||
MS_LOG(ERROR) << "Unable to get tensor data from npy";
|
||||
}
|
||||
*size = data_size;
|
||||
|
|
|
@ -55,6 +55,10 @@ int32_t DbgServices::Initialize(std::string net_name, std::string dump_folder_pa
|
|||
MS_LOG(INFO) << "cpp DbgServices initialize network name " << net_name;
|
||||
MS_LOG(INFO) << "cpp DbgServices initialize dump folder path " << dump_folder_path;
|
||||
MS_LOG(INFO) << "cpp DbgServices initialize sync mode " << is_sync_mode;
|
||||
if (debug_services == nullptr) {
|
||||
MS_LOG(EXCEPTION) << "Debugger services initialize failed as occur null pointer error,"
|
||||
<< "may be due to memory allocation failure, check as: top";
|
||||
}
|
||||
debug_services->SetNetName(net_name);
|
||||
debug_services->SetDumpDir(dump_folder_path);
|
||||
debug_services->SetSyncMode(is_sync_mode);
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
approvers:
|
||||
- ougongchang
|
||||
- yelihua
|
||||
- lilongfei15
|
||||
- wangyue01
|
||||
- wenkai_distq
|
|
@ -360,6 +360,11 @@ def _fill_image_summary(tag: str, np_value, summary_image, input_format='NCHW'):
|
|||
f"The tensor with dim({np_value.ndim}) can't convert the format({input_format}) because dim not same")
|
||||
return False
|
||||
|
||||
if 0 in np_value.shape:
|
||||
logger.error(
|
||||
f"The tensor with shape({np_value.shape}) is not a valid image because the shape contains zero.")
|
||||
return False
|
||||
|
||||
# convert the tensor format
|
||||
tensor = _convert_image_format(np_value, input_format)
|
||||
|
||||
|
|
Loading…
Reference in New Issue