[DLPACK] Support from_dlpack with shared memory#67927
Merged
HydrogenSulfate merged 40 commits intoPaddlePaddle:developfrom Sep 19, 2024
Merged
[DLPACK] Support from_dlpack with shared memory#67927HydrogenSulfate merged 40 commits intoPaddlePaddle:developfrom
HydrogenSulfate merged 40 commits intoPaddlePaddle:developfrom
Conversation
[pull] develop from PaddlePaddle:develop
[pull] develop from PaddlePaddle:develop
|
你的PR提交成功,感谢你对开源项目的贡献! |
14 tasks
18a9390 to
d7c70ac
Compare
d7c70ac to
1eecb4e
Compare
…ove redundant function in tensor_util.cc
SigureMo
approved these changes
Sep 19, 2024
|
|
||
|
|
||
| def from_dlpack(dlpack: CapsuleType) -> Tensor: | ||
| def from_dlpack(dlpack: Any) -> Tensor: |
Member
There was a problem hiding this comment.
这里是易用性提升么?原来只支持 dlpack 的现在只要实现 __dlpack__ Protocol 就可以传了
从类型上比较建议使用 SupportDLPack | CapsuleType
class SupportDLPack(Protocol):
def __dlpack__(self) -> CapsuleType: ...不过目前这样也没啥大问题,可以下个 PR
DesmonDay
reviewed
Sep 19, 2024
| strides[i] = _strides[i]; | ||
| if (shape[i] < 2) { | ||
| strides[i] = 1; | ||
| } |
Contributor
Author
There was a problem hiding this comment.
这里的改动是等价的么?
原先的strides计算方法应该是有问题的,没有考虑x是non-contiguous的情况,而是直接根据shape算strides,这会导致转化后的dlpack张量一定是contiguous。参考pytorch的做法,应该直接使用原张量的strides即可https://github.com/pytorch/pytorch/blob/db80b98ec460ca5b2fd84c1dfb6426925f64c8cc/aten/src/ATen/DLConvertor.cpp#L267-L276。
根据你说的我测了下这个PR转换前后的strides,好像from_dlpack对strides的处理还有点问题,我需要再修改一下,并再加一个strides单测。
This was referenced Sep 27, 2024
Closed
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 Category
User Experience
PR Types
Bug fixes
Description
Pcard-75624
修复前:
bool修复后:
使用百万元素的张量进行测试,可支持与numpy、cupy、pytorch等高性能计算框架在CPU和GPU下的数据共享和张量互相转换:
(
-表示不需要支持,√表示支持)相关PR:NVIDIA/warp#313
输出: