Skip to content

[CPU:Bugfix] supplement missing headfile, and fix a bug in MNNLineDep… - #4454

Closed
Sherlockzhangjinge wants to merge 2 commits into
alibaba:masterfrom
Sherlockzhangjinge:RVV/Bugfix
Closed

[CPU:Bugfix] supplement missing headfile, and fix a bug in MNNLineDep…#4454
Sherlockzhangjinge wants to merge 2 commits into
alibaba:masterfrom
Sherlockzhangjinge:RVV/Bugfix

Conversation

@Sherlockzhangjinge

Copy link
Copy Markdown
Contributor

Description

Fix the bugs below:
ssize_t has not been declared:
source/backend/cpu/riscv/rvv/MNNFloat2Int8.cpp
source/backend/cpu/riscv/rvv/MNNInt8ScaleToFloat.cpp
source/backend/cpu/riscv/rvv/MNNAvgPoolInt8.cpp
不能在初始化时将 const int32_t* const 转换为 const float* :
source/backend/cpu/riscv/rvv/MNNLineDepthWiseInt8AddBiasScaleUnit.cpp

Module

CPU

Type

  • Feature
  • Bugfix
  • Perf
  • Refact
  • Style
  • Doc
  • Test
  • Chore

Checklist

  • Commit message follows [Module:Type] Description format
  • Code compiles without errors
  • Tested on relevant platform(s)
  • No unrelated format or style changes included

…thWiseInt8AddBiasScaleUnit which causse the error below:

不能在初始化时将 const int32_t* const 转换为 const float*

Signed-off-by: Jixingguang <1955992348@qq.com>

Signed-off-by: Sherlockzhangjinge <zjgzhangjinge@outlook.com>

Signed-off-by: lyd1992 <liuyudong@iscas.ac.cn>
@wangzhaode wangzhaode self-assigned this May 18, 2026

@wangzhaode wangzhaode left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

感谢提交!头文件补充的修复是正确的,但 MNNLineDepthWiseInt8AddBiasScaleUnit.cpp 的修复存在未解决的编译错误

问题

MNNLineDepthWiseInt8AddBiasScaleUnit.cpp 第 24 行:

const float* bias_z = parameters->bias;

parameters->bias 的类型是 const int32_t*(见 QuanPostTreatParameters 结构体定义),C++ 中不允许从 const int32_t* 隐式转换为 const float*此行会编译失败

同时,修改后的第 59 行:

vint32m4_t vec_bias_int = __riscv_vle32_v_i32m4(bias_z, vl);

__riscv_vle32_v_i32m4 期望第一个参数为 const int32_t*,传入 const float* 类型的 bias_z 同样会导致类型不匹配错误。

建议修复

将第 24 行改为:

const int32_t* bias_z = parameters->bias;

同时建议删除注释掉的旧代码(第 58 行),git history 已经保留了记录:

-        // vfloat32m4_t vec_bias = __riscv_vle32_v_f32m4(bias_z, vl);

验证

已通过 clang++ 模拟验证两个错误:

  1. error: cannot initialize a variable of type 'const float *' with an lvalue of type 'const int32_t *const'
  2. error: no known conversion from 'const float *' to 'const int32_t *' for 1st argument

Signed-off-by: Jixingguang <1955992348@qq.com>

Signed-off-by: Sherlockzhangjinge <zjgzhangjinge@outlook.com>

Signed-off-by: lyd1992 <liuyudong@iscas.ac.cn>
@wangzhaode

Copy link
Copy Markdown
Collaborator

Hi @Sherlockzhangjinge, the bugfix looks correct — especially the bias_z type change from float* to int32_t* with explicit vfcvt_f_x_v_f32m4 conversion, which is more accurate than the current cast in master. However, this PR now has merge conflicts because some of the header file fixes were already merged via #4359. Could you please rebase onto the latest master? The conflict should be straightforward — just keep both #include <sys/types.h> (from master) and your #include "Int8FunctionsOpt.h". The bias_z fix still has independent value. Thanks!

@wangzhaode wangzhaode added awaiting contributor Waiting for contributor to address review comments or rebase needs rebase PR has merge conflicts, needs rebase to latest master labels Jun 11, 2026
@wangzhaode wangzhaode closed this Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting contributor Waiting for contributor to address review comments or rebase needs rebase PR has merge conflicts, needs rebase to latest master

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants