!23711 Fix the code warnings

Merge pull request !23711 from maning202007/master
This commit is contained in:
i-robot 2021-09-19 06:21:24 +00:00 committed by Gitee
commit 60b33924dc
10 changed files with 23 additions and 10 deletions

View File

@ -544,11 +544,12 @@ void DebugServices::ReadTensorFromNpy(const std::string &tensor_name, const std:
const int substr_len = 2;
const int header_len_offset = 8;
const int header_offset = 9;
const int header_len_buffer_size = 2;
const int type_offset = 10;
// get header length
infile.seekg(0, std::ios::beg);
auto header_len_buffer = std::make_unique<std::vector<char>>(header_len_offset + 2);
if (!infile.read(header_len_buffer->data(), header_len_offset + 2)) {
auto header_len_buffer = std::make_unique<std::vector<char>>(header_len_offset + header_len_buffer_size);
if (!infile.read(header_len_buffer->data(), header_len_offset + header_len_buffer_size)) {
MS_LOG(ERROR) << "Failed to parse header length from " << file_path;
return;
}

View File

@ -425,7 +425,7 @@ class DebugServices {
std::unordered_map<std::string, std::vector<std::string>> overflow_ops_;
std::string net_name_;
std::string dump_dir_;
bool is_sync_mode_;
bool is_sync_mode_{false};
std::shared_ptr<TensorLoader> tensor_loader_;
};

View File

@ -600,7 +600,6 @@ void Debugger::SendHeartbeat(int32_t period) {
while (enable_heartbeat_) {
MS_EXCEPTION_IF_NULL(grpc_client_);
EventReply reply = grpc_client_->SendHeartbeat(heartbeat);
if (reply.status() != reply.OK) {
MS_LOG(ERROR) << "Error: SendHeartbeat failed";
num_heartbeat_fail++;

View File

@ -194,7 +194,6 @@ EventReply GrpcClient::SendHeartbeat(const Heartbeat &heartbeat) {
grpc::ClientContext context;
grpc::Status status = stub_->SendHeartbeat(&context, heartbeat, &reply);
if (!status.ok()) {
MS_LOG(ERROR) << "RPC failed: SendHeartbeat";
MS_LOG(ERROR) << status.error_code() << ": " << status.error_message();
@ -217,7 +216,6 @@ EventReply GrpcClient::SendTensorBase(const std::list<TensorBase> &tensor_base_l
}
writer->WritesDone();
grpc::Status status = writer->Finish();
if (!status.ok()) {
MS_LOG(ERROR) << "RPC failed: SendTensorBase";
MS_LOG(ERROR) << status.error_code() << ": " << status.error_message();
@ -240,7 +238,6 @@ EventReply GrpcClient::SendTensorStats(const std::list<TensorSummary> &tensor_su
}
writer->WritesDone();
grpc::Status status = writer->Finish();
if (!status.ok()) {
MS_LOG(ERROR) << "RPC failed: SendTensorStats";
MS_LOG(ERROR) << status.error_code() << ": " << status.error_message();

View File

@ -20,8 +20,8 @@
DbgServices::DbgServices(bool verbose) {
DbgLogger::verbose = verbose;
char *dbg_log_path = getenv("OFFLINE_DBG_LOG");
if (dbg_log_path != NULL) {
std::string dbg_log_path = common::GetEnv("OFFLINE_DBG_LOG");
if (!dbg_log_path.empty()) {
DbgLogger::verbose = true;
}
debug_services_ = new DebugServices();

View File

@ -27,8 +27,10 @@
#include "pybind11/stl.h"
#include "pybind11/stl_bind.h"
#include "utils/ms_utils.h"
#include "debug/debug_services.h"
namespace py = pybind11;
namespace common = mindspore::common;
struct parameter_t {
parameter_t(const std::string &name, bool disabled, double value, bool hit, double actual_value)

View File

@ -104,6 +104,7 @@ class ConvertToolLoader:
if str(toolkit_path) in sys.path:
sys.path.remove(str(toolkit_path))
def parse_args(file_list, output_path):
"""Helper function to parse the input argument for the conversion configuration."""
args_dict = dict()

View File

@ -42,6 +42,7 @@ def get_version():
"Please recompile mindspore without `-s on`.")
return cds.DbgServices(False).GetVersion()
class DbgLogger:
"""
Offline Debug Services Logger
@ -367,6 +368,7 @@ class DbgServices():
tensor_stat_data_list_ret.append(tensor_stat_data)
return tensor_stat_data_list_ret
class TensorInfo():
"""
Tensor Information class.
@ -522,6 +524,7 @@ class TensorInfo():
return self.instance.get_is_output()
class TensorData():
"""
TensorData class.
@ -623,6 +626,7 @@ class TensorData():
return self.instance.get_shape()
class TensorBaseData():
"""
@ -707,6 +711,8 @@ class TensorBaseData():
"""
return self.instance.shape()
class TensorStatData():
"""
@ -1055,6 +1061,7 @@ class TensorStatData():
"""
return self.instance.pos_inf_count()
class WatchpointHit():
"""
WatchpointHit class.
@ -1286,6 +1293,7 @@ class WatchpointHit():
return self.instance.get_root_graph_id()
class Parameter():
"""
Parameter class.

View File

@ -127,6 +127,7 @@ def type_check_list(args, types, arg_names):
for arg, arg_name in zip(args, arg_names):
type_check(arg, types, arg_name)
def replace_minus_one(value):
""" replace -1 with a default value """
return value if value != -1 else UINT32_MAX

View File

@ -18,7 +18,8 @@ Validator Functions for Offline Debugger APIs.
from functools import wraps
import mindspore.offline_debug.dbg_services as cds
from mindspore.offline_debug.mi_validator_helpers import parse_user_args, type_check, type_check_list, check_dir, check_uint32, check_uint64, check_iteration
from mindspore.offline_debug.mi_validator_helpers import parse_user_args, type_check, \
type_check_list, check_dir, check_uint32, check_uint64, check_iteration
def check_init(method):
@ -190,6 +191,7 @@ def check_tensor_data_init(method):
return new_method
def check_tensor_base_data_init(method):
"""Wrapper method to check the parameters of DbgServices TensorBaseData init."""
@ -206,6 +208,7 @@ def check_tensor_base_data_init(method):
return new_method
def check_tensor_stat_data_init(method):
"""Wrapper method to check the parameters of DbgServices TensorBaseData init."""
@ -237,6 +240,7 @@ def check_tensor_stat_data_init(method):
return new_method
def check_watchpoint_hit_init(method):
"""Wrapper method to check the parameters of DbgServices WatchpointHit init."""