Skip to content
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

Initialize ArithmeticParams & OpDataReduce #2337

Merged
merged 2 commits into from
Nov 30, 2023

Conversation

rascani
Copy link
Contributor

@rascani rascani commented Nov 28, 2023

There are several structs that are allocated as either part of the arena or on the stack that do not get entirely initialized. It is typical that individual operations will just fill in the fields of a struct that they need. This can lead to difficult to find bugs where a field is used despite never being initialized. This PR resolves two such instances found in issue #2336.

The first is in the reference ADD kernel, where we use ArithmeticParams without initializing it. This is resolved by zero initializing the struct when it is declared.

The second is the OpDataReduce object that is created in the Persistent Arena for Reduce kernels. This is resolved by performing placement new on the buffer that is returned from AllocatePersistentBuffer. This is a pattern we use elsewhere with allocations, and likely one we should re-use in all Init functions.

BUG=#2336

There are several structs that are allocated as either part of the arena
or on the stack that do not get entirely initialized. It is typical that
individual operations will just fill in the fields of a struct that they
need. This can lead to difficult to find bugs where a field is used
despite never being initialized. This PR resolves two such instances
found in issue tensorflow#2336.

The first is in the reference ADD kernel, where we use ArithmeticParams
without initializing it. This is resolved by zero initializing the
struct when it is declared.

The second is the OpDataReduce object that is created in the Persistent
Arena for Reduce kernels. This is resolved by performing placement new
on the buffer that is returned from AllocatePersistentBuffer. This is a
pattern we use elsewhere with allocations, and likely one we should
re-use in all Init functions.

BUG=tensorflow#2336
@mergify mergify bot merged commit 2f97d82 into tensorflow:main Nov 30, 2023
28 checks passed
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