Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubArray of subArray now returns subArray of original parent #3538

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

willyborn
Copy link
Contributor

@willyborn willyborn commented Feb 28, 2024

left-hand subArrays always return the parent Array with a new dimensions/strides (copy parameter == false).
When the parent Array however already was an subArray, an internal copy was executed and a subArray on the internal copy was returned. All updates performed on this left-hand subArray were lost.

Reason:
the subArray calculation assumes that the parent array is linear. If not, a copy is created before starting the calculation.
For left-hand subArrays, a copy is not allowed because we would no longer write into the parent data buffer. It is also not necessary for parent subArrays since the original parent array still is linear (although the parent subArray is not).

Solution:
The linear check is changed so that we now verify the original parent array on linearity. In case of non-linear a copy is still performed when the copy parameter is true, otherwise an AF_ERROR is thrown.

Description

Additional information about the PR answering following questions:

  • Is this a new feature or a bug fix?
    • bug fix
  • More detail if necessary to describe all commits in pull request.
  • Why these changes are necessary.
    • Without this change, left-hand subArray of an existing subArray would reference an internal copy of the parent. All data written remains invisible since it is an internal copy.
  • Potential impact on specific hardware, software or backends.
    • None
  • New functions and their functionality.
    • Existing function
  • Can this PR be backported to older versions?
    • Yes
  • Future changes not implemented in this PR.
    -->
    Fixes: [BUG] Elementwise value assignment silently fails after in-place array downsize using rows() #3534

Changes to Users

No changes

Checklist

  • Rebased on latest master
  • Code compiles
  • Tests pass, except for oneapi since I could not install. Issue 3539 created.

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.

[BUG] Elementwise value assignment silently fails after in-place array downsize using rows()
1 participant