Skip to content

[XPU] fix strided_copy data_size param#74225

Merged
dynamicheart merged 1 commit intoPaddlePaddle:developfrom
cqulilujia:stride_copy
Jul 25, 2025
Merged

[XPU] fix strided_copy data_size param#74225
dynamicheart merged 1 commit intoPaddlePaddle:developfrom
cqulilujia:stride_copy

Conversation

@cqulilujia
Copy link
Contributor

PR Category

Custom Device

PR Types

Bug fixes

Description

Fix strided_copy data_size param

@paddle-bot
Copy link

paddle-bot bot commented Jul 24, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the XPU label Jul 24, 2025
int64_t data_size = input.Holder()->size() - input.meta().offset;
int64_t data_size_in = input.Holder()->size() - input.meta().offset;
int64_t data_size_out = out->Holder()->size() - out->meta().offset;
int64_t data_size = std::max(data_size_in, data_size_out);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strided_copy的size是不是应该跟out的size有关?如果in的size大于out的size,他是有多个输入写到同一个输出地址吗?overwrite?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的data_size是指原始的数据大小,即显存里实际存放的大小,不是逻辑上的tensor大小,输入输出的data_size由于stride的存在都有可能远大于tensor.numel(),是否overwrite由stride和shape共同控制,合法的strided_copy不应该存在overwrite的情形。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

理论上是不是不需要data_size这个参数?tensor的dim和stride可以推算出来

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加上这个参数 1 是为了做合法校验,防止paddle的bug,api参数检查会通过tensor的dim和stride计算tensor大小,不能大于data_size 2 对于API来说是必要的,因为单测要分配原始tensor大小的显存,需要预先定好

@dynamicheart dynamicheart merged commit 583b68d into PaddlePaddle:develop Jul 25, 2025
51 checks passed
@cqulilujia cqulilujia deleted the stride_copy branch December 8, 2025 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants