[BugFix] Validate feature shape to reject mismatched Encode versions#7131
Open
TBD1 wants to merge 1 commit intoPaddlePaddle:release/online/20251131from
Open
[BugFix] Validate feature shape to reject mismatched Encode versions#7131TBD1 wants to merge 1 commit intoPaddlePaddle:release/online/20251131from
TBD1 wants to merge 1 commit intoPaddlePaddle:release/online/20251131from
Conversation
|
Thanks for your contribution! |
2773d66 to
d888d7b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
在多模态推理场景中,特征下载后需要确保形状维度的一致性。当前代码在下载 BOS 特征时,缺少对特征形状维度的验证,可能导致混合维度(如同时存在 2D 和 4D 特征)或非法维度(如 1D 特征)的输入进入后续处理流程,引发潜在的运行时错误。
本 PR 通过添加特征形状检查逻辑,在特征下载完成后立即验证形状维度的合法性,提前拦截不合规的请求并返回明确的错误信息。
Modifications
1. 新增
check_result_shape()函数 (resource_manager_v1.py)2. 特征下载流程增强
在以下特征下载完成后调用
check_result_shape()进行验证:video_features下载后image_features下载后3. 单元测试覆盖 (
test_resource_manager_v1.py)新增 4 个测试用例:
test_check_result_shape_all_2d_success- 验证所有 2D 特征通过test_check_result_shape_all_4d_success- 验证所有 4D 特征通过test_check_result_shape_mixed_2d_4d_fails- 验证混合维度被拦截test_check_result_shape_1d_fails- 验证非法维度被拦截Usage or Command
无需额外命令,该修复自动应用于多模态特征下载流程。
Accuracy Tests
本 PR 不涉及模型内核或前向传播代码的修改,仅增加输入验证逻辑,不影响模型输出的准确性。
Checklist
[BugFix]pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.