Skip to content

r2.8 cherry-pick: 1b85a28d395 "Fix TensorKey hash function."#56016

Merged
mihaimaruseac merged 1 commit into
r2.8from
r2.8-1b85a28d395
May 8, 2022
Merged

r2.8 cherry-pick: 1b85a28d395 "Fix TensorKey hash function."#56016
mihaimaruseac merged 1 commit into
r2.8from
r2.8-1b85a28d395

Conversation

@tensorflow-jenkins
Copy link
Copy Markdown
Collaborator

Refer to the original commit: 1b85a28

The original hash function only used total estimated `AllocatedBytes()`, which (a) is an estimate per tensor, and (b) is a very poor hash function for constants (e.g. `int32_t`).
It also tried to access individual tensor bytes through `tensor.data()` of size `AllocatedBytes()`.  This led to ASAN failures because the `AllocatedBytes()` is an estimate of total bytes allocated by a tensor, including any pointed-to constructs (e.g. strings), and does not refer to contiguous bytes in the `.data()` buffer.  We couldn't use this byte vector anyways, since types like `tstring` include pointers, whereas we need to hash the string values themselves.

Modified the hash function to more closely mirror the `==` operator.  This correctly handles `tstring` and any numeric types that do have contiguous storage.  Other types are currently left as unimplemented.

PiperOrigin-RevId: 446265413
@mihaimaruseac mihaimaruseac merged commit cc24eec into r2.8 May 8, 2022
@mihaimaruseac mihaimaruseac deleted the r2.8-1b85a28d395 branch May 8, 2022 18: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.

3 participants