From f9b487e81bb296cb06b0467b5d89fac81427ecfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=8A=9D=E4=BC=9F?= Date: Tue, 27 Sep 2022 12:29:04 +0000 Subject: [PATCH] =?UTF-8?q?!680=20codecheck=20=E5=91=8A=E8=AD=A6=E6=B8=85?= =?UTF-8?q?=E7=90=86=20Merge=20pull=20request=20!680=20from=20=E7=8E=8B?= =?UTF-8?q?=E8=8A=9D=E4=BC=9F/ge=5Fdev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parser/common/CMakeLists.txt | 2 +- parser/common/acl_graph_parser_util.cc | 2 +- parser/common/data_op_parser.h | 2 +- parser/common/graph_pass.h | 4 - parser/common/model_saver.cc | 3 +- parser/common/model_saver.h | 6 +- parser/common/module.mk | 2 +- parser/common/op_map.h | 2 +- parser/common/op_parser_factory.h | 3 +- .../{register_tbe.cc => op_registration_tbe.cc} | 2 +- .../{register_tbe.h => op_registration_tbe.h} | 0 parser/common/parser_api.cc | 4 +- parser/common/parser_factory.cc | 4 +- parser/common/parser_fp16_t.cc | 88 +++++++++++----------- parser/common/parser_fp16_t.h | 38 +++++----- parser/common/thread_pool.h | 2 +- parser/onnx/onnx_constant_parser.cc | 2 +- parser/onnx/onnx_constant_parser.h | 2 +- parser/onnx/onnx_custom_parser_adapter.cc | 2 +- parser/onnx/onnx_custom_parser_adapter.h | 2 +- parser/onnx/onnx_data_parser.cc | 2 +- parser/onnx/onnx_data_parser.h | 2 +- parser/onnx/onnx_file_constant_parser.cc | 4 +- parser/onnx/onnx_file_constant_parser.h | 2 +- parser/onnx/onnx_op_parser.h | 2 +- tests/st/CMakeLists.txt | 2 +- tests/st/testcase/test_caffe_parser.cc | 2 +- tests/st/testcase/test_onnx_parser.cc | 2 +- tests/st/testcase/test_tensorflow_parser.cc | 3 +- tests/ut/parser/CMakeLists.txt | 2 +- .../caffe_parser_testcase/caffe_parser_unittest.cc | 2 +- .../testcase/common/acl_graph_parser_unittest.cc | 2 +- .../onnx_parser_testcase/onnx_parser_unittest.cc | 2 +- ...sorflow_auto_mapping_parser_adapter_unittest.cc | 2 +- .../tensorflow_parser_unittest.cc | 3 +- 35 files changed, 99 insertions(+), 107 deletions(-) rename parser/common/{register_tbe.cc => op_registration_tbe.cc} (99%) rename parser/common/{register_tbe.h => op_registration_tbe.h} (100%) diff --git a/parser/common/CMakeLists.txt b/parser/common/CMakeLists.txt index e9c1884..087b83b 100644 --- a/parser/common/CMakeLists.txt +++ b/parser/common/CMakeLists.txt @@ -3,7 +3,7 @@ set(SRC_LIST "data_op_parser.cc" "op_parser_factory.cc" "pre_checker.cc" - "register_tbe.cc" + "op_registration_tbe.cc" "parser_api.cc" "parser_inner_ctx.cc" "proto_file_parser.cc" diff --git a/parser/common/acl_graph_parser_util.cc b/parser/common/acl_graph_parser_util.cc index c10ed57..d5f0d20 100644 --- a/parser/common/acl_graph_parser_util.cc +++ b/parser/common/acl_graph_parser_util.cc @@ -37,7 +37,7 @@ #include "graph/opsproto_manager.h" #include "graph/utils/type_utils.h" #include "omg/parser/parser_inner_ctx.h" -#include "parser/common/register_tbe.h" +#include "parser/common/op_registration_tbe.h" #include "tbe_plugin_loader.h" #include "mmpa/mmpa_api.h" diff --git a/parser/common/data_op_parser.h b/parser/common/data_op_parser.h index da2f15a..6329e87 100644 --- a/parser/common/data_op_parser.h +++ b/parser/common/data_op_parser.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/graph_pass.h b/parser/common/graph_pass.h index 68a6338..28e3279 100644 --- a/parser/common/graph_pass.h +++ b/parser/common/graph_pass.h @@ -22,21 +22,17 @@ #include "common/pass.h" namespace ge { -/// /// @ingroup domi_omg /// @brief graph pass /// @author -/// class GraphPass : public Pass { public: - /// /// run graph pass /// @param [in] graph graph to be optimized /// @return SUCCESS optimize successfully /// @return NOT_CHANGED not optimized /// @return others optimized failed /// @author - /// virtual Status Run(ge::ComputeGraphPtr graph) = 0; virtual Status ClearStatus() { return SUCCESS; }; }; diff --git a/parser/common/model_saver.cc b/parser/common/model_saver.cc index 21d9368..a3445a8 100644 --- a/parser/common/model_saver.cc +++ b/parser/common/model_saver.cc @@ -74,10 +74,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi GELOGE(FAILED, "[Open][File] [%s] failed. %s", file_path, err_msg); return FAILED; } - const char *model_char = model_str.c_str(); uint32_t len = static_cast(model_str.length()); // Write data to file - mmSsize_t mmpa_ret = mmWrite(fd, const_cast(static_cast(model_char)), len); + mmSsize_t mmpa_ret = mmWrite(fd, const_cast(static_cast(model_str.c_str())), len); if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) { char_t err_buf[kMaxErrStrLen + 1U] = {}; const auto err_msg = mmGetErrorFormatMessage(mmGetErrorCode(), &err_buf[0], kMaxErrStrLen); diff --git a/parser/common/model_saver.h b/parser/common/model_saver.h index cee6c07..137e96a 100644 --- a/parser/common/model_saver.h +++ b/parser/common/model_saver.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,11 +41,9 @@ public: static Status SaveJsonToFile(const char *file_path, const Json &model); private: - /// /// @ingroup domi_common /// @brief Check validity of the file path /// @return Status result - /// static Status CheckPath(const string &file_path); static int CreateDirectory(const std::string &directory_path); @@ -53,4 +51,4 @@ private: } // namespace parser } // namespace ge -#endif //PARSER_COMMON_FILE_SAVER_H_ +#endif // PARSER_COMMON_FILE_SAVER_H_ diff --git a/parser/common/module.mk b/parser/common/module.mk index ba73f40..6dcbb38 100644 --- a/parser/common/module.mk +++ b/parser/common/module.mk @@ -15,7 +15,7 @@ COMMON_LOCAL_SRC_FILES := \ data_op_parser.cc \ op_parser_factory.cc \ pre_checker.cc \ - register_tbe.cc \ + op_registration_tbe.cc \ parser_api.cc \ parser_inner_ctx.cc \ proto_file_parser.cc \ diff --git a/parser/common/op_map.h b/parser/common/op_map.h index cae651c..3ea80c2 100644 --- a/parser/common/op_map.h +++ b/parser/common/op_map.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/op_parser_factory.h b/parser/common/op_parser_factory.h index 92fdda5..682de50 100644 --- a/parser/common/op_parser_factory.h +++ b/parser/common/op_parser_factory.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,7 +77,6 @@ class OpParserFactory { * @brief OpParser creation function * @return Created OpParser */ - // typedef shared_ptr (*CREATOR_FUN)(void); using CREATOR_FUN = std::function(void)>; /** diff --git a/parser/common/register_tbe.cc b/parser/common/op_registration_tbe.cc similarity index 99% rename from parser/common/register_tbe.cc rename to parser/common/op_registration_tbe.cc index c1287f2..6548034 100644 --- a/parser/common/register_tbe.cc +++ b/parser/common/op_registration_tbe.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "parser/common/register_tbe.h" +#include "parser/common/op_registration_tbe.h" #include #include #include diff --git a/parser/common/register_tbe.h b/parser/common/op_registration_tbe.h similarity index 100% rename from parser/common/register_tbe.h rename to parser/common/op_registration_tbe.h diff --git a/parser/common/parser_api.cc b/parser/common/parser_api.cc index 2110116..a848ee2 100644 --- a/parser/common/parser_api.cc +++ b/parser/common/parser_api.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #include "common/util.h" #include "tbe_plugin_loader.h" #include "framework/common/debug/ge_log.h" -#include "parser/common/register_tbe.h" +#include "parser/common/op_registration_tbe.h" #include "framework/omg/parser/parser_inner_ctx.h" #include "external/ge/ge_api_types.h" diff --git a/parser/common/parser_factory.cc b/parser/common/parser_factory.cc index 60efe29..3fac0f4 100644 --- a/parser/common/parser_factory.cc +++ b/parser/common/parser_factory.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ #include "omg/parser/parser_factory.h" #include "framework/common/debug/ge_log.h" -#include "common/register_tbe.h" +#include "common/op_registration_tbe.h" namespace domi { FMK_FUNC_HOST_VISIBILITY WeightsParserFactory *WeightsParserFactory::Instance() { diff --git a/parser/common/parser_fp16_t.cc b/parser/common/parser_fp16_t.cc index 3ce5c6b..d02704b 100644 --- a/parser/common/parser_fp16_t.cc +++ b/parser/common/parser_fp16_t.cc @@ -100,7 +100,8 @@ static float Fp16ToFloat(const uint16_t &fp_val) { e_ret = 0; m_ret = 0; } else { - e_ret = (static_cast(hf_exp) - static_cast(kFp16ExpBias)) + static_cast(kFp32ExpBias); + e_ret = static_cast((static_cast(hf_exp) - static_cast(kFp16ExpBias)) + + static_cast(kFp32ExpBias)); m_ret = hf_man & kFp16ManMask; m_ret = m_ret << (kFp32ManLen - kFp16ManLen); } @@ -132,7 +133,8 @@ static double Fp16ToDouble(const uint16_t &fp_val) { e_ret = 0; m_ret = 0; } else { - e_ret = (static_cast(hf_exp) - static_cast(kFp16ExpBias)) + static_cast(kFp64ExpBias); + e_ret = static_cast((static_cast(hf_exp) - static_cast(kFp16ExpBias)) + + static_cast(kFp64ExpBias)); m_ret = hf_man & kFp16ManMask; m_ret = m_ret << (kFp64ManLen - kFp16ManLen); } @@ -150,7 +152,7 @@ static double Fp16ToDouble(const uint16_t &fp_val) { /// @return Return uint8 value of fp16_t object static uint8_t GetUint8ValByMan(uint8_t s_ret, const uint64_t &long_int_m, const uint16_t &shift_out) { bool need_round = IsRoundOne(long_int_m, shift_out + kFp16ManLen); - auto m_ret = static_cast((long_int_m >> (kFp16ManLen + shift_out)) & kBitLen8Max); + auto m_ret = static_cast((long_int_m >> static_cast(kFp16ManLen + shift_out)) & kBitLen8Max); need_round = need_round && ((s_ret == 0 && m_ret < kInt8Max) || (s_ret == 1 && m_ret <= kInt8Max)); if (need_round) { m_ret++; @@ -172,14 +174,14 @@ static int8_t Fp16ToInt8(const uint16_t &fp_val) { int8_t ret; uint8_t ret_v; // 1.get s_ret and shift it to bit0. - uint8_t s_ret = Fp16ExtracSign(fp_val); + uint8_t s_ret = static_cast(Fp16ExtracSign(fp_val)); // 2.get hf_e and hf_m uint16_t hf_e = Fp16ExtracExp(fp_val); uint16_t hf_m = Fp16ExtracMan(fp_val); if (Fp16IsDenorm(fp_val)) { // Denormalized number ret_v = 0; - ret = *(ge::PtrToPtr(&ret_v)); + ret = static_cast(*(ge::PtrToPtr(&ret_v))); return ret; } @@ -215,7 +217,7 @@ static int8_t Fp16ToInt8(const uint16_t &fp_val) { ret_v = GetUint8ValByMan(s_ret, long_int_m, shift_out); } - ret = *(ge::PtrToPtr(&ret_v)); + ret = static_cast(*(ge::PtrToPtr(&ret_v))); return ret; } @@ -226,7 +228,7 @@ static int8_t Fp16ToInt8(const uint16_t &fp_val) { static uint8_t Fp16ToUInt8(const uint16_t &fp_val) { uint8_t m_ret = 0; // 1.get s_ret and shift it to bit0. - uint8_t s_ret = Fp16ExtracSign(fp_val); + uint8_t s_ret = static_cast(Fp16ExtracSign(fp_val)); // 2.get hf_e and hf_m uint16_t hf_e = Fp16ExtracExp(fp_val); uint16_t hf_m = Fp16ExtracMan(fp_val); @@ -258,7 +260,7 @@ static uint8_t Fp16ToUInt8(const uint16_t &fp_val) { } if (overflow_flag == 0U) { bool need_round = IsRoundOne(long_int_m, shift_out + kFp16ManLen); - m_ret = static_cast((long_int_m >> (kFp16ManLen + shift_out)) & kBitLen8Max); + m_ret = static_cast((long_int_m >> static_cast(kFp16ManLen + shift_out)) & kBitLen8Max); if (need_round && m_ret != kBitLen8Max) { m_ret++; } @@ -280,7 +282,7 @@ static uint8_t Fp16ToUInt8(const uint16_t &fp_val) { /// @return Return uint16 value of fp16_t object static uint16_t GetUint16ValByMan(uint16_t s_ret, const uint64_t &long_int_m, const uint16_t &shift_out) { bool need_round = IsRoundOne(long_int_m, shift_out + kFp16ManLen); - auto m_ret = static_cast((long_int_m >> (kFp16ManLen + shift_out)) & kBitLen16Max); + auto m_ret = static_cast((long_int_m >> static_cast(kFp16ManLen + shift_out)) & kBitLen16Max); if (need_round && m_ret < kInt16Max) { m_ret++; } @@ -343,7 +345,7 @@ static int16_t Fp16ToInt16(const uint16_t &fp_val) { // Generate final result ret_v = GetUint16ValByMan(s_ret, long_int_m, shift_out); } - ret = *(ge::PtrToPtr(&ret_v)); + ret = static_cast(*(ge::PtrToPtr(&ret_v))); return ret; } @@ -378,7 +380,7 @@ static uint16_t Fp16ToUInt16(const uint16_t &fp_val) { } } bool need_round = IsRoundOne(long_int_m, shift_out + kFp16ManLen); - m_ret = static_cast((long_int_m >> (kFp16ManLen + shift_out)) & kBitLen16Max); + m_ret = static_cast((long_int_m >> static_cast(kFp16ManLen + shift_out)) & kBitLen16Max); if (need_round && m_ret != kBitLen16Max) { m_ret++; } @@ -419,7 +421,7 @@ static int32_t Fp16ToInt32(const uint16_t &fp_val) { } } bool need_round = IsRoundOne(long_int_m, shift_out + kFp16ManLen); - auto m_ret = static_cast((long_int_m >> (kFp16ManLen + shift_out)) & kBitLen32Max); + auto m_ret = static_cast((long_int_m >> static_cast(kFp16ManLen + shift_out)) & kBitLen32Max); if (need_round && m_ret < kInt32Max) { m_ret++; } @@ -434,7 +436,7 @@ static int32_t Fp16ToInt32(const uint16_t &fp_val) { ret_v = (s_ret << static_cast(kBitShift31)) | (m_ret); } - return *(ge::PtrToPtr(&ret_v)); + return static_cast(*(ge::PtrToPtr(&ret_v))); } /// @ingroup fp16_t math conversion static method @@ -468,7 +470,7 @@ static uint32_t Fp16ToUInt32(const uint16_t &fp_val) { } } bool need_round = IsRoundOne(long_int_m, shift_out + kFp16ManLen); - m_ret = static_cast(long_int_m >> (kFp16ManLen + shift_out)) & kBitLen32Max; + m_ret = static_cast(long_int_m >> static_cast(kFp16ManLen + shift_out)) & kBitLen32Max; if (need_round && m_ret != kBitLen32Max) { m_ret++; } @@ -483,10 +485,10 @@ static uint32_t Fp16ToUInt32(const uint16_t &fp_val) { static uint16_t Fp16AddCalVal(uint16_t s_ret, int16_t e_ret, uint16_t m_ret, uint32_t m_trunc, uint16_t shift_out) { uint16_t m_min = kFp16ManHideBit << shift_out; - uint16_t m_max = m_min << 1; + uint16_t m_max = static_cast(m_min << 1U); // Denormal while (m_ret < m_min && e_ret > 0) { // the value of m_ret should not be smaller than 2^23 - m_ret = m_ret << 1; + m_ret = static_cast(m_ret << 1U); m_ret += (kFp32SignMask & m_trunc) >> kFp32SignIndex; m_trunc = m_trunc << 1; e_ret = e_ret - 1; @@ -560,12 +562,12 @@ static uint16_t Fp16Add(uint16_t v_1, uint16_t v_2) { uint32_t m_trunc = 0; int16_t e_ret = std::max(e_a, e_b); - int16_t e_tmp = std::abs(e_a - e_b); + int16_t e_tmp = static_cast(std::abs(e_a - e_b)); if (e_a > e_b) { - m_trunc = (m_b << (static_cast(kBitShift32) - static_cast(e_tmp))); + m_trunc = (m_b << static_cast(static_cast(kBitShift32) - static_cast(e_tmp))); m_b = RightShift(m_b, e_tmp); } else if (e_a < e_b) { - m_trunc = (m_a << (static_cast(kBitShift32) - static_cast(e_tmp))); + m_trunc = (m_a << static_cast(static_cast(kBitShift32) - static_cast(e_tmp))); m_a = RightShift(m_a, e_tmp); } // calculate mantissav @@ -690,7 +692,7 @@ static uint16_t Fp16Div(uint16_t v_1, uint16_t v_2) { m_b = m_tmp; } m_div = static_cast(m_a * 1.0f / m_b); - fp16_t fp_div = m_div; + fp16_t fp_div = static_cast(m_div); ret = fp_div.val; if (s_a != s_b) { ret |= kFp16SignMask; @@ -917,7 +919,7 @@ fp16_t &fp16_t::operator=(const int8_t &i_val) { e_ret = kFp16ManLen; while ((m_ret & kFp16ManHideBit) == 0) { - m_ret = m_ret << 1; + m_ret = static_cast(m_ret << 1U); e_ret = e_ret - 1U; } e_ret = e_ret + kFp16ExpBias; @@ -935,7 +937,7 @@ fp16_t &fp16_t::operator=(const uint8_t &ui_val) { if (static_cast(m_ret)) { e_ret = kFp16ManLen; while ((m_ret & kFp16ManHideBit) == 0) { - m_ret = m_ret << 1; + m_ret = static_cast(m_ret << 1U); e_ret = e_ret - 1U; } e_ret = e_ret + kFp16ExpBias; @@ -948,18 +950,18 @@ fp16_t &fp16_t::operator=(const uint8_t &ui_val) { static void SetValByUint16Val(const uint16_t &input_val, const uint16_t &sign, uint16_t &ret_val) { uint32_t m_tmp = (input_val & kFp32AbsMax); uint16_t m_min = kFp16ManHideBit; - uint16_t m_max = m_min << 1; + uint16_t m_max = static_cast(m_min << 1U); uint16_t len = static_cast(GetManBitLength(m_tmp)); if (static_cast(m_tmp)) { int16_t e_ret; if (len > static_cast(kDim11)) { e_ret = kFp16ExpBias + kFp16ManLen; - uint16_t e_tmp = len - static_cast(kDim11); + uint16_t e_tmp = static_cast(len - static_cast(kDim11)); uint32_t trunc_mask = 1; for (int i = 1; i < e_tmp; i++) { trunc_mask = (trunc_mask << 1) + 1; } - uint32_t m_trunc = (m_tmp & trunc_mask) << (static_cast(kBitShift32) - e_tmp); + uint32_t m_trunc = (m_tmp & trunc_mask) << static_cast(static_cast(kBitShift32) - e_tmp); for (int i = 0; i < e_tmp; i++) { m_tmp = (m_tmp >> 1); e_ret = e_ret + 1; @@ -978,8 +980,8 @@ static void SetValByUint16Val(const uint16_t &input_val, const uint16_t &sign, u } } else { e_ret = static_cast(kFp16ExpBias); - m_tmp = m_tmp << (kManBitLength - len); - e_ret = e_ret + (len - 1); + m_tmp = m_tmp << static_cast(kManBitLength - len); + e_ret = e_ret + static_cast(len - 1); } auto m_ret = static_cast(m_tmp); ret_val = Fp16Constructor(sign, static_cast(e_ret), m_ret); @@ -990,7 +992,7 @@ fp16_t &fp16_t::operator=(const int16_t &i_val) { if (i_val == 0) { val = 0; } else { - uint16_t ui_val = *(ge::PtrToPtr(&i_val)); + uint16_t ui_val = static_cast(*(ge::PtrToPtr(&i_val))); auto s_ret = static_cast(ui_val >> static_cast(kBitShift15)); if (static_cast(s_ret)) { int16_t iValM = -i_val; @@ -1008,17 +1010,17 @@ fp16_t &fp16_t::operator=(const uint16_t &ui_val) { int16_t e_ret; uint16_t m_ret = ui_val; uint16_t m_min = kFp16ManHideBit; - uint16_t m_max = m_min << 1; + uint16_t m_max = static_cast(m_min << 1U); uint16_t len = static_cast(GetManBitLength(m_ret)); if (len > kManBitLength) { e_ret = kFp16ExpBias + kFp16ManLen; uint32_t m_trunc; uint32_t trunc_mask = 1; - uint16_t e_tmp = len - kManBitLength; + uint16_t e_tmp = static_cast(len - kManBitLength); for (int i = 1; i < e_tmp; i++) { trunc_mask = (trunc_mask << 1) + 1; } - m_trunc = (m_ret & trunc_mask) << (static_cast(kBitShift32) - e_tmp); + m_trunc = (m_ret & trunc_mask) << static_cast(static_cast(kBitShift32) - e_tmp); for (int i = 0; i < e_tmp; i++) { m_ret = (m_ret >> 1); e_ret = e_ret + 1; @@ -1040,8 +1042,8 @@ fp16_t &fp16_t::operator=(const uint16_t &ui_val) { } } else { e_ret = static_cast(kFp16ExpBias); - m_ret = m_ret << (static_cast(kDim11) - len); - e_ret = e_ret + (len - 1); + m_ret = m_ret << static_cast(static_cast(kDim11) - len); + e_ret = static_cast(e_ret + (len - 1)); } val = Fp16Constructor(0u, static_cast(e_ret), m_ret); } @@ -1054,15 +1056,15 @@ static void SetValByUint32Val(const uint32_t &input_val, const uint16_t &sign, u uint32_t m_min = kFp16ManHideBit; uint32_t m_max = m_min << 1; uint16_t len = static_cast(GetManBitLength(m_tmp)); - if (len > kDim11) { + if (len > static_cast(kDim11)) { e_ret = kFp16ExpBias + kFp16ManLen; uint32_t m_trunc = 0; uint32_t trunc_mask = 1; - uint16_t e_tmp = len - static_cast(kDim11); + uint16_t e_tmp = static_cast(len - static_cast(kDim11)); for (int i = 1; i < e_tmp; i++) { trunc_mask = (trunc_mask << 1) + 1; } - m_trunc = (m_tmp & trunc_mask) << (static_cast(kBitShift32) - e_tmp); + m_trunc = (m_tmp & trunc_mask) << static_cast(static_cast(kBitShift32) - e_tmp); for (int i = 0; i < e_tmp; i++) { m_tmp = (m_tmp >> 1); e_ret = e_ret + 1; @@ -1085,8 +1087,8 @@ static void SetValByUint32Val(const uint32_t &input_val, const uint16_t &sign, u } } else { e_ret = static_cast(kFp16ExpBias); - m_tmp = m_tmp << (static_cast(kDim11) - len); - e_ret = e_ret + (len - 1); + m_tmp = m_tmp << static_cast(static_cast(kDim11) - len); + e_ret = e_ret + static_cast(len - 1); } auto m_ret = static_cast(m_tmp); ret_val = Fp16Constructor(sign, static_cast(e_ret), m_ret); @@ -1116,11 +1118,11 @@ fp16_t &fp16_t::operator=(const uint32_t &ui_val) { uint32_t m_min = kFp16ManHideBit; uint32_t m_max = m_min << 1; uint16_t len = static_cast(GetManBitLength(m_tmp)); - if (len > kDim11) { + if (len > static_cast(kDim11)) { e_ret = kFp16ExpBias + kFp16ManLen; uint32_t m_trunc = 0; uint32_t trunc_mask = 1; - uint16_t e_tmp = len - static_cast(kDim11); + uint16_t e_tmp = static_cast(len - static_cast(kDim11)); for (int i = 1; i < e_tmp; i++) { trunc_mask = (trunc_mask << 1) + 1; } @@ -1147,8 +1149,8 @@ fp16_t &fp16_t::operator=(const uint32_t &ui_val) { } } else { e_ret = static_cast(kFp16ExpBias); - m_tmp = m_tmp << (static_cast(kDim11) - len); - e_ret = e_ret + (len - 1); + m_tmp = m_tmp << static_cast(static_cast(kDim11) - len); + e_ret = static_cast(e_ret + (len - 1)); } auto m_ret = static_cast(m_tmp); val = Fp16Constructor(0u, static_cast(e_ret), m_ret); @@ -1200,7 +1202,7 @@ fp16_t &fp16_t::operator=(const double &d_val) { } else { // Regular case with no overflow or underflow e_ret = static_cast(e_d - 0x3F0u); - need_round = IsRoundOne(m_d, m_len_delta); + need_round = IsRoundOne(m_d, static_cast(m_len_delta)); m_ret = static_cast(m_d >> m_len_delta); if (need_round) { m_ret++; diff --git a/parser/common/parser_fp16_t.h b/parser/common/parser_fp16_t.h index 2f970b9..6b2ab3d 100644 --- a/parser/common/parser_fp16_t.h +++ b/parser/common/parser_fp16_t.h @@ -169,7 +169,7 @@ inline bool Fp16IsInf(const uint16_t x) { /// @ingroup fp16 special value judgment /// @brief whether a fp16 is NaN inline bool Fp16IsNan(const uint16_t x) { - return ((((x) & kFp16ExpMask) == kFp16ExpMask) && ((x) & kFp16ManMask)); + return ((((x) & kFp16ExpMask) == kFp16ExpMask) && (((x) & kFp16ManMask) != 0U)); } /// @ingroup fp16 special value judgment /// @brief whether a fp16 is invalid @@ -211,38 +211,38 @@ constexpr uint32_t kFp32MaxExp = 0xFFU; constexpr uint32_t kFp32MaxMan = 0x7FFFFFU; /// @ingroup fp32 special value judgment /// @brief whether a fp32 is NaN -inline bool Fp32IsNan(const uint16_t x) { - return ((((x) & kFp32ExpMask) == kFp32ExpMask) && ((x) & kFp32ManMask)); +inline bool Fp32IsNan(const uint32_t x) { + return ((((x) & kFp32ExpMask) == kFp32ExpMask) && (((x) & kFp32ManMask) != 0U)); } /// @ingroup fp32 special value judgment /// @brief whether a fp32 is infinite -inline bool Fp32IsInf(const uint16_t x) { - return ((((x) & kFp32ExpMask) == kFp32ExpMask) && (!((x) & kFp32ManMask))); +inline bool Fp32IsInf(const uint32_t x) { + return ((((x) & kFp32ExpMask) == kFp32ExpMask) && (((x) & kFp32ManMask) == 0U)); } /// @ingroup fp32 special value judgment /// @brief whether a fp32 is a denormalized value -inline bool Fp32IsDenorm(const uint16_t x) { - return ((((x)&kFp32ExpMask) == 0)); +inline bool Fp32IsDenorm(const uint32_t x) { + return ((((x)&kFp32ExpMask) == 0)); } /// @ingroup fp32 basic operator /// @brief get sign of fp32 -inline bool Fp32ExtracSign(const uint16_t x) { - return (((x) >> kFp32SignIndex) & 1); +inline uint32_t Fp32ExtracSign(const uint16_t x) { + return (((x) >> kFp32SignIndex) & 1U); } /// @ingroup fp32 basic operator /// @brief get exponent of fp16 -inline bool Fp32ExtracExp(const uint16_t x) { - return (((x)&kFp32ExpMask) >> kFp32ManLen); +inline uint32_t Fp32ExtracExp(const uint32_t x) { + return (((x)&kFp32ExpMask) >> kFp32ManLen); } /// @ingroup fp32 basic operator /// @brief get mantissa of fp16 -inline uint16_t Fp32ExtracMan(const uint16_t x) { - return (((x)&kFp32ManMask) | (((((x) >> kFp32ManLen) & kFp32MaxExp) > 0 ? 1 : 0) * kFp32ManHideBit)); +inline uint32_t Fp32ExtracMan(const uint32_t x) { + return (((x)&kFp32ManMask) | (((((x) >> kFp32ManLen) & kFp32MaxExp) > 0 ? 1 : 0) * kFp32ManHideBit)); } /// @ingroup fp32 basic operator /// @brief constructor of fp32 from sign exponent and mantissa -inline uint16_t Fp32Constructor(const uint16_t s, const uint16_t e, const uint16_t m) { - return (((s) << kFp32SignIndex) | ((e) << kFp32ManLen) | ((m) & kFp32MaxMan)); +inline uint32_t Fp32Constructor(const uint32_t s, const uint32_t e, const uint32_t m) { + return (((s) << kFp32SignIndex) | ((e) << kFp32ManLen) | ((m) & kFp32MaxMan)); } /// @ingroup fp64 basic parameter /// @brief fp64 exponent bias @@ -279,13 +279,13 @@ constexpr uint64_t kFp64MaxExp = 0x07FF; constexpr uint64_t kFp64MaxMan = 0xFFFFFFFFFFFLLu; /// @ingroup fp64 special value judgment /// @brief whether a fp64 is NaN -inline bool Fp64IsNan(const uint16_t x) { - return ((((x) & kFp64ExpMask) == kFp64ExpMask) && ((x) & kFp64ManMask)); +inline bool Fp64IsNan(const uint64_t x) { + return ((((x) & kFp64ExpMask) == kFp64ExpMask) && (((x) & kFp64ManMask) != 0ULL)); } /// @ingroup fp64 special value judgment /// @brief whether a fp64 is infinite -inline bool Fp64IsInf(const uint16_t x) { - return ((((x) & kFp64ExpMask) == kFp64ExpMask) && (!((x) & kFp64ManMask))); +inline bool Fp64IsInf(const uint64_t x) { + return ((((x) & kFp64ExpMask) == kFp64ExpMask) && (((x) & kFp64ManMask) == 0ULL)); } /// @ingroup integer special value judgment /// @brief maximum positive value of int8_t (0111 1111) diff --git a/parser/common/thread_pool.h b/parser/common/thread_pool.h index 96a9cfd..8baf7d9 100644 --- a/parser/common/thread_pool.h +++ b/parser/common/thread_pool.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/onnx/onnx_constant_parser.cc b/parser/onnx/onnx_constant_parser.cc index 06ba0bf..06c6041 100644 --- a/parser/onnx/onnx_constant_parser.cc +++ b/parser/onnx/onnx_constant_parser.cc @@ -1,5 +1,5 @@ /** - * Copyright (c) Huawei Technologies Co., Ltd. 2020~2022. All rights reserved. + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/onnx/onnx_constant_parser.h b/parser/onnx/onnx_constant_parser.h index 628e832..1345783 100644 --- a/parser/onnx/onnx_constant_parser.h +++ b/parser/onnx/onnx_constant_parser.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/onnx/onnx_custom_parser_adapter.cc b/parser/onnx/onnx_custom_parser_adapter.cc index d634daf..b6d000b 100644 --- a/parser/onnx/onnx_custom_parser_adapter.cc +++ b/parser/onnx/onnx_custom_parser_adapter.cc @@ -1,5 +1,5 @@ /** - * Copyright (c) Huawei Technologies Co., Ltd. 2020~2022. All rights reserved. + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/onnx/onnx_custom_parser_adapter.h b/parser/onnx/onnx_custom_parser_adapter.h index e22dda7..0dfdf82 100644 --- a/parser/onnx/onnx_custom_parser_adapter.h +++ b/parser/onnx/onnx_custom_parser_adapter.h @@ -1,5 +1,5 @@ /** - * Copyright (c) Huawei Technologies Co., Ltd. 2020~2022. All rights reserved. + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/onnx/onnx_data_parser.cc b/parser/onnx/onnx_data_parser.cc index 927e618..6483a4d 100644 --- a/parser/onnx/onnx_data_parser.cc +++ b/parser/onnx/onnx_data_parser.cc @@ -1,5 +1,5 @@ /** - * Copyright (c) Huawei Technologies Co., Ltd. 2020~2022. All rights reserved. + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/onnx/onnx_data_parser.h b/parser/onnx/onnx_data_parser.h index 4d51e2f..8503779 100644 --- a/parser/onnx/onnx_data_parser.h +++ b/parser/onnx/onnx_data_parser.h @@ -1,5 +1,5 @@ /** - * Copyright (c) Huawei Technologies Co., Ltd. 2020~2022. All rights reserved. + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/onnx/onnx_file_constant_parser.cc b/parser/onnx/onnx_file_constant_parser.cc index 1b6717d..36abbbe 100644 --- a/parser/onnx/onnx_file_constant_parser.cc +++ b/parser/onnx/onnx_file_constant_parser.cc @@ -1,5 +1,5 @@ /** - * Copyright (c) Huawei Technologies Co., Ltd. 2020~2022. All rights reserved. + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ const char *const kFileConstant = "FileConstant"; namespace ge { Status OnnxFileConstantParser::ParseParams(const Message *op_src, ge::Operator &op_def) { GE_CHECK_NOTNULL(op_src); - const ge::onnx::NodeProto *node = reinterpret_cast(op_src); + const ge::onnx::NodeProto *node = PtrToPtr(op_src); GELOGD("Onnx op node name = %s, op type= %s, parse params", node->name().c_str(), node->op_type().c_str()); ge::onnx::TensorProto tensor_proto; diff --git a/parser/onnx/onnx_file_constant_parser.h b/parser/onnx/onnx_file_constant_parser.h index 0c523c5..a0ff9b4 100644 --- a/parser/onnx/onnx_file_constant_parser.h +++ b/parser/onnx/onnx_file_constant_parser.h @@ -1,5 +1,5 @@ /** - * Copyright (c) Huawei Technologies Co., Ltd. 2020~2022. All rights reserved. + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/onnx/onnx_op_parser.h b/parser/onnx/onnx_op_parser.h index 2ab3c38..fa54a4f 100644 --- a/parser/onnx/onnx_op_parser.h +++ b/parser/onnx/onnx_op_parser.h @@ -1,5 +1,5 @@ /** - * Copyright (c) Huawei Technologies Co., Ltd. 2020~2022. All rights reserved. + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/st/CMakeLists.txt b/tests/st/CMakeLists.txt index 1acc4ed..0cf2fdd 100644 --- a/tests/st/CMakeLists.txt +++ b/tests/st/CMakeLists.txt @@ -274,7 +274,7 @@ set(PARSER_SRC_FILES "${PARSER_DIR}/parser/common/pre_checker.cc" "${PARSER_DIR}/parser/common/proto_file_parser.cc" "${PARSER_DIR}/parser/common/prototype_pass_manager.cc" - "${PARSER_DIR}/parser/common/register_tbe.cc" + "${PARSER_DIR}/parser/common/op_registration_tbe.cc" "${PARSER_DIR}/parser/common/tbe_plugin_loader.cc" "${PARSER_DIR}/parser/common/thread_pool.cc" "${PARSER_DIR}/parser/common/auto_mapping_subgraph_io_index_func.cc" diff --git a/tests/st/testcase/test_caffe_parser.cc b/tests/st/testcase/test_caffe_parser.cc index 45fc70c..fe5ecf9 100644 --- a/tests/st/testcase/test_caffe_parser.cc +++ b/tests/st/testcase/test_caffe_parser.cc @@ -21,7 +21,7 @@ #include "parser/common/op_parser_factory.h" #include "graph/operator_reg.h" #include "register/op_registry.h" -#include "parser/common/register_tbe.h" +#include "parser/common/op_registration_tbe.h" #include "framework/omg/parser/model_parser.h" #include "framework/omg/parser/parser_factory.h" #include "external/parser/caffe_parser.h" diff --git a/tests/st/testcase/test_onnx_parser.cc b/tests/st/testcase/test_onnx_parser.cc index 799f2d6..05b4207 100644 --- a/tests/st/testcase/test_onnx_parser.cc +++ b/tests/st/testcase/test_onnx_parser.cc @@ -19,7 +19,7 @@ #include "parser/common/op_parser_factory.h" #include "graph/operator_reg.h" #include "register/op_registry.h" -#include "parser/common/register_tbe.h" +#include "parser/common/op_registration_tbe.h" #include "external/parser/onnx_parser.h" #include "st/parser_st_utils.h" #include "external/ge/ge_api_types.h" diff --git a/tests/st/testcase/test_tensorflow_parser.cc b/tests/st/testcase/test_tensorflow_parser.cc index ac6c275..0db72f5 100644 --- a/tests/st/testcase/test_tensorflow_parser.cc +++ b/tests/st/testcase/test_tensorflow_parser.cc @@ -23,7 +23,6 @@ #include "graph/operator_reg.h" #include "register/op_registry.h" #include "external/register/register.h" -#include "parser/common/register_tbe.h" #include "st/parser_st_utils.h" #include "tests/depends/ops_stub/ops_stub.h" #include "parser/common/acl_graph_parser_util.h" @@ -68,7 +67,7 @@ #include "parser/common/parser_fp16_t.h" #include "parser/common/op_parser_factory.h" #include "parser/common/prototype_pass_manager.h" -#include "parser/common/register_tbe.h" +#include "parser/common/op_registration_tbe.h" #include "parser/common/pass_manager.h" #include "parser/tensorflow/parser_graph_optimizer.h" #include "metadef/inc/register/scope/scope_pass_registry_impl.h" diff --git a/tests/ut/parser/CMakeLists.txt b/tests/ut/parser/CMakeLists.txt index 8b44a0a..2826196 100644 --- a/tests/ut/parser/CMakeLists.txt +++ b/tests/ut/parser/CMakeLists.txt @@ -275,7 +275,7 @@ set(PARSER_SRC_FILES "${PARSER_DIR}/parser/common/pre_checker.cc" "${PARSER_DIR}/parser/common/proto_file_parser.cc" "${PARSER_DIR}/parser/common/prototype_pass_manager.cc" - "${PARSER_DIR}/parser/common/register_tbe.cc" + "${PARSER_DIR}/parser/common/op_registration_tbe.cc" "${PARSER_DIR}/parser/common/tbe_plugin_loader.cc" "${PARSER_DIR}/parser/common/thread_pool.cc" "${PARSER_DIR}/parser/common/auto_mapping_subgraph_io_index_func.cc" diff --git a/tests/ut/parser/testcase/caffe_parser_testcase/caffe_parser_unittest.cc b/tests/ut/parser/testcase/caffe_parser_testcase/caffe_parser_unittest.cc index 5d1a5bd..53e5cf9 100755 --- a/tests/ut/parser/testcase/caffe_parser_testcase/caffe_parser_unittest.cc +++ b/tests/ut/parser/testcase/caffe_parser_testcase/caffe_parser_unittest.cc @@ -23,7 +23,7 @@ #include "graph/operator_reg.h" #include "external/graph/types.h" #include "register/op_registry.h" -#include "parser/common/register_tbe.h" +#include "parser/common/op_registration_tbe.h" #include "framework/omg/parser/model_parser.h" #include "framework/omg/parser/parser_factory.h" #include "external/parser/caffe_parser.h" diff --git a/tests/ut/parser/testcase/common/acl_graph_parser_unittest.cc b/tests/ut/parser/testcase/common/acl_graph_parser_unittest.cc index e452661..50a787c 100755 --- a/tests/ut/parser/testcase/common/acl_graph_parser_unittest.cc +++ b/tests/ut/parser/testcase/common/acl_graph_parser_unittest.cc @@ -23,7 +23,7 @@ #include "graph/operator_reg.h" #include "external/graph/types.h" #include "register/op_registry.h" -#include "parser/common/register_tbe.h" +#include "parser/common/op_registration_tbe.h" #include "external/parser/onnx_parser.h" #include "ut/parser/parser_ut_utils.h" #include "external/ge/ge_api_types.h" diff --git a/tests/ut/parser/testcase/onnx_parser_testcase/onnx_parser_unittest.cc b/tests/ut/parser/testcase/onnx_parser_testcase/onnx_parser_unittest.cc index c945d69..b0338ce 100644 --- a/tests/ut/parser/testcase/onnx_parser_testcase/onnx_parser_unittest.cc +++ b/tests/ut/parser/testcase/onnx_parser_testcase/onnx_parser_unittest.cc @@ -20,7 +20,7 @@ #include "graph/operator_reg.h" #include "external/graph/types.h" #include "register/op_registry.h" -#include "parser/common/register_tbe.h" +#include "parser/common/op_registration_tbe.h" #include "external/parser/onnx_parser.h" #include "ut/parser/parser_ut_utils.h" #include "external/ge/ge_api_types.h" diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_auto_mapping_parser_adapter_unittest.cc b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_auto_mapping_parser_adapter_unittest.cc index ed6e274..b088603 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_auto_mapping_parser_adapter_unittest.cc +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_auto_mapping_parser_adapter_unittest.cc @@ -22,7 +22,7 @@ #include "graph/operator_reg.h" #include "external/graph/types.h" #include "register/op_registry.h" -#include "parser/common/register_tbe.h" +#include "parser/common/op_registration_tbe.h" namespace ge { diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc index 549ea61..8e4ccab 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc @@ -25,7 +25,6 @@ #include "external/graph/types.h" #include "register/op_registry.h" #include "external/register/register.h" -#include "parser/common/register_tbe.h" #include "tests/depends/ops_stub/ops_stub.h" #include "parser/common/acl_graph_parser_util.h" #include "metadef/third_party/graphengine/inc/external/ge/ge_api_types.h" @@ -71,7 +70,7 @@ #include "parser/common/parser_fp16_t.h" #include "parser/common/op_parser_factory.h" #include "parser/common/prototype_pass_manager.h" -#include "parser/common/register_tbe.h" +#include "parser/common/op_registration_tbe.h" #include "parser/common/pass_manager.h" #include "parser/tensorflow/parser_graph_optimizer.h" #include "metadef/inc/register/scope/scope_pass_registry_impl.h"