Open
docs: fix Tensor construction examples to compile #94
docs: fix Tensor construction examples to compile #94
Open
SuneeAdd on Oct 24
Sunee
SuneeCollaborators
Oct 24

描述

修复 docs/api 下 17 篇文档「使用示例」中 Tensor 构造的花括号初始化写法,该写法无法编译。

原示例形如:

Atvoss::Tensor<InputDtype> in1(deviceIn1, {{3, 4, 0, 0, 0, 0, 0, 0}}, 2);

include/utils/tensor.h 仅提供 Tensor(T*, uint64_t (&)[N])、Tensor(T*, uint64_t*, size_t)、Tensor(T*, int64_t*, size_t) 三个构造;三参数调用的第 2 个实参是花括号初始化列表,不能绑定到原始指针参数,g++ -std=c++17 报 no matching function for call。

修复方式(对齐 examples/rms_norm/rms_norm.cpp 的既有写法):每个示例先声明一次 uint64_t shapeArray[8] = {3, 4, 0, 0, 0, 0, 0, 0};,再以 (device, shapeArray, 2) 传入。shape 值与维数不变,未修改 Tensor 实现或构造签名。

涉及 17 篇文档、共 51 处:
ArgumentsBuilder_attr.md、ArgumentsBuilderImpl_build.md、ArgumentsBuilder_inputOutput.md、BlockBuilder.md、Compute.md、DefaultBlockConfig.md、DefaultBlockPolicy.md、DefaultBlockSchedule.md、DefaultKernelConfig.md、DefaultKernelPolicy.md、DefaultKernelSchedule.md、DeviceAdapter.md、DeviceAdapter_Run.md、KernelBuilder.md、ParamUsage.md、PlaceHolder.md、PlaceHolderTmpLike.md。

关联的Issue

Fixes #60

测试

  • 最小复现:文档原写法 Tensor<float> in1(dev, {{3, 4, 0, 0, 0, 0, 0, 0}}, 2),g++ -std=c++17 -fsyntax-only -Iinclude 复现 no matching function for call。
  • 修正后写法 uint64_t shapeArray[8] = {...}; Tensor<float> in1(dev, shapeArray, 2) 编译通过(exit 0)。
  • 逐文件校验:每篇文档声明恰好 1 处、且位于首个 in1 构造之前;全文无残留 {{3, 4, 0, 0, 0, 0, 0, 0}}。
  • 文档类改动,无运行测试;OAT 合规检查通过。

文档更新

更新 docs/api 下 17 篇文档的使用示例(Tensor 构造写法)。

类型标签

likedislike
Merge blocked
SuneeSuneeCollaborators
Oct 24 Created pull request, commit 26de2a0c
SuneeSuneeCollaborators
Oct 24 Modify description of pull request
CANN-robotCANN-robotCollaborators
Oct 24 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Oct 24 Comments:

CLA Signature Pass

Sunee, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robot
CANN-robotCollaborators
Oct 24 Comments:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)

Module Approval Details

module lgtm status approve status
repo-cann/atvoss ❌ (0/2)(You can also ask: 王瑞, 王林木, 周奇龙, 冯彤, 顾宝成) ❌ (0/1)(You can also ask: 冯彤, 顾宝成, 徐鲁威, jia0liang, 王瑞)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)
likedislike
CANN-robotCANN-robotCollaborators
Oct 24 Set zhou-qilong,wangrui_,rxtfeng,loov1,jia0liang,llimwang,gubaocheng as approver
CANN-robotCANN-robotCollaborators
Oct 24 Set zhou-qilong,wangrui_,rxtfeng,loov1,jia0liang,llimwang,gubaocheng as approver
Sunee
SuneeCollaborators
Oct 24 Comments:

compile

likedislike
CANN-robotCANN-robotCollaborators
Oct 24 Added label: ci-pipeline-running
CANN-robot
CANN-robotCollaborators
Oct 24 Comments:

流水线任务触发成功
任务链接 [ceb3df4e80a040c6b0654f1f4448e4fe][流水线指导]

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
cocheck_codestyle ✅ SUCCESS
precommit ⚠️ WARNING >>>>> >>>>>
UT_Test ✅ SUCCESS
ST_Test ✅ SUCCESS
API_Check ✅ SUCCESS >>>>>

[2026-10-24 10:10:00]    CI执行结束

likedislike
CANN-robotCANN-robotCollaborators
Oct 24 Added label: api-check-pass
CANN-robotCANN-robotCollaborators
Oct 24 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Oct 24 Added label: ci-pipeline-passed