masahi opened a new pull request, #13001: URL: https://github.com/apache/tvm/pull/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 https://github.com/apache/tvm/pull/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); } } }; ``` cc @tqchen @junrushao -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
