Skip to content

Conversation

@jdowd7
Copy link

@jdowd7 jdowd7 commented Jan 2, 2025

Refactors this func to address the warning:

Capture of 'keyTensorPointer' with non-sendable type 'UnsafeMutableRawBufferPointer' in a @sendable closure; this is an error in the Swift 6 language mode

  • Simplified the index calculations by treating the 4D tensors as 2D (hidden_dim × seq_length)
  • Added bounds checking to prevent out-of-range access
  • Used direct array indexing with properly calculated linear indices
  • Simplified memory copying using direct pointer access for the slices

Tested in our application and its working as expected

@ZachNagengast
Copy link
Contributor

Thanks @jdowd7! Do you have any metrics on if there is a speed difference between the two implementations?

@jdowd7
Copy link
Author

jdowd7 commented Jan 2, 2025

Thanks @jdowd7! Do you have any metrics on if there is a speed difference between the two implementations?

Not yet, will benchmark and report back when I get a chance

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