APITest 测试基建:修复非连续 Tensor 生成错误#639
Merged
wanghuancoder merged 1 commit intoJun 9, 2026
Merged
Conversation
zhengshengning
approved these changes
Jun 8, 2026
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.
概述
本 PR 重构了 Paddle 和 PyTorch 非连续步长张量(non-contiguous strided tensor)的创建逻辑,确保两个框架使用相同的共享逻辑数据源,而非各自随机生成数据。
主要改进
共享逻辑数据源
移除旧逻辑中各自独立随机生成数据的方式,双方框架现在通过
get_numpy_tensor()获取相同的逻辑数据简化存储大小计算
提取
_strided_storage_size()为独立方法,避免代码重复,便于维护优化数据类型处理
对
float8_e5m2/float8_e4m3fn等特殊类型,使用中间类型(float16)进行数据填充,填充后再转换为目标类型,保证数据精度改进内存分配方式
paddle.to_tensor()随机数据改为paddle.empty()+ 数据赋值torch.randn()改为torch.empty()+copy_()赋值