Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Generalize ref-to-ref ops#1468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
akern40 wants to merge33 commits intorust-ndarray:master
base:master
Choose a base branch
Loading
fromakern40:expand-ops

Conversation

akern40
Copy link
Collaborator

The current reference-to-reference operations defined inimpl_ops.rs only allow for outputs where the output type is the same as the left-hand operand. This makes sense for reference-to-owned, where we can reuse an allocation, but not for reference-to-reference.

This is a follow on to#1440, and so cannot be merged until then.

The reference type, `RefBase<A, D, R>`, is parameterized by its elementtype, a dimensionality type, and its "referent" type. This last typeis only a `PhantomData` marker, and acts to differentiate referencesthat are "safe" from those that are "raw", i.e., references that comefrom an array whose storage is `Data` vs an array whose stoarge is`RawData`. The `DerefMut` implementation contains a check of uniqueness,guaranteeing that an `&mut RefBase` is safe to mutate.This comes with one breaking change and one important internal librarynote. The breaking change is that `ArrayBase` no longer implements `Copy`for views. This is because a `RefBase` does not know where it is pointing,and therefore cannot implement `Copy`; this, in turn, prohibits`ArrayBase` from implementing `Copy`. Users will now have to explicitlyinvoke `Clone` in the same way that they do for non-view arrays.The important library note has to do with the `.try_ensure_unique` checkthat occurs in the `DerefMut` implementation. The library's methods areallowed to *temporarily* break the invariant that an array's `ptr`is contained within `data`. The issue comes when trying to then alter`ptr`, `shape`, or `dim` while that invariant is broken. Code wasusing `self.ptr = ...` (where `self` is `ArrayBase`), which triggers`DerefMut`, which calls `try_ensure_unique`, which panics on thepointer inbounds check. As a result, code that is altering `RefBase`fields while the array's invariants are broken must be sure to write`self.aref.ptr = ...` instead.
I think I accidentally moved this over to ArrayRef, but we're not sure it should still require DataOwned
@akern40
Copy link
CollaboratorAuthor

This is also blocked until the inclusion of the next-gen solver, seerust-lang/rust#80542

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@akern40

[8]ページ先頭

©2009-2025 Movatter.jp