Pull Request has been successfully merged by CANN-robot.
(Thank you for jude_pixel's contribution.)Hi @lvyelong12, welcome to submitting your first PR to CANN!
PR Merge Steps
1. CLA Signing
If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.
2. CI Check
Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.
3. Code Review
After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.
%!(EXTRA string=https://atomgit.com/cann/community/blob/master/en/sig-infrastructure/command.md)


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
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/pypto-gym | ✅ liulufang_gitcode, congqiannan (2/2) | ✅ liulufang_gitcode, congqiannan (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
lvyelong12, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


这单把 modeling/transformers/gutenocr_3b/ask_gutenocr_3b.py 预热循环里重复的 if/else 分支精简了一下(+1/-4),刚刚 CI 已经跑绿,麻烦 @hw_0086_hrf @liulufang_gitcode @wangzheng97 几位老师有空帮忙看看。


/approve


/approve


移除了
modeling/transformers/gutenocr_3b/ask_gutenocr_3b.py(L293-L302)预热循环里if args.batch > 1:与else:执行完全相同语句的冗余条件判断,直接调用model.generate(**inputs, max_new_tokens=10, do_sample=False)。本地已通过
py_compile、ast.parse和ruff增量检查,保持原逻辑不变。修改补丁
查看完整 unified diff
diff --git a/modeling/transformers/gutenocr_3b/ask_gutenocr_3b.py b/modeling/transformers/gutenocr_3b/ask_gutenocr_3b.py index e4cc71e..29cc6a5 100644 --- a/modeling/transformers/gutenocr_3b/ask_gutenocr_3b.py +++ b/modeling/transformers/gutenocr_3b/ask_gutenocr_3b.py @@ -293,10 +293,7 @@ logging.info("\n[Inference]") logging.info(f"Warmup ({args.warmup} iters)...") with torch.no_grad(): for i in range(args.warmup): - if args.batch > 1: - outputs = model.generate(**inputs, max_new_tokens=10, do_sample=False) - else: - outputs = model.generate(**inputs, max_new_tokens=10, do_sample=False) + outputs = model.generate(**inputs, max_new_tokens=10, do_sample=False) torch.npu.synchronize() if i % 5 == 0 or i == args.warmup - 1: logging.info(f" Warmup {i+1}/{args.warmup}")Closes #442