build.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. # on intel mac, this ends up with a lot of the following error.
  5. #
  6. # AttributeError: 'Sequential' object has no attribute '_get_save_spec'.
  7. #
  8. # * "pip install tensorflow" installs tensorflow 2.16.2 on intel mac.
  9. # (because it's the last version before tf deprecated the target.)
  10. # * keras 3 support in the version seems incomplete (thus the error)
  11. # * a workaround: use keras 2 as mentioned in:
  12. # https://github.com/tensorflow/tensorflow/releases/tag/v2.16.1
  13. # https://blog.tensorflow.org/2024/03/whats-new-in-tensorflow-216.html
  14. set -e
  15. CURR_PATH=$(cd $(dirname $0) && pwd -P)
  16. # WASM application that uses WASI-NN
  17. /opt/wasi-sdk/bin/clang \
  18. --target=wasm32-wasi \
  19. -DNN_LOG_LEVEL=1 \
  20. -Wl,--allow-undefined \
  21. -I../include -I../src/utils \
  22. -o test_tensorflow.wasm \
  23. test_tensorflow.c utils.c
  24. # TFLite models to use in the tests
  25. cd ${CURR_PATH}/models
  26. python3 average.py
  27. python3 max.py
  28. python3 mult_dimension.py
  29. python3 mult_outputs.py
  30. python3 sum.py
  31. # Specific tests for TPU
  32. cd ${CURR_PATH}
  33. /opt/wasi-sdk/bin/clang \
  34. --target=wasm32-wasi \
  35. -DNN_LOG_LEVEL=1 \
  36. -Wl,--allow-undefined \
  37. -I../include -I../src/utils \
  38. -o test_tensorflow_quantized.wasm \
  39. test_tensorflow_quantized.c utils.c
  40. cd ${CURR_PATH}/models
  41. python3 quantized.py
  42. cd ${CURR_PATH}