iree-org / iree

A retargetable MLIR-based machine learning compiler and runtime toolkit.
http://iree.dev/
Apache License 2.0
2.56k stars 568 forks source link

[METAL] Fail to compile `singlepose-lightning-tflite-int8` TFlite of Movenet to `.vmfb` file. #17976

Open RechieKho opened 1 month ago

RechieKho commented 1 month ago

What happened?

I'm trying to compile singlepose-lightning-tflite-int8 tensorflow lite file. These are the commands I ran:

iree-import-tflite model.tflite -o model.mlir # Success.
iree-compile --iree-input-type=tosa --iree-hal-target-backends=vulkan-spirv model.mlir -o model.vmfb # Failure.

There is no output during the import (running iree-import-tflite). Errors pop up when compile it. Here is the output of the command, error.log. Very unfortunate that the output is too big to inline them.

Steps to reproduce your issue

As explained above.

What component(s) does this issue relate to?

Compiler

Version information

Here is the print of tree-compile --version:

IREE (https://iree.dev):
  IREE compiler version 20240721.961 @ b0512e2e6c00583f20b6f3b78c1ca52327ed745a
  LLVM version 19.0.0git
  Optimized build

Additional context

You might find this very similar to this issue. But this time I'm going back to my MacBook and compile this. After further inspection, I found out it is a different error compare to the aforementioned issue. This time it is about vector.broadcast instead of spirv.VectorShuffle.

<unknown>:0: error: loc(callsite("center_net_mobile_net_v2fpn_feature_extractor/model_1/tf.__operators__.add/AddV2" at "main")): failed to legalize operation 'vector.broadcast'
kuhar commented 1 month ago
<unknown>:0: note: loc(callsite("center_net_mobile_net_v2fpn_feature_extractor/model_1/tf.__operators__.add/AddV2" at "main")): see current operation: %162 = "vector.broadcast"(%161) : (index) -> vector<4xindex>
kuhar commented 1 month ago

Seems like we forgot to use the converted result type in the vector to spirv pattern for broadcast: https://github.com/llvm/llvm-project/blob/c91e85278cb87a35924d86463d3c0a379c64e9d1/mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp#L147-L148