[Frontend][TFLite] Fix fully_connected converter when batch size is not 1 #6038
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The fully_connected converter used the shapes from the TFLite model to reshape the data tensor. However, the TFLite model shapes do not reflect those provided by the
data_shape
parameter infrom_tflite()
. The TFLite model shapeinput_tensor.tensor.ShapeAsNumpy()
will give a batch size of1
because the TFLite model obviously doesn't know about thedata_shape
dict the user provided to the relay importer.For this particular op, the reshape can always be set to
(-1, n_units)
without needing to calculate a batch size.For inceptionv4, without this PR we would incorrectly compute a batch size of 1 adding this reshape from %515:
(4, 1, 1, 1536)
to %516:(1, 1536)
. This ultimately causes the model output to become(1, 1001)
instead of(4, 1001)
Btw, should the reshape op have some validation to prevent reshapes where the numbers of elements don't match?
(4, 1, 1, 1536)
->(1, 1536)
shouldn't be valid.