iree-org / iree

A retargetable MLIR-based machine learning compiler and runtime toolkit.

Home Page:http://iree.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot run posenet example in tflite

Sylvexia opened this issue · comments

What happened?

terminal output:

2024-06-09 12:35:49.949317: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-06-09 12:35:49.983152: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-06-09 12:35:50.401913: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Traceback (most recent call last):
  File "/home/sylvex/iree/.venv/bin/iree-import-tflite", line 8, in <module>
    sys.exit(main())
  File "/home/sylvex/iree/.venv/lib/python3.10/site-packages/iree/tools/tflite/scripts/iree_import_tflite/__main__.py", line 54, in main
    tflite_to_tosa(
  File "/home/sylvex/iree/.venv/lib/python3.10/site-packages/iree/tools/tflite/scripts/iree_import_tflite/__main__.py", line 69, in tflite_to_tosa
    tflite_to_tosa_bytecode(
  File "/home/sylvex/iree/.venv/lib/python3.10/site-packages/tensorflow/python/compiler/mlir/mlir.py", line 200, in tflite_to_tosa_bytecode
    pywrap_mlir.experimental_tflite_to_tosa_bytecode(
  File "/home/sylvex/iree/.venv/lib/python3.10/site-packages/tensorflow/python/pywrap_mlir.py", line 123, in experimental_tflite_to_tosa_bytecode
    return ExperimentalTFLiteToTosaBytecode(
tensorflow.python.framework.errors_impl.InvalidArgumentError: Unable to load input file cannot open input file '/tmp/workdir/model.tflite': No such file or directory
(.venv) sylvex@sylvex-Aspire-A715-51G:~/iree$ wget ${TFLITE_URL} -O ${TFLITE_PATH}
--2024-06-09 12:35:58--  https://storage.googleapis.com/iree-model-artifacts/tflite-integration-tests/posenet_i8.tflite
Resolving storage.googleapis.com (storage.googleapis.com)... 2404:6800:4012:4::201b, 2404:6800:4012:2::201b, 2404:6800:4012::201b, ...
Connecting to storage.googleapis.com (storage.googleapis.com)|2404:6800:4012:4::201b|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2894840 (2.8M) [application/octet-stream]
Saving to: ‘/tmp/workdir/model.tflite’

/tmp/workdir/model.tflite 100%[===================================>]   2.76M  1.56MB/s    in 1.8s

2024-06-09 12:36:00 (1.56 MB/s) - ‘/tmp/workdir/model.tflite’ saved [2894840/2894840]

(.venv) sylvex@sylvex-Aspire-A715-51G:~/iree$ iree-import-tflite ${TFLITE_PATH} -o ${IMPORT_PATH}
2024-06-09 12:36:03.387469: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-06-09 12:36:03.417775: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-06-09 12:36:03.894858: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
(.venv) sylvex@sylvex-Aspire-A715-51G:~/iree$ iree-compile \
    --iree-input-type=tosa \
    --iree-hal-target-backends=llvm-cpu \
    ${IMPORT_PATH} \
    -o ${MODULE_PATH}
<unknown>:0: error: loc("floordiv"): unregistered operation 'tosa.div' found in dialect ('tosa') that does not allow unknown operations
<unknown>:0: note: loc("floordiv"): see current operation: %405 = "tosa.div"(%404, %39) : (tensor<1x1xi32>, tensor<1x1xi32>) -> tensor<1x1xi32>
<unknown>:0: note: loc("floordiv"): in bytecode version 1 produced by: MLIR19.0.0git

Steps to reproduce your issue

  1. Build project with commit f062b19
  2. run the command at https://iree.dev/guides/ml-frameworks/tflite/#using-command-line-tools

What component(s) does this issue relate to?

No response

Version information

f062b19

Additional context

There's probably previous version that I compiled also doesn't work.

what happend

I got almost same error here with https://iree.dev/guides/ml-frameworks/tflite/ (using python code)

2024-06-10 00:12:28.459569: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
  File "/Users/chendongsheng/github/iree/cds_demo_/test_tflite.py", line 29, in <module>
    iree_tflite_compile.compile_file(
  File "/Users/chendongsheng/github/iree/build/compiler/bindings/python/iree/compiler/tools/tflite.py", line 119, in compile_file
    result = invoke_pipeline([compile_cl])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chendongsheng/github/iree/build/compiler/bindings/python/iree/compiler/tools/binaries.py", line 261, in invoke_pipeline
    raise CompilerToolError(stage.completed)
iree.compiler.tools.binaries.CompilerToolError: Error invoking IREE compiler tool iree-compile
Error code: 1
Diagnostics:
<unknown>:0: error: loc("floordiv"): unregistered operation 'tosa.div' found in dialect ('tosa') that does not allow unknown operations
<unknown>:0: note: loc("floordiv"): in bytecode version 1 produced by: MLIR19.0.0git


Invoked with:
 iree-compile /Users/chendongsheng/github/iree/build/compiler/bindings/python/iree/compiler/tools/../_mlir_libs/iree-compile /tmp/workdir/tosa.mlir --iree-input-type=tosa --iree-vm-bytecode-module-output-format=flatbuffer-binary --iree-hal-target-backends=llvm-cpu -o=/tmp/workdir/iree.vmfb --iree-llvmcpu-embedded-linker-path=/Users/chendongsheng/github/iree/build/compiler/bindings/python/iree/compiler/tools/../_mlir_libs/iree-lld --mlir-print-debuginfo --mlir-print-op-on-diagnostic=false

Need more information? Set IREE_SAVE_TEMPS=/some/dir in your environment to save all artifacts and reproducers.

step reduce

commit id: 9e3d27a
build cmd:

cmake -G Ninja -B ./build/ -S . \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DIREE_ENABLE_ASSERTIONS=ON \
    -DIREE_ENABLE_SPLIT_DWARF=ON \
    -DCMAKE_C_COMPILER=clang \
    -DCMAKE_CXX_COMPILER=clang++ \
    -DIREE_ENABLE_LLD=ON \
    -DCMAKE_C_COMPILER_LAUNCHER=ccache \
    -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
    -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
    -DCMAKE_C_COMPILER=/usr/bin/clang \
    -DIREE_BUILD_PYTHON_BINDINGS=ON \
    -DPython3_EXECUTABLE="$(which python)" \
    -DCMAKE_INSTALL_PREFIX=/usr/local/cds_bin \
    -DIREE_EMBED_RELEASE_INFO=ON

This is hard to debug without the full inputs to the compiler. My guess is that you use a TF version that is too old. tosa.div was renamed to tosa.int_div quite a while ago. IREE requires tensorflow>=2.16.1

The version of tensorflow I installed do be 2.16.1