| @@ -304,7 +304,8 @@ bool CheckIsUnknownDimNum(const gert::Shape& shape) |
| return shape.GetDimNum() == 1 && shape.GetDim(0) == UNKNOWN_DIM_NUM; | return shape.GetDimNum() == 1 && shape.GetDim(0) == UNKNOWN_DIM_NUM; |
| } | } |
| | |
| -bool CalculateTransX2Float(const gert::InferShapeContext* context, const Shape& shape_x2, bool trans_x1, bool trans_x2) | +static bool CalculateTransX2Float( |
| + const gert::InferShapeContext* context, const Shape& shape_x2, bool trans_x1, bool trans_x2) |
| { | { |
| auto shape_x1 = context->GetInputShape(0); | auto shape_x1 = context->GetInputShape(0); |
| auto x1_dim_num = shape_x1->GetDimNum(); | auto x1_dim_num = shape_x1->GetDimNum(); |
| @@ -317,7 +318,7 @@ bool CalculateTransX2Float(const gert::InferShapeContext* context, const Shape& |
| return false; | return false; |
| } | } |
| | |
| -ge::graphStatus UpdateX2NewShape( | +static ge::graphStatus UpdateX2NewShape( |
| const gert::InferShapeContext* context, Shape& new_shape, bool& reshape_flag, bool trans_x1, bool trans_x2, | const gert::InferShapeContext* context, Shape& new_shape, bool& reshape_flag, bool trans_x1, bool trans_x2, |
| const bool is_packed) | const bool is_packed) |
| { | { |
| @@ -423,7 +424,7 @@ ge::graphStatus InferShapeForBatchMatMul( |
| constexpr int64_t INFINITE_RANGE = -1; | constexpr int64_t INFINITE_RANGE = -1; |
| constexpr int64_t NORMALIZE_INFINITE_RANGE = std::numeric_limits<int64_t>::max(); | constexpr int64_t NORMALIZE_INFINITE_RANGE = std::numeric_limits<int64_t>::max(); |
| static const std::pair<int64_t, int64_t> NORMALIZE_FULL_RANGE = {0, NORMALIZE_INFINITE_RANGE}; | static const std::pair<int64_t, int64_t> NORMALIZE_FULL_RANGE = {0, NORMALIZE_INFINITE_RANGE}; |
| -bool InitializeRange( | +static bool InitializeRange( |
| size_t num, const std::vector<std::pair<int64_t, int64_t>>& range, | size_t num, const std::vector<std::pair<int64_t, int64_t>>& range, |
| std::vector<std::pair<int64_t, int64_t>>& new_range) | std::vector<std::pair<int64_t, int64_t>>& new_range) |
| { | { |
| @@ -451,7 +452,7 @@ bool InitializeRange( |
| return true; | return true; |
| } | } |
| | |
| -bool GetBatchIntersection( | +static bool GetBatchIntersection( |
| const char* op_name, std::pair<int64_t, int64_t>& a, std::pair<int64_t, int64_t>& b, | const char* op_name, std::pair<int64_t, int64_t>& a, std::pair<int64_t, int64_t>& b, |
| std::pair<int64_t, int64_t>& out) | std::pair<int64_t, int64_t>& out) |
| { | { |
| @@ -484,7 +485,7 @@ bool GetBatchIntersection( |
| return true; | return true; |
| } | } |
| | |
| -bool GetKNIntersection( | +static bool GetKNIntersection( |
| const char* op_name, const std::pair<int64_t, int64_t>& a, const std::pair<int64_t, int64_t>& b, | const char* op_name, const std::pair<int64_t, int64_t>& a, const std::pair<int64_t, int64_t>& b, |
| std::pair<int64_t, int64_t>& out) | std::pair<int64_t, int64_t>& out) |
| { | { |
| @@ -501,7 +502,7 @@ bool GetKNIntersection( |
| return true; | return true; |
| } | } |
| | |
| -void ExpendOneDimRange( | +static void ExpendOneDimRange( |
| size_t num_dim_x1, size_t num_dim_x2, std::vector<std::pair<int64_t, int64_t>>& shape_range_x1, | size_t num_dim_x1, size_t num_dim_x2, std::vector<std::pair<int64_t, int64_t>>& shape_range_x1, |
| std::vector<std::pair<int64_t, int64_t>>& shape_range_x2) | std::vector<std::pair<int64_t, int64_t>>& shape_range_x2) |
| { | { |
| @@ -517,7 +518,7 @@ void ExpendOneDimRange( |
| } | } |
| } | } |
| | |
| -void ReduceOneDimRange( | +static void ReduceOneDimRange( |
| size_t num_dim_x1, size_t num_dim_x2, size_t& num_dim_out, | size_t num_dim_x1, size_t num_dim_x2, size_t& num_dim_out, |
| std::vector<std::pair<int64_t, int64_t>>& shape_range_out) | std::vector<std::pair<int64_t, int64_t>>& shape_range_out) |
| { | { |
| @@ -533,7 +534,7 @@ void ReduceOneDimRange( |
| } | } |
| } | } |
| | |
| -bool InferRangeBias( | +static bool InferRangeBias( |
| const char* op_name, std::vector<std::pair<int64_t, int64_t>>& new_shape_range_out, size_t idx_n, | const char* op_name, std::vector<std::pair<int64_t, int64_t>>& new_shape_range_out, size_t idx_n, |
| const gert::Range<gert::Shape>* bias_shape_range, | const gert::Range<gert::Shape>* bias_shape_range, |
| const std::vector<std::pair<int64_t, int64_t>>& new_shape_range_x2) | const std::vector<std::pair<int64_t, int64_t>>& new_shape_range_x2) |
| |
代码结构与可维护性: 循环变量类型与比较类型不匹配。在 for 循环中,变量 i 的类型为 size_t,而 tensor0Shape.GetDimNum() 的返回值类型未明确给出,但通常也应为 size_t 或 uint64_t 等无符号类型。然而,在循环体内,使用 i 作为参数调用 tensor0Shape.GetDim(i) 和 OP_LOGE 的格式化参数 %ld。%ld 是用于格式化 long int 类型的,而 size_t 在 64 位系统上通常是 unsigned long 或 unsigned long long,直接使用 %ld 可能导致格式化错误或数据截断。虽然代码逻辑上可能不会出错,但这种类型不匹配会影响代码的可移植性和健壮性。
问题类型: 代码结构与可维护性 文件路径:
matmul/batch_mat_mul_v3/op_host/op_api/aclnn_einsum.cpp行号: 102 问题代码:for (size_t i = 0; i < tensor0Shape.GetDimNum(); i++) { if (tensor0Shape.GetDim(i) == DIM_ZERO) { OP_LOGE(ACLNN_ERR_PARAM_INVALID, "tensor0 shape dim%ld [0] should not be zero", i); return ACLNN_ERR_PARAM_INVALID; } }修改建议:
此评论由代码审查工具自动生成