@@ -155,7 +155,7 @@ static uint8_t GetUint8ValByMan(uint8_t s_ret, const uint64_t &long_int_m, const | |||
if (need_round) { | |||
m_ret++; | |||
} | |||
if (s_ret) { | |||
if (static_cast<bool>(s_ret)) { | |||
m_ret = (~m_ret) + 1; | |||
} | |||
if (m_ret == 0) { | |||
@@ -208,14 +208,14 @@ static int8_t Fp16ToInt8(const uint16_t &fp_val) { | |||
} | |||
} | |||
} | |||
if (overflow_flag) { | |||
if (static_cast<bool>(overflow_flag)) { | |||
ret_v = kInt8Max + s_ret; | |||
} else { | |||
// Generate final result | |||
ret_v = GetUint8ValByMan(s_ret, long_int_m, shift_out); | |||
} | |||
ret = *(reinterpret_cast<uint8_t *>(&ret_v)); | |||
ret = *(ge::PtrToPtr<uint8_t, uint8_t>(&ret_v)); | |||
return ret; | |||
} | |||
@@ -284,7 +284,7 @@ static uint16_t GetUint16ValByMan(uint16_t s_ret, const uint64_t &long_int_m, co | |||
if (need_round && m_ret < kInt16Max) { | |||
m_ret++; | |||
} | |||
if (s_ret) { | |||
if (static_cast<bool>(s_ret)) { | |||
m_ret = (~m_ret) + 1; | |||
} | |||
if (m_ret == 0) { | |||
@@ -308,7 +308,7 @@ static int16_t Fp16ToInt16(const uint16_t &fp_val) { | |||
if (FP16_IS_DENORM(fp_val)) { // Denormalized number | |||
ret_v = 0; | |||
ret = *(reinterpret_cast<uint8_t *>(&ret_v)); | |||
ret = *(ge::PtrToPtr<uint16_t, uint8_t>(&ret_v)); | |||
return ret; | |||
} | |||
@@ -337,13 +337,13 @@ static int16_t Fp16ToInt16(const uint16_t &fp_val) { | |||
} | |||
} | |||
} | |||
if (overflow_flag) { | |||
if (static_cast<bool>(overflow_flag)) { | |||
ret_v = kInt16Max + s_ret; | |||
} else { | |||
// Generate final result | |||
ret_v = GetUint16ValByMan(s_ret, long_int_m, shift_out); | |||
} | |||
ret = *(reinterpret_cast<int16_t *>(&ret_v)); | |||
ret = *(ge::PtrToPtr<uint16_t, uint16_t>(&ret_v)); | |||
return ret; | |||
} | |||
@@ -434,7 +434,7 @@ static int32_t Fp16ToInt32(const uint16_t &fp_val) { | |||
ret_v = (s_ret << kBitShift31) | (m_ret); | |||
} | |||
return *(reinterpret_cast<int32_t *>(&ret_v)); | |||
return *(ge::PtrToPtr<uint32_t, uint32_t>(&ret_v)); | |||
} | |||
/// @ingroup fp16_t math conversion static method | |||
@@ -892,7 +892,7 @@ fp16_t &fp16_t::operator=(const float &f_val) { | |||
if (need_round) { | |||
m_ret++; | |||
} | |||
if (m_ret & kFp16ManHideBit) { | |||
if (static_cast<bool>(m_ret & kFp16ManHideBit)) { | |||
e_ret++; | |||
} | |||
} | |||
@@ -911,7 +911,7 @@ fp16_t &fp16_t::operator=(const int8_t &i_val) { | |||
if (m_ret == 0) { | |||
e_ret = 0; | |||
} else { | |||
if (s_ret) { // negative number(<0) | |||
if (static_cast<bool>(s_ret)) { // negative number(<0) | |||
m_ret = static_cast<uint16_t>(std::abs(i_val)); // complement | |||
} | |||
@@ -932,7 +932,7 @@ fp16_t &fp16_t::operator=(const uint8_t &ui_val) { | |||
s_ret = 0; | |||
e_ret = 0; | |||
m_ret = ui_val; | |||
if (m_ret) { | |||
if (static_cast<bool>(m_ret)) { | |||
e_ret = kFp16ManLen; | |||
while ((m_ret & kFp16ManHideBit) == 0) { | |||
m_ret = m_ret << 1; | |||
@@ -950,7 +950,7 @@ static void SetValByUint16Val(const uint16_t &input_val, const uint16_t &sign, u | |||
uint16_t m_min = kFp16ManHideBit; | |||
uint16_t m_max = m_min << 1; | |||
uint16_t len = static_cast<uint16_t>(GetManBitLength(m_tmp)); | |||
if (m_tmp) { | |||
if (static_cast<bool>(m_tmp)) { | |||
int16_t e_ret; | |||
if (len > kDim11) { | |||
e_ret = kFp16ExpBias + kFp16ManLen; | |||
@@ -990,11 +990,11 @@ fp16_t &fp16_t::operator=(const int16_t &i_val) { | |||
if (i_val == 0) { | |||
val = 0; | |||
} else { | |||
uint16_t ui_val = *(reinterpret_cast<const uint16_t *>(&i_val)); | |||
uint16_t ui_val = *(ge::PtrToPtr<const int16_t, const int16_t>(&i_val)); | |||
auto s_ret = static_cast<uint16_t>(ui_val >> kBitShift15); | |||
if (s_ret) { | |||
if (static_cast<bool>(s_ret)) { | |||
int16_t iValM = -i_val; | |||
ui_val = *(reinterpret_cast<uint16_t *>(&iValM)); | |||
ui_val = *(ge::PtrToPtr<int16_t, uint16_t>(&iValM)); | |||
} | |||
SetValByUint16Val(ui_val, s_ret, val); | |||
} | |||
@@ -1096,11 +1096,11 @@ fp16_t &fp16_t::operator=(const int32_t &i_val) { | |||
if (i_val == 0) { | |||
val = 0; | |||
} else { | |||
uint32_t ui_val = *(reinterpret_cast<const uint32_t *>(&i_val)); | |||
uint32_t ui_val = *(ge::PtrToPtr<const int32_t, const uint32_t>(&i_val)); | |||
auto s_ret = static_cast<uint16_t>(ui_val >> kBitShift31); | |||
if (s_ret) { | |||
if (static_cast<bool>(s_ret)) { | |||
int32_t iValM = -i_val; | |||
ui_val = *(reinterpret_cast<uint32_t *>(&iValM)); | |||
ui_val = *(ge::PtrToPtr<int32_t, uint32_t>(&iValM)); | |||
} | |||
SetValByUint32Val(ui_val, s_ret, val); | |||
} | |||
@@ -1205,7 +1205,7 @@ fp16_t &fp16_t::operator=(const double &d_val) { | |||
if (need_round) { | |||
m_ret++; | |||
} | |||
if (m_ret & kFp16ManHideBit) { | |||
if (static_cast<bool>(m_ret & kFp16ManHideBit)) { | |||
e_ret++; | |||
} | |||
} | |||
@@ -1240,7 +1240,7 @@ fp16_t::operator uint64_t() const { return 0; } | |||
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int fp16_t::IsInf() const { | |||
if ((val & kFp16AbsMax) == kFp16ExpMask) { | |||
if (val & kFp16SignMask) { | |||
if (static_cast<bool>(val & kFp16SignMask)) { | |||
return -1; | |||
} else { | |||
return 1; | |||
@@ -199,7 +199,7 @@ Status OnnxConstantParser::ParseConvertDataType(const ge::onnx::TensorProto &ten | |||
Status OnnxConstantParser::ParseConstFromInput(const ge::onnx::NodeProto *op_src, ge::Operator &op_def) { | |||
GE_CHECK_NOTNULL(op_src); | |||
const NodeProto *node = reinterpret_cast<const NodeProto *>(op_src); | |||
const NodeProto *node = PtrToPtr<const ge::onnx::NodeProto, const NodeProto>(op_src); | |||
// Get const Tensor from node | |||
Tensor tensor; | |||
@@ -226,7 +226,7 @@ Status OnnxConstantParser::ParseConstFromInput(const ge::onnx::NodeProto *op_src | |||
Status OnnxConstantParser::ParseParams(const Message *op_src, ge::Operator &op_def) { | |||
GE_CHECK_NOTNULL(op_src); | |||
const ge::onnx::NodeProto *node = reinterpret_cast<const ge::onnx::NodeProto *>(op_src); | |||
const ge::onnx::NodeProto *node = PtrToPtr<const Message, const ge::onnx::NodeProto>(op_src); | |||
GE_CHECK_NOTNULL(node); | |||
GELOGD("Onnx op node name = %s, op type= %s, parse params", node->name().c_str(), node->op_type().c_str()); | |||
@@ -32,7 +32,7 @@ const char *const kSerializeFormat = "serialize_format"; | |||
Status ParseParams(const Message *op_src, ArgOpOperator *const op) { | |||
GE_CHECK_NOTNULL(op_src); | |||
GE_CHECK_NOTNULL(op); | |||
const domi::tensorflow::NodeDef *node = reinterpret_cast<const domi::tensorflow::NodeDef *>(op_src); | |||
const domi::tensorflow::NodeDef *node = PtrToPtr<const Message, const domi::tensorflow::NodeDef>(op_src); | |||
GELOGD("TF op node name = %s, op type= %s, parse params", node->name().c_str(), node->op().c_str()); | |||
domi::tensorflow::AttrValue output_attr_value; | |||
if (TensorFlowUtil::FindAttrValue(node, ge::ATTR_NAME_OUTPUT_TENSOR_DESC, output_attr_value)) { | |||
@@ -31,7 +31,7 @@ namespace ge { | |||
Status ParseParams(const Message *op_src, FrameworkOpOperator *op) { | |||
GE_CHECK_NOTNULL(op_src); | |||
GE_CHECK_NOTNULL(op); | |||
const domi::tensorflow::NodeDef *node = reinterpret_cast<const domi::tensorflow::NodeDef *>(op_src); | |||
const domi::tensorflow::NodeDef *node = PtrToPtr<const Message, const domi::tensorflow::NodeDef>(op_src); | |||
GELOGD("TF op node name = %s, op type= %s, parse params", node->name().c_str(), node->op().c_str()); | |||
string type = node->op(); | |||
@@ -33,7 +33,8 @@ Status TensorFlowFusionCustomParserAdapter::ParseParams(const vector<const NodeD | |||
std::vector<const google::protobuf::Message *> inside_nodes; | |||
for (auto inside_node : v_input_const) { | |||
GE_CHECK_NOTNULL(inside_node); | |||
const google::protobuf::Message *node_src = reinterpret_cast<const google::protobuf::Message *>(inside_node); | |||
const google::protobuf::Message *node_src = | |||
PtrToPtr<const google::protobuf::Message, const google::protobuf::Message>(inside_node); | |||
inside_nodes.push_back(node_src); | |||
} | |||
std::string ori_type = op_dest->GetType(); | |||
@@ -1203,7 +1203,7 @@ Status TensorFlowModelParser::ParseFromMemory(const char *data, uint32_t size, g | |||
graph_def = OriDef; | |||
} else { | |||
GELOGI("Before Trim, the Graph Node size is:%d", OriDef.node_size()); | |||
if (TrimGraph(OriDef, &graph_def)) { | |||
if (static_cast<bool>(TrimGraph(OriDef, &graph_def))) { | |||
GELOGE(FAILED, "Trim Graph fail."); | |||
return INTERNAL_ERROR; | |||
} | |||
@@ -1370,7 +1370,7 @@ Status TensorFlowModelParser::Parse(const char *model_path, ge::ComputeGraphPtr | |||
graph_def = ori_def; | |||
} else { | |||
GELOGI("Before Trim, the Graph Node size is:%d", ori_def.node_size()); | |||
if (TrimGraph(ori_def, &graph_def)) { | |||
if (static_cast<bool>(TrimGraph(ori_def, &graph_def))) { | |||
GELOGE(FAILED, "Trim Graph fail."); | |||
return INTERNAL_ERROR; | |||
} | |||
@@ -3042,7 +3042,7 @@ Status TensorFlowModelParser::TrimGraphByInput(const domi::tensorflow::GraphDef | |||
domi::tensorflow::GraphDef filtered_graph_def; | |||
filtered_graph_def.mutable_node()->Clear(); | |||
for (const NodeDef &node : input_graph_def.node()) { | |||
if (input_nodes.count(node.name())) { | |||
if (static_cast<bool>(input_nodes.count(node.name()))) { | |||
*(filtered_graph_def.mutable_node()->Add()) = node; | |||
} | |||
if (!delete_nodes.count(node.name())) { | |||
@@ -3051,7 +3051,7 @@ Status TensorFlowModelParser::TrimGraphByInput(const domi::tensorflow::GraphDef | |||
} | |||
output_graph_def->Clear(); | |||
for (const NodeDef &node : filtered_graph_def.node()) { | |||
if (input_nodes.count(node.name())) { | |||
if (static_cast<bool>(input_nodes.count(node.name()))) { | |||
NodeDef placeholder_node = node; | |||
placeholder_node.clear_input(); | |||
GE_IF_BOOL_EXEC(node.op() != "Placeholder", placeholder_node.set_op("Placeholder")); | |||
@@ -3099,7 +3099,7 @@ Status TensorFlowModelParser::TrimGraphByOutput(const domi::tensorflow::GraphDef | |||
std::set<string> next_inputs; | |||
for (const string ¤t_input : current_inputs) { | |||
required_nodes.insert(current_input); | |||
GE_IF_BOOL_EXEC(input_nodes.count(current_input), continue); | |||
GE_IF_BOOL_EXEC(static_cast<bool>(input_nodes.count(current_input)), continue); | |||
GE_CHK_BOOL_EXEC(node_lookup.count(current_input) > 0U, | |||
ErrorManager::GetInstance().ATCReportErrMessage("E10016", {"parameter", "opname"}, | |||
{"out_nodes", current_input}); | |||
@@ -3118,13 +3118,13 @@ Status TensorFlowModelParser::TrimGraphByOutput(const domi::tensorflow::GraphDef | |||
domi::tensorflow::GraphDef filtered_graph_def; | |||
filtered_graph_def.mutable_node()->Clear(); | |||
for (const NodeDef &node : input_graph_def.node()) { | |||
if (required_nodes.count(node.name())) { | |||
if (static_cast<bool>(required_nodes.count(node.name()))) { | |||
*(filtered_graph_def.mutable_node()->Add()) = node; | |||
} | |||
} | |||
output_graph_def->Clear(); | |||
for (const NodeDef &node : filtered_graph_def.node()) { | |||
if (input_nodes.count(node.name())) { | |||
if (static_cast<bool>(input_nodes.count(node.name()))) { | |||
NodeDef placeholder_node = node; | |||
placeholder_node.clear_input(); | |||
GE_IF_BOOL_EXEC(node.op() != "Placeholder", placeholder_node.set_op("Placeholder")); | |||