-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Node] Expose StructuralEqual/Hash handler implemenation to header #13001
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
Merged
junrushao
merged 3 commits into
apache:main
from
masahi:structural-equal-hash-impl-refactor
Oct 10, 2022
Merged
[Node] Expose StructuralEqual/Hash handler implemenation to header #13001
junrushao
merged 3 commits into
apache:main
from
masahi:structural-equal-hash-impl-refactor
Oct 10, 2022
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
Would love to have @tqchen's thoughts on this :-) |
Member
|
seems to be a fine change, would be good to get another pair of eyes for reviewing |
junrushao
approved these changes
Oct 9, 2022
Member
junrushao
left a comment
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.
LGTM
Member
Author
|
@tqchen good to merge? |
Member
|
Sorry for the delay! |
junrushao
pushed a commit
that referenced
this pull request
Oct 17, 2022
…ng NDArray raw data (#13091) A follow up to #13050, also builds on #13001. This PR enables the functionality in #12706 without changing the existing `StructuralEqual/Hash`. A question for discussion: Should this be the default ModuleEquality used by MS? It has no effect for the `link-params = False` case, and it simplifies the MS tuning API usage for the `link-params = True` case (Hexagon etc).
xinetzone
pushed a commit
to daobook/tvm
that referenced
this pull request
Nov 10, 2022
…ng NDArray raw data (apache#13091) A follow up to apache#13050, also builds on apache#13001. This PR enables the functionality in apache#12706 without changing the existing `StructuralEqual/Hash`. A question for discussion: Should this be the default ModuleEquality used by MS? It has no effect for the `link-params = False` case, and it simplifies the MS tuning API usage for the `link-params = True` case (Hexagon etc).
xinetzone
pushed a commit
to daobook/tvm
that referenced
this pull request
Nov 25, 2022
…pache#13001) When we use `StructuralEqual/Hash`, the actual equality testing / hashing work are deferred to `RemapVarSEqualHandler` and `VarCountingSHashHandler` class respectively, defined in `.cc` files. To customize equality / hash behavior, I want to be able to derive from these classes outside of `structural_equal.cc` or `structural_hash.cc`. This is the first step toward replacing my previous attempt apache#12706 to allow ignoring NDArray raw data in `StructuralEqual/Hash`. So I propose to expose them as the "default" handler, while still hiding their implementation details. This lets me define a custom hasher that ignores NDArray content simply by: ``` class SHashHandlerIgnoreNDArray : public SHashHandlerDefault { protected: void DispatchSHash(const ObjectRef& object, bool map_free_vars) override { ICHECK(object.defined()); if (auto ndarray = object.as<runtime::NDArray::Container>()) { SHashReducer hash_reduce(this, map_free_vars); NDArrayHash(ndarray, &hash_reduce, false); } else { SHashHandlerDefault::DispatchSHash(object, map_free_vars); } } }; ```
xinetzone
pushed a commit
to daobook/tvm
that referenced
this pull request
Nov 25, 2022
…ng NDArray raw data (apache#13091) A follow up to apache#13050, also builds on apache#13001. This PR enables the functionality in apache#12706 without changing the existing `StructuralEqual/Hash`. A question for discussion: Should this be the default ModuleEquality used by MS? It has no effect for the `link-params = False` case, and it simplifies the MS tuning API usage for the `link-params = True` case (Hexagon etc).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we use
StructuralEqual/Hash, the actual equality testing / hashing work are deferred toRemapVarSEqualHandlerandVarCountingSHashHandlerclass respectively, defined in.ccfiles. To customize equality / hash behavior, I want to be able to derive from these classes outside ofstructural_equal.ccorstructural_hash.cc. This is the first step toward replacing my previous attempt #12706 to allow ignoring NDArray raw data inStructuralEqual/Hash.So I propose to expose them as the "default" handler, while still hiding their implementation details. This lets me define a custom hasher that ignores NDArray content simply by:
cc @tqchen @junrushao