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

[CherryPick2.6]Fix a null pointer exception caused by branching on uninitialized data. #50864

Merged
merged 1 commit into from Jul 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions tensorflow/lite/kernels/unidirectional_sequence_lstm.cc
Expand Up @@ -62,8 +62,12 @@ TfLiteStatus PopulateQuantizedLstmParams8x8_16(
context,
GetOutputSafe(context, node, lstm::full::kOutputTensor, &output_tensor));

TF_LITE_ENSURE(context,
cell_state->quantization.type != kTfLiteNoQuantization);
auto* cell_state_params =
static_cast<TfLiteAffineQuantization*>(cell_state->quantization.params);
TF_LITE_ENSURE(context,
output_tensor->quantization.type != kTfLiteNoQuantization);
auto* proj_params = static_cast<TfLiteAffineQuantization*>(
output_tensor->quantization.params);
if (cell_clip > 0.0) {
Expand Down Expand Up @@ -160,6 +164,8 @@ TfLiteStatus PopulateQuantizedLstmParams8x8_16(
TfLiteTensor* intermediate;
TF_LITE_ENSURE_OK(context,
GetIntermediatesSafe(context, node, i, &intermediate));
TF_LITE_ENSURE(context,
intermediate->quantization.type != kTfLiteNoQuantization);
auto* params = static_cast<TfLiteAffineQuantization*>(
intermediate->quantization.params);
intermediate_scale.push_back(params->scale->data[0]);
Expand All @@ -174,6 +180,7 @@ TfLiteStatus PopulateQuantizedLstmParams8x8_16(
// is ignored.
TfLiteTensor* hidden;
TF_LITE_ENSURE_OK(context, GetIntermediatesSafe(context, node, 4, &hidden));
TF_LITE_ENSURE(context, hidden->quantization.type != kTfLiteNoQuantization);
auto* hidden_params =
static_cast<TfLiteAffineQuantization*>(hidden->quantization.params);
intermediate_scale.push_back(hidden_params->scale->data[0]);
Expand Down Expand Up @@ -760,6 +767,8 @@ TfLiteStatus PopulatePrecomputedZPTimesWeightsWithBias(TfLiteContext* context,

const TfLiteTensor* intermediate =
&context->tensors[node->intermediates->data[4]];
TF_LITE_ENSURE(context,
intermediate->quantization.type != kTfLiteNoQuantization);
const auto* params =
static_cast<TfLiteAffineQuantization*>(intermediate->quantization.params);
const int32_t hidden_zp = params->zero_point->data[0];
Expand Down