[CPU:Bugfix] supplement missing headfile, and fix a bug in MNNLineDep… - #4454
[CPU:Bugfix] supplement missing headfile, and fix a bug in MNNLineDep…#4454Sherlockzhangjinge wants to merge 2 commits into
Conversation
…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
left a comment
There was a problem hiding this comment.
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++ 模拟验证两个错误:
error: cannot initialize a variable of type 'const float *' with an lvalue of type 'const int32_t *const'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>
|
Hi @Sherlockzhangjinge, the bugfix looks correct — especially the |
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
Checklist
[Module:Type] Descriptionformat