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

Prevent division by 0 in OneHot implementation #49793

Merged
merged 1 commit into from May 31, 2021

Conversation

geetachavan1
Copy link
Contributor

If input indices is degenerate, the implementation would do a divide by zero. See

int prefix_dim_size = 1;
for (int i = 0; i < op_context.axis; ++i) {
prefix_dim_size *= op_context.indices->dims->data[i];
}
const int suffix_dim_size = NumElements(op_context.indices) / prefix_dim_size;

PiperOrigin-RevId: 370966870
Change-Id: Ie018337811c8016b5a1d3a277d00d5f2e19a2058

If input indices is degenerate, the implementation would do a divide by zero. See https://github.com/tensorflow/tensorflow/blob/745d57df6d5e9bc568666a2a48ed8dd629c27241/tensorflow/lite/kernels/one_hot.cc#L68-L72

PiperOrigin-RevId: 370966870
Change-Id: Ie018337811c8016b5a1d3a277d00d5f2e19a2058
@google-cla google-cla bot added the cla: yes label May 26, 2021
@gbaned gbaned self-assigned this May 27, 2021
@gbaned gbaned added comp:lite TF Lite related issues size:XS CL Change Size: Extra Small labels May 27, 2021
@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation May 27, 2021
@gbaned gbaned requested a review from mihaimaruseac May 27, 2021 09:42
@gbaned gbaned assigned mihaimaruseac and unassigned gbaned May 27, 2021
PR Queue automation moved this from Assigned Reviewer to Approved by Reviewer May 31, 2021
@mihaimaruseac mihaimaruseac merged commit e5d259f into tensorflow:r2.2 May 31, 2021
PR Queue automation moved this from Approved by Reviewer to Merged May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes comp:lite TF Lite related issues size:XS CL Change Size: Extra Small
Projects
PR Queue
  
Merged
Development

Successfully merging this pull request may close these issues.

None yet

3 participants