Skip to content

Commit

Permalink
Merge pull request #50864 from geetachavan1/cherrypicks_PO4XP
Browse files Browse the repository at this point in the history
[CherryPick2.6]Fix a null pointer exception caused by branching on uninitialized data.
  • Loading branch information
mihaimaruseac committed Jul 27, 2021
2 parents ac0094d + 82e762a commit 5b8be38
Showing 1 changed file with 9 additions and 0 deletions.
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

0 comments on commit 5b8be38

Please sign in to comment.