Skip to content

Support reinterpreting torch.Tensor as Tensor<StructType, N>#723

Draft
wlewNV wants to merge 53 commits intoshader-slang:mainfrom
wlewNV:reinterpret_tensor
Draft

Support reinterpreting torch.Tensor as Tensor<StructType, N>#723
wlewNV wants to merge 53 commits intoshader-slang:mainfrom
wlewNV:reinterpret_tensor

Conversation

@wlewNV
Copy link
Contributor

@wlewNV wlewNV commented Jan 15, 2026

Fixes #522

Note: This change is built on-top of the tensor refactor. Once that change has been merged, this change can be moved from draft.

Add as_struct_tensor() helper to reinterpret a torch.Tensor as a tensor of struct elements, enabling more structured Slang code when porting from slang-torch.

Changes:

  • Add StructTensorRefMarshall for struct tensor marshalling
  • Support both CUDA (fast path) and non-CUDA backends (interop buffer)

Note: As stated in the parent issue, struct layout may vary between platforms due to padding/alignment.

@ccummingsNV
Copy link
Contributor

Hi - can we hold off on this until the tensor refactor perf work is done. It's a great feature, but marshalling of tensors is going to change dramatically

@ccummingsNV
Copy link
Contributor

@wlewNV this needs merging or closing :)

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.

Support reinterpret of a torchTensor as Tensor<MyStructType, N>

2 participants

Comments