Skip to content

Conversation

@wlewNV
Copy link
Contributor

@wlewNV wlewNV commented Jan 5, 2026

Issue #636

Previously, passing ANY structured numpy dtype to NDBuffer.copy_from_numpy() would fail because nanobind's numpy binding doesn't accept compound dtypes.

This change does the following:

  • copy_from_numpy() now uses BufferCursor for structured dtypes, which handles platform-specific alignment
  • Simple dtypes (e.g., float32, int32) use a direct memory copy
  • from_numpy() raises a helpful error for structured dtypes without explicit Slang type

@wlewNV wlewNV changed the title Allow numpy arrays created with np.dtype to be passed to slangpy Support structured numpy dtypes in NDBuffer.copy_from_numpy() Jan 5, 2026
@wlewNV wlewNV marked this pull request as ready for review January 5, 2026 19:28
@wlewNV wlewNV requested a review from a team as a code owner January 5, 2026 19:28
@ccummingsNV
Copy link
Contributor

This one should maybe wait until after the tensor refactor, because:

  • We're getting rid of NDBuffer altogether (only Tensor will exist)
  • We need to get rid of all Python side implemenation of the tensor type eventually, so we'll need to work out how to achieve the above from the native side (or at least via some hook)

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.

2 participants