-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
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)
Monday morning review ping |
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
apps/hannk/interpreter/tensor.h
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment looks stale
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is indeed
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)