Skip to content

Don't use dl_tensor.byte_offset when exporting capsules. - #21153

Merged
AWoloszyn merged 1 commit into
iree-org:mainfrom
AWoloszyn:fix-bytes-offset
Jun 23, 2025
Merged

AWoloszyn merged 1 commit into
iree-org:mainfrom
AWoloszyn:fix-bytes-offset

Conversation

@AWoloszyn

Copy link
Copy Markdown
Contributor

Pytorch ignores byte_offset at least in some circumstances, meaning we end up with the wrong data getting output.

This solves the issue by baking the byte_offset directly into the returned pointer.

See: https://github.com/dmlc/dlpack/blob/7f393bbb86a0ddd71fde3e700fc2affa5cdce72d/include/dlpack/dlpack.h#L225

Pytorch ignores byte_offset at least in some circumstances,
meaning we end up with the wrong data getting output.

This solves the issue by baking the byte_offset directly into
the returned pointer.

Signed-off-by: Andrew Woloszyn <[email protected]>
@zjgarvey

Copy link
Copy Markdown
Contributor

Fascinating. Should I file an issue with pytorch? This sounds like a rather unfortunate bug.

@stellaraccident stellaraccident left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ugh. good find.

@AWoloszyn
AWoloszyn merged commit a6bbf4a into iree-org:main Jun 23, 2025
AWoloszyn added a commit that referenced this pull request Dec 1, 2025
Pytorch ignores byte_offset at least in some circumstances, meaning we
end up with the wrong data getting output.

This solves the issue by baking the byte_offset directly into the
returned pointer.

See:
https://github.com/dmlc/dlpack/blob/7f393bbb86a0ddd71fde3e700fc2affa5cdce72d/include/dlpack/dlpack.h#L225

Signed-off-by: Andrew Woloszyn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants