已关闭
[Bug-Report|缺陷反馈]: [AI 识别] tests/ut/common/tiling_context_faker.cpp 缺少 #include <algorithm> 头文件 #2696
StoneChan_创建于 5月14日关闭于 5月15日
5月14日 添加了label:bug-report
5月14日 修改了issue 的描述
5月14日 关联了pull request:修复 gcc14 时仓内find函数编译报错的问题
5月15日 关闭了 issue
5月15日 添加了label:resolved
Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.
Describe the current behavior / 问题描述
项目测试代码存在编译错误,
tests/ut/common/tiling_context_faker.cpp文件使用了std::find函数但缺少#include <algorithm>头文件,导致无法编译运行完整的单元测试套件。具体问题:
tests/ut/common/tiling_context_faker.cppstd::find但未包含<algorithm>头文件Environment / 环境信息
软件环境:
硬件环境:
问题环境:
Steps to reproduce the issue / 重现步骤
cd /mnt/workspace/gitCode/CANN/ops-nncat tests/ut/common/tiling_context_faker.cpp | grep -n "std::find"std::find:bool inputPacked = std::find(inputInstanceNum_.begin(), inputInstanceNum_.end(), 0) != inputInstanceNum_.end();cat tests/ut/common/tiling_context_faker.cpp | head -20tiling_context_faker.h,缺少<algorithm>头文件#include <vector> int main() { std::vector<int> vec = {1, 2, 3, 0, 4}; bool found = std::find(vec.begin(), vec.end(), 0) != vec.end(); return found ? 0 : 1; }g++ test.cpp -o testerror: 'find' is not a member of 'std'Describe the expected behavior / 预期结果
修复建议:在
tests/ut/common/tiling_context_faker.cpp文件开头添加缺失的头文件:#include "tiling_context_faker.h" #include <algorithm> // 提供 std::find 的定义预期结果:
Related log / screenshot / 日志 / 截图
问题文件列表:
编译错误信息:
问题代码片段:
// 文件: tests/ut/common/tiling_context_faker.cpp // 第301行 bool inputPacked = std::find(inputInstanceNum_.begin(), inputInstanceNum_.end(), 0) != inputInstanceNum_.end();当前头文件包含:
// 文件开头仅有: #include "tiling_context_faker.h"修复后头文件包含:
#include "tiling_context_faker.h" #include <algorithm> // 提供 std::find 的定义Special notes for this issue / 备注
影响范围:
技术说明:
std::find是 C++ 标准库<algorithm>头文件中定义的算法函数,用于在容器中查找指定元素。使用该函数时必须包含相应的头文件,否则会导致编译失败。验证结果:
#include <algorithm>后编译成功提交地址: https://gitcode.com/cann/ops-nn/issues/new
Issue 文件: issue.md