Skip to content

[hannk] Clean up aliasing (v2)#6364

Merged
steven-johnson merged 3 commits intomasterfrom
srj/hannk-alias-improvements
Nov 1, 2021
Merged

[hannk] Clean up aliasing (v2)#6364
steven-johnson merged 3 commits intomasterfrom
srj/hannk-alias-improvements

Conversation

@steven-johnson
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Monday morning review ping

Comment thread apps/hannk/interpreter/tensor.h Outdated
//
// 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
Copy Markdown
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
Copy Markdown
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.

Comment thread apps/hannk/interpreter/tensor.h Outdated

bool is_alias() const {
return is_alias_;
// Return true iff this Tensor aliases another Tensor.
Copy link
Copy Markdown
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
Copy Markdown
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