Skip to content

Conversation

@jwaldrop107
Copy link
Member

Is this pull request associated with an issue(s)?
No

Description
This PR changes the API used to interact with the Contiguous and Eigen buffers, moving towards explicit getters and setters for accessing data. get_elem/set_elem uses coordinate indices, while get_data/set_data uses ordinal indices (overloading wasn't used for these because the index types make the signatures ambiguous). A read-only pointer to the underlying data is accessible with get_immutable_data, while a read/write pointer is available with get_mutable_data.

The get_mutable_data function should be used with care because of the second part of this PR, which is switching to a hash-based equality check for buffers. Having mutable pointers to the underlying data around means it is unfeasible to track changes within the tensor, so using get_mutable_data turns off any attempt to store the hash of the current state and requires recalculation each time equality is checked. Otherwise, the hash will only be updated when a non-const method is called (or if it's the first time it's being checked).

@jwaldrop107 jwaldrop107 self-assigned this Apr 22, 2025
Copy link
Member

@ryanmrichard ryanmrichard left a comment

Choose a reason for hiding this comment

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

Looks great! Just two minor questions.

@jwaldrop107 jwaldrop107 merged commit e90f976 into master Apr 22, 2025
9 checks passed
@jwaldrop107 jwaldrop107 deleted the buffer_api_update branch April 22, 2025 17:41
@jwaldrop107
Copy link
Member Author

🚀 [bumpr] Bumped!
New version:v0.0.54
Changes:v0.0.53...v0.0.54

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