Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds a new public method as_raw_ptr() to the Mat, MatRef, and MatMut types in the quantization module. The method provides safe access to the underlying byte-level pointer (*const u8) for these matrix types. The "raw" naming convention clearly distinguishes this byte-pointer accessor from potential typed-pointer accessors, following established codebase patterns.
Changes:
- Added
as_raw_ptr()method toMat,MatRef, andMatMutthat returns the base byte pointer (*const u8) - Removed the previous test-only
as_ptr()method fromMatand replaced all its usages with the new publicas_raw_ptr() - Updated all test code to use the new method name
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #774 +/- ##
==========================================
- Coverage 88.99% 88.99% -0.01%
==========================================
Files 428 428
Lines 78415 78431 +16
==========================================
+ Hits 69784 69798 +14
- Misses 8631 8633 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| /// Return the base pointer for the [`Mat`]. | ||
| pub fn as_raw_ptr(&self) -> *const u8 { | ||
| self.ptr.as_ptr() | ||
| } |
There was a problem hiding this comment.
I'm curious - why expose these publicly?
There was a problem hiding this comment.
Isn't this a footgun for unsafe reads?
Add publicly exported
as_raw_ptrfor retrieving the base pointer ofMat,MatRef, andMatMut.The term "raw" is meant to denote that this is the byte pointer - not necessarily the pointer to the actual element type stored in these containers.