From: A. Unique TensorFlower Date: Thu, 17 May 2018 18:47:16 +0000 (-0700) Subject: Support 1x1x1xN bias sizes in TFLite's convolution and FC layers. X-Git-Tag: upstream/v1.9.0_rc1~94^2^2~66 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=622168b154be1aa60fe94fc840ad82803c29e5d3;p=platform%2Fupstream%2Ftensorflow.git Support 1x1x1xN bias sizes in TFLite's convolution and FC layers. PiperOrigin-RevId: 197027135 --- diff --git a/tensorflow/contrib/lite/kernels/conv.cc b/tensorflow/contrib/lite/kernels/conv.cc index 3b467b3..2b7e455 100644 --- a/tensorflow/contrib/lite/kernels/conv.cc +++ b/tensorflow/contrib/lite/kernels/conv.cc @@ -212,8 +212,7 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { } else { TF_LITE_ENSURE_EQ(context, bias->type, data_type); } - TF_LITE_ENSURE_EQ(context, bias->dims->size, 1); - TF_LITE_ENSURE_EQ(context, bias->dims->data[0], filter->dims->data[0]); + TF_LITE_ENSURE_EQ(context, NumElements(bias), SizeOfDimension(filter, 0)); } int channels_out = filter->dims->data[0]; diff --git a/tensorflow/contrib/lite/kernels/fully_connected.cc b/tensorflow/contrib/lite/kernels/fully_connected.cc index 1ba3064..a486b81 100644 --- a/tensorflow/contrib/lite/kernels/fully_connected.cc +++ b/tensorflow/contrib/lite/kernels/fully_connected.cc @@ -106,11 +106,10 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ASSERT_EQ(input_size, batch_size * filter->dims->data[1]); if (bias) { - TF_LITE_ASSERT_EQ(bias->dims->data[0], num_units); + TF_LITE_ENSURE_EQ(context, NumElements(bias), SizeOfDimension(filter, 0)); } TF_LITE_ENSURE_EQ(context, NumDimensions(filter), 2); - TF_LITE_ENSURE_EQ(context, NumDimensions(bias), 1); // Note that quantized inference requires that all tensors have their // parameters set. This is usually done during quantized training.