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

[hannk] Clean up aliasing (v2) #6364

Merged
merged 3 commits into from
Nov 1, 2021
Merged

Conversation

steven-johnson
Copy link
Contributor

The code for aliasing tensors was janky. This cleans it up and makes a clear distinction between aliasing done to overlay buffers with crop-and-translate, vs the aliasing done when we reshape tensors. We no longer allow a given tensor to do both of these, and we give preference to Reshape aliasing first.

(Cherry-picked from #6321)

The code for aliasing tensors was janky. This cleans it up and makes a clear distinction between aliasing done to overlay buffers with crop-and-translate, vs the aliasing done when we reshape tensors. We no longer allow a given tensor to do both of these, and we give preference to Reshape aliasing first.

(Cherry-picked from  #6321)
@steven-johnson
Copy link
Contributor Author

Monday morning review ping

//
// Note that this list should never have size() of 0 or 1 (the pointer should simply be null).
std::shared_ptr<std::vector<std::weak_ptr<Tensor>>> aliases_;
AliasType alias_type_ = AliasType::None;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be inside the shared_ptr above? A tuple/struct with the vector?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, yes, that is probably a better design, will do.

@@ -207,10 +219,17 @@ class Tensor {

void resize_dynamic(const Box &new_shape);

bool is_alias() const {
return is_alias_;
// Return true iff this Tensor aliases another Tensor.
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment looks stale

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is indeed

@steven-johnson steven-johnson merged commit f5ce5f3 into master Nov 1, 2021
@steven-johnson steven-johnson deleted the srj/hannk-alias-improvements branch November 1, 2021 20:40
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