Skip to content

Commit a0e297e

Browse files
authored
docs(skill): update branch creation workflow (#75)
1 parent 2250bf1 commit a0e297e

15 files changed

Lines changed: 240 additions & 86 deletions

File tree

.claude/skills/add-compat-api/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ bash test/result_cmp.sh ./build/
202202

203203
闭环验证通过且文档已回填后,按以下流程提交。完整命令模板见 [`references/Step7.md`](references/Step7.md)
204204

205-
1. **从 fork 主分支 checkout 新分支**`git fetch upstream && git checkout -B add/<api>-<YYYYMMDD> upstream/develop`
205+
1. **从本地跟踪 origin 的 develop 创建新分支**`git checkout develop && git pull --ff-only origin develop && git checkout -b add/<api>-<YYYYMMDD>`
206206
2. **commit 改动**(commit message 首行使用 `[Cpp API Compatibility] <对齐迭代记录标题>`
207207
3. **push 到 fork**`git push origin <branch>`
208208
4. **`gh pr create` 到 upstream**`--repo PaddlePaddle/Paddle --base develop`
209209
5. **同步 PCAT 测试改动**
210-
1. **从 fork 主分支 checkout 新分支**`cd "$PCAT_ROOT" && git fetch upstream && git checkout -B test/<api>-<YYYYMMDD> upstream/master`
210+
1. **从本地跟踪 origin 的 master 创建新分支**`cd "$PCAT_ROOT" && git checkout master && git pull --ff-only origin master && git checkout -b test/<api>-<YYYYMMDD>`
211211
2. **commit 改动**(commit message 首行使用 `test(<api>): align with Paddle compat <api> 行为`
212212
3. **push 到 fork**`git push origin <branch>`
213213
4. **`gh pr create` 到 upstream**`--repo PFCCLab/PaddleCppAPITest --base master`,PR body 中加 `Related: PaddlePaddle/Paddle#<Paddle_PR_NUM>`

.claude/skills/add-compat-api/references/Step7.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,27 @@
1313

1414
任一未通过 → **不要**进入本流程。
1515

16-
## 1) 从 fork 主分支 checkout 新分支
16+
## 1) 从本地跟踪 origin 的基分支创建新分支
1717

1818
### Paddle 侧
1919

2020
```bash
2121
cd "$PADDLE_ROOT"
22-
git fetch upstream
22+
git checkout develop
23+
git pull --ff-only origin develop
2324
# add 流程
24-
git checkout -B "add/<api-name>-$(date +%Y%m%d)" upstream/develop
25+
git checkout -b "add/<api-name>-$(date +%Y%m%d)"
2526
# fix 流程
26-
git checkout -B "fix/<pr-or-issue-num>-$(date +%Y%m%d)" upstream/develop
27+
git checkout -b "fix/<pr-or-issue-num>-$(date +%Y%m%d)"
2728
```
2829

2930
分支命名规则:
3031
- add:`add/<api-name>-<YYYYMMDD>`(例:`add/abs-20260519`
3132
- fix:`fix/<pr-num>-<YYYYMMDD>`(例:`fix/78652-20260519`
3233

33-
> 前提:Paddle 仓库已配置 `origin = <user>/Paddle``upstream = PaddlePaddle/Paddle`。若 remote 缺失,**提示用户配置后再继续**,不要主动改用户仓库的 remote。
34+
> 实际执行时只选 add 或 fix 对应的一条 `git checkout -b`。若分支已存在,`git checkout -b` 会失败;换新分支名或让用户手动处理,**不要**改用 `-B` 覆盖已有分支。
35+
>
36+
> 前提:Paddle 仓库已配置 `origin = <user>/Paddle``upstream = PaddlePaddle/Paddle`,且本地 `develop` 跟踪 `origin/develop`。若 remote 或本地基分支缺失,**提示用户配置后再继续**,不要主动改用户仓库的 remote。
3437
3538
## 2) commit 改动
3639

@@ -100,8 +103,9 @@ EOF
100103

101104
```bash
102105
cd "$PCAT_ROOT"
103-
git fetch upstream
104-
git checkout -B "test/<api>-$(date +%Y%m%d)" upstream/master
106+
git checkout master
107+
git pull --ff-only origin master
108+
git checkout -b "test/<api>-$(date +%Y%m%d)"
105109
git add test/<改动文件>
106110
git commit -m "test(<api>): align with Paddle compat <api> 行为"
107111
git push origin <branch>

.claude/skills/fix-compat-api/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ bash test/result_cmp.sh ./build/
218218

219219
闭环验证通过且文档已回填后,按以下流程提交。完整命令模板见 [`../add-compat-api/references/Step7.md`](../add-compat-api/references/Step7.md)(与 `add-compat-api` 共享同一份 references)。
220220

221-
1. **从 fork 主分支 checkout 新分支**`git fetch upstream && git checkout -B fix/<pr-or-issue-num>-<YYYYMMDD> upstream/develop`
221+
1. **从本地跟踪 origin 的 develop 创建新分支**`git checkout develop && git pull --ff-only origin develop && git checkout -b fix/<pr-or-issue-num>-<YYYYMMDD>`
222222
2. **commit 改动**(commit message 首行使用 `[Cpp API Compatibility] <Compat 修复记录标题>`
223223
3. **征求用户同意后 push 到 fork**`git push origin <branch>`——这是发出去的动作,**push 前必须明确询问用户**
224224
4. **征求用户同意后 `gh pr create` 到 upstream**`--repo PaddlePaddle/Paddle --base develop`——同样需要用户确认;若本轮修复源自外部 PR/Actions/comment 链接,PR 描述里应**引用原链接**便于追溯)

.github/skills/add-compat-api/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ bash test/result_cmp.sh ./build/
202202

203203
闭环验证通过且文档已回填后,按以下流程提交。完整命令模板见 [`references/Step7.md`](references/Step7.md)
204204

205-
1. **从 fork 主分支 checkout 新分支**`git fetch upstream && git checkout -B add/<api>-<YYYYMMDD> upstream/develop`
205+
1. **从本地跟踪 origin 的 develop 创建新分支**`git checkout develop && git pull --ff-only origin develop && git checkout -b add/<api>-<YYYYMMDD>`
206206
2. **commit 改动**(commit message 首行使用 `[Cpp API Compatibility] <对齐迭代记录标题>`
207207
3. **push 到 fork**`git push origin <branch>`
208208
4. **`gh pr create` 到 upstream**`--repo PaddlePaddle/Paddle --base develop`
209209
5. **同步 PCAT 测试改动**
210-
1. **从 fork 主分支 checkout 新分支**`cd "$PCAT_ROOT" && git fetch upstream && git checkout -B test/<api>-<YYYYMMDD> upstream/master`
210+
1. **从本地跟踪 origin 的 master 创建新分支**`cd "$PCAT_ROOT" && git checkout master && git pull --ff-only origin master && git checkout -b test/<api>-<YYYYMMDD>`
211211
2. **commit 改动**(commit message 首行使用 `test(<api>): align with Paddle compat <api> 行为`
212212
3. **push 到 fork**`git push origin <branch>`
213213
4. **`gh pr create` 到 upstream**`--repo PFCCLab/PaddleCppAPITest --base master`,PR body 中加 `Related: PaddlePaddle/Paddle#<Paddle_PR_NUM>`

.github/skills/add-compat-api/references/Step7.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,27 @@
1313

1414
任一未通过 → **不要**进入本流程。
1515

16-
## 1) 从 fork 主分支 checkout 新分支
16+
## 1) 从本地跟踪 origin 的基分支创建新分支
1717

1818
### Paddle 侧
1919

2020
```bash
2121
cd "$PADDLE_ROOT"
22-
git fetch upstream
22+
git checkout develop
23+
git pull --ff-only origin develop
2324
# add 流程
24-
git checkout -B "add/<api-name>-$(date +%Y%m%d)" upstream/develop
25+
git checkout -b "add/<api-name>-$(date +%Y%m%d)"
2526
# fix 流程
26-
git checkout -B "fix/<pr-or-issue-num>-$(date +%Y%m%d)" upstream/develop
27+
git checkout -b "fix/<pr-or-issue-num>-$(date +%Y%m%d)"
2728
```
2829

2930
分支命名规则:
3031
- add:`add/<api-name>-<YYYYMMDD>`(例:`add/abs-20260519`
3132
- fix:`fix/<pr-num>-<YYYYMMDD>`(例:`fix/78652-20260519`
3233

33-
> 前提:Paddle 仓库已配置 `origin = <user>/Paddle``upstream = PaddlePaddle/Paddle`。若 remote 缺失,**提示用户配置后再继续**,不要主动改用户仓库的 remote。
34+
> 实际执行时只选 add 或 fix 对应的一条 `git checkout -b`。若分支已存在,`git checkout -b` 会失败;换新分支名或让用户手动处理,**不要**改用 `-B` 覆盖已有分支。
35+
>
36+
> 前提:Paddle 仓库已配置 `origin = <user>/Paddle``upstream = PaddlePaddle/Paddle`,且本地 `develop` 跟踪 `origin/develop`。若 remote 或本地基分支缺失,**提示用户配置后再继续**,不要主动改用户仓库的 remote。
3437
3538
## 2) commit 改动
3639

@@ -100,8 +103,9 @@ EOF
100103

101104
```bash
102105
cd "$PCAT_ROOT"
103-
git fetch upstream
104-
git checkout -B "test/<api>-$(date +%Y%m%d)" upstream/master
106+
git checkout master
107+
git pull --ff-only origin master
108+
git checkout -b "test/<api>-$(date +%Y%m%d)"
105109
git add test/<改动文件>
106110
git commit -m "test(<api>): align with Paddle compat <api> 行为"
107111
git push origin <branch>

.github/skills/fix-compat-api/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ bash test/result_cmp.sh ./build/
218218

219219
闭环验证通过且文档已回填后,按以下流程提交。完整命令模板见 [`../add-compat-api/references/Step7.md`](../add-compat-api/references/Step7.md)(与 `add-compat-api` 共享同一份 references)。
220220

221-
1. **从 fork 主分支 checkout 新分支**`git fetch upstream && git checkout -B fix/<pr-or-issue-num>-<YYYYMMDD> upstream/develop`
221+
1. **从本地跟踪 origin 的 develop 创建新分支**`git checkout develop && git pull --ff-only origin develop && git checkout -b fix/<pr-or-issue-num>-<YYYYMMDD>`
222222
2. **commit 改动**(commit message 首行使用 `[Cpp API Compatibility] <Compat 修复记录标题>`
223223
3. **征求用户同意后 push 到 fork**`git push origin <branch>`——这是发出去的动作,**push 前必须明确询问用户**
224224
4. **征求用户同意后 `gh pr create` 到 upstream**`--repo PaddlePaddle/Paddle --base develop`——同样需要用户确认;若本轮修复源自外部 PR/Actions/comment 链接,PR 描述里应**引用原链接**便于追溯)

test/ATen/core/TensorUtilTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <torch/all.h>
66

77
#include <string>
8+
#include <utility>
89
#include <vector>
910

1011
#include "src/file_manager.h"
@@ -17,6 +18,11 @@ namespace test {
1718
using paddle_api_test::FileManerger;
1819
using paddle_api_test::ThreadSafeParam;
1920

21+
static_assert(noexcept(std::declval<const at::TensorBase&>().is_same(
22+
std::declval<const at::TensorBase&>())));
23+
static_assert(noexcept(std::declval<const at::TensorBase&>().use_count()));
24+
static_assert(noexcept(std::declval<const at::TensorBase&>().weak_use_count()));
25+
2026
class TensorUtilTest : public ::testing::Test {
2127
protected:
2228
void SetUp() override {

test/ATen/ops/AsStridedTest.cpp

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,8 @@ class AsStridedTest : public ::testing::Test {
1919
void SetUp() override {}
2020
};
2121

22-
// 返回当前用例的结果文件名
23-
std::string GetTestCaseResultFileName() {
24-
std::string base = g_custom_param.get();
25-
std::string test_name =
26-
::testing::UnitTest::GetInstance()->current_test_info()->name();
27-
if (base.size() >= 4 && base.substr(base.size() - 4) == ".txt") {
28-
base.resize(base.size() - 4);
29-
}
30-
return base + "_" + test_name + ".txt";
31-
}
32-
3322
TEST_F(AsStridedTest, AsStrided) {
34-
FileManerger file(GetTestCaseResultFileName());
23+
FileManerger file(g_custom_param.get());
3524
file.createFile();
3625
file << "AsStrided ";
3726
at::Tensor tensor = at::ones({2, 3, 4}, at::kFloat);
@@ -44,7 +33,7 @@ TEST_F(AsStridedTest, AsStrided) {
4433
}
4534

4635
TEST_F(AsStridedTest, AsStridedInplace) {
47-
FileManerger file(GetTestCaseResultFileName());
36+
FileManerger file(g_custom_param.get());
4837
file.openAppend();
4938
file << "AsStridedInplace ";
5039
at::Tensor tensor = at::ones({2, 3, 4}, at::kFloat);
@@ -57,7 +46,7 @@ TEST_F(AsStridedTest, AsStridedInplace) {
5746
}
5847

5948
TEST_F(AsStridedTest, AsStridedScatter) {
60-
FileManerger file(GetTestCaseResultFileName());
49+
FileManerger file(g_custom_param.get());
6150
file.openAppend();
6251
file << "AsStridedScatter ";
6352
at::Tensor tensor = at::ones({2, 3, 4}, at::kFloat);
@@ -69,5 +58,40 @@ TEST_F(AsStridedTest, AsStridedScatter) {
6958
file.saveFile();
7059
}
7160

61+
TEST_F(AsStridedTest, AsStridedScatterPreservesInputShape) {
62+
FileManerger file(g_custom_param.get());
63+
file.openAppend();
64+
file << "AsStridedScatterPreservesInputShape ";
65+
at::Tensor tensor = at::arange(12, at::kFloat);
66+
at::Tensor src = at::full({2, 3}, 99.0f, at::kFloat);
67+
at::Tensor result = tensor.as_strided_scatter(src, {2, 3}, {3, 1});
68+
file << std::to_string(result.dim()) << " ";
69+
file << std::to_string(result.sizes()[0]) << " ";
70+
float* data = result.data_ptr<float>();
71+
for (int i = 0; i < 6; ++i) {
72+
file << std::to_string(data[i]) << " ";
73+
}
74+
file << "\n";
75+
file.saveFile();
76+
}
77+
78+
TEST_F(AsStridedTest, AsStridedScatterWithOffset) {
79+
FileManerger file(g_custom_param.get());
80+
file.openAppend();
81+
file << "AsStridedScatterWithOffset ";
82+
at::Tensor tensor = at::arange(12, at::kFloat);
83+
at::Tensor src = at::full({2, 2}, 88.0f, at::kFloat);
84+
at::Tensor result = tensor.as_strided_scatter(src, {2, 2}, {2, 1}, 2);
85+
file << std::to_string(result.dim()) << " ";
86+
file << std::to_string(result.sizes()[0]) << " ";
87+
float* data = result.data_ptr<float>();
88+
file << std::to_string(data[0]) << " ";
89+
file << std::to_string(data[2]) << " ";
90+
file << std::to_string(data[3]) << " ";
91+
file << std::to_string(data[5]) << " ";
92+
file << "\n";
93+
file.saveFile();
94+
}
95+
7296
} // namespace test
7397
} // namespace at

test/ATen/ops/BitwiseTest.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,8 @@ class BitwiseTest : public ::testing::Test {
1919
void SetUp() override {}
2020
};
2121

22-
// 返回当前用例的结果文件名
23-
std::string GetTestCaseResultFileName() {
24-
std::string base = g_custom_param.get();
25-
std::string test_name =
26-
::testing::UnitTest::GetInstance()->current_test_info()->name();
27-
if (base.size() >= 4 && base.substr(base.size() - 4) == ".txt") {
28-
base.resize(base.size() - 4);
29-
}
30-
return base + "_" + test_name + ".txt";
31-
}
32-
3322
TEST_F(BitwiseTest, BitwiseRightShift) {
34-
FileManerger file(GetTestCaseResultFileName());
23+
FileManerger file(g_custom_param.get());
3524
file.createFile();
3625
file << "BitwiseRightShift ";
3726
at::Tensor input = at::ones({2, 3}, at::kInt).fill_(8);

test/ATen/ops/ClampTest.cpp

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,8 @@ class ClampTest : public ::testing::Test {
1919
void SetUp() override {}
2020
};
2121

22-
// 返回当前用例的结果文件名
23-
std::string GetTestCaseResultFileName() {
24-
std::string base = g_custom_param.get();
25-
std::string test_name =
26-
::testing::UnitTest::GetInstance()->current_test_info()->name();
27-
if (base.size() >= 4 && base.substr(base.size() - 4) == ".txt") {
28-
base.resize(base.size() - 4);
29-
}
30-
return base + "_" + test_name + ".txt";
31-
}
32-
3322
TEST_F(ClampTest, ClampScalarMinMax) {
34-
FileManerger file(GetTestCaseResultFileName());
23+
FileManerger file(g_custom_param.get());
3524
file.createFile();
3625
file << "ClampScalarMinMax ";
3726
at::Tensor input = at::ones({2, 3}, at::kFloat).fill_(5.0f);
@@ -44,7 +33,7 @@ TEST_F(ClampTest, ClampScalarMinMax) {
4433
}
4534

4635
TEST_F(ClampTest, ClampTensorMinMax) {
47-
FileManerger file(GetTestCaseResultFileName());
36+
FileManerger file(g_custom_param.get());
4837
file.openAppend();
4938
file << "ClampTensorMinMax ";
5039
at::Tensor input = at::ones({2, 3}, at::kFloat).fill_(5.0f);
@@ -57,7 +46,7 @@ TEST_F(ClampTest, ClampTensorMinMax) {
5746
}
5847

5948
TEST_F(ClampTest, ClampInplaceScalar) {
60-
FileManerger file(GetTestCaseResultFileName());
49+
FileManerger file(g_custom_param.get());
6150
file.openAppend();
6251
file << "ClampInplaceScalar ";
6352
at::Tensor input = at::ones({2, 3}, at::kFloat).fill_(5.0f);
@@ -69,7 +58,7 @@ TEST_F(ClampTest, ClampInplaceScalar) {
6958
}
7059

7160
TEST_F(ClampTest, ClampInplaceTensor) {
72-
FileManerger file(GetTestCaseResultFileName());
61+
FileManerger file(g_custom_param.get());
7362
file.openAppend();
7463
file << "ClampInplaceTensor ";
7564
at::Tensor input = at::ones({2, 3}, at::kFloat).fill_(5.0f);
@@ -82,7 +71,7 @@ TEST_F(ClampTest, ClampInplaceTensor) {
8271
}
8372

8473
TEST_F(ClampTest, ClampMaxScalar) {
85-
FileManerger file(GetTestCaseResultFileName());
74+
FileManerger file(g_custom_param.get());
8675
file.openAppend();
8776
file << "ClampMaxScalar ";
8877
at::Tensor input = at::ones({2, 3}, at::kFloat).fill_(5.0f);
@@ -94,7 +83,7 @@ TEST_F(ClampTest, ClampMaxScalar) {
9483
}
9584

9685
TEST_F(ClampTest, ClampMaxTensor) {
97-
FileManerger file(GetTestCaseResultFileName());
86+
FileManerger file(g_custom_param.get());
9887
file.openAppend();
9988
file << "ClampMaxTensor ";
10089
at::Tensor input = at::ones({2, 3}, at::kFloat).fill_(5.0f);
@@ -106,7 +95,7 @@ TEST_F(ClampTest, ClampMaxTensor) {
10695
}
10796

10897
TEST_F(ClampTest, ClampMaxInplace) {
109-
FileManerger file(GetTestCaseResultFileName());
98+
FileManerger file(g_custom_param.get());
11099
file.openAppend();
111100
file << "ClampMaxInplace ";
112101
at::Tensor input = at::ones({2, 3}, at::kFloat).fill_(5.0f);
@@ -118,7 +107,7 @@ TEST_F(ClampTest, ClampMaxInplace) {
118107
}
119108

120109
TEST_F(ClampTest, ClampMaxInplaceTensor) {
121-
FileManerger file(GetTestCaseResultFileName());
110+
FileManerger file(g_custom_param.get());
122111
file.openAppend();
123112
file << "ClampMaxInplaceTensor ";
124113
at::Tensor input = at::ones({2, 3}, at::kFloat).fill_(5.0f);
@@ -130,7 +119,7 @@ TEST_F(ClampTest, ClampMaxInplaceTensor) {
130119
}
131120

132121
TEST_F(ClampTest, ClampMinScalar) {
133-
FileManerger file(GetTestCaseResultFileName());
122+
FileManerger file(g_custom_param.get());
134123
file.openAppend();
135124
file << "ClampMinScalar ";
136125
at::Tensor input = at::ones({2, 3}, at::kFloat);
@@ -142,7 +131,7 @@ TEST_F(ClampTest, ClampMinScalar) {
142131
}
143132

144133
TEST_F(ClampTest, ClampMinTensor) {
145-
FileManerger file(GetTestCaseResultFileName());
134+
FileManerger file(g_custom_param.get());
146135
file.openAppend();
147136
file << "ClampMinTensor ";
148137
at::Tensor input = at::ones({2, 3}, at::kFloat);
@@ -154,7 +143,7 @@ TEST_F(ClampTest, ClampMinTensor) {
154143
}
155144

156145
TEST_F(ClampTest, ClampMinInplace) {
157-
FileManerger file(GetTestCaseResultFileName());
146+
FileManerger file(g_custom_param.get());
158147
file.openAppend();
159148
file << "ClampMinInplace ";
160149
at::Tensor input = at::ones({2, 3}, at::kFloat);
@@ -166,7 +155,7 @@ TEST_F(ClampTest, ClampMinInplace) {
166155
}
167156

168157
TEST_F(ClampTest, ClampMinInplaceTensor) {
169-
FileManerger file(GetTestCaseResultFileName());
158+
FileManerger file(g_custom_param.get());
170159
file.openAppend();
171160
file << "ClampMinInplaceTensor ";
172161
at::Tensor input = at::ones({2, 3}, at::kFloat);

0 commit comments

Comments
 (0)