Repository: tensorflow/tensorflow (language: cpp)

Issue:
NNAPI does not accept the reshape operation with the -1 parameter
**System information**
* OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18.04
* Mobile device: Xiaomi Mi MIX 2S (Android 9, API 28)
* TensorFlow Lite version on Android: 0.0.0-gpu-experimental



**Provide the text output from tflite_convert**

```
tflite_convert \
--graph_def_file=tflite_graph.pb \
--output_file=detect.tflite \
--input_shapes=1,300,300,3 \
--input_arrays=normalized_input_image_tensor \
--output_arrays='raw_outputs/class_predictions','raw_outputs/box_encodings' \
--inference_type=QUANTIZED_UINT8 \
--mean_values=128 \
--std_dev_values=128 \
--change_concat_input_ranges=false \
--allow_custom_ops
```

**Describe the current behavior**

I use SSD mobilenet V1 model from [zoo](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md). When I try to use this model in an Android application using NNAPI, I get an error message. The problem is that the Reshape operation has the new shape [1, -1, 91]. Will it be possible to use Reshape with the -1 parameter in NNAPI. And is it possible to change this parameter to static without retraining the model?



Discussion / hints:
Not sure this is still relevant, as I think this is pre-toco and pre having unknown shape in TF lite. At the least it should be checked.
@AndrzejKRK,

As mentioned in [Android developers website](https://developer.android.com/ndk/guides/neuralnetworks#tensors_of_unknown_rank), 
Android 9 (API level 28) introduced model operands of unknown dimensions but known rank (the number of dimensions). Android 10 (API level 29) introduced tensors of unknown rank, as shown in [ANeuralNetworksOperandType](https://developer.android.com/ndk/reference/struct/a-neural-networks-operand-type).

Hope this helps. Thank you!
This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Thank you.

Closing as stale. Please reopen if you'd like to work on this further.

Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/25661">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/25661">No</a>


Fix patch:
diff --git a/third_party/xla/xla/service/gpu/gpu_hlo_schedule.cc b/third_party/xla/xla/service/gpu/gpu_hlo_schedule.cc
index aacd6d264475fa..8a2bddaa3e6455 100644
--- a/third_party/xla/xla/service/gpu/gpu_hlo_schedule.cc
+++ b/third_party/xla/xla/service/gpu/gpu_hlo_schedule.cc
@@ -396,6 +396,8 @@ std::optional<ProfiledInstructionsProto> ProfileFromPath(
     LOG(ERROR) << "Tried but failed to parse PGLE proto from "
                << (as_text ? "text" : "binary") << " file '" << path
                << "'. Error message: " << s.message();
+  } else {
+    LOG(ERROR) << "PGLE profile file does not exist: " << path;
   }
   return std::nullopt;
 }


Test patch: