executorch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. set -e
  3. pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
  4. src_dir=./third_party/source/executorch
  5. case "${OSTYPE}" in
  6. msys*) python="winpty python";;
  7. *) python="python";;
  8. esac
  9. clean() {
  10. echo "executorch clean"
  11. rm -rf "${src_dir}"
  12. }
  13. sync() {
  14. echo "executorch sync"
  15. if [ ! -d "${src_dir}" ]; then
  16. git clone --quiet --depth=1 --branch main --single-branch https://github.com/pytorch/executorch.git "${src_dir}"
  17. else
  18. git -C "${src_dir}" fetch --quiet --depth=1 origin main
  19. git -C "${src_dir}" reset --quiet --hard FETCH_HEAD
  20. git -C "${src_dir}" gc --quiet --prune=all
  21. fi
  22. # mkdir -p "${src_dir}/schema"
  23. # curl --silent --show-error --location --output "${src_dir}/schema/scalar_type.fbs" "https://github.com/pytorch/executorch/raw/main/schema/scalar_type.fbs"
  24. # curl --silent --show-error --location --output "${src_dir}/schema/program.fbs" "https://github.com/pytorch/executorch/raw/main/schema/program.fbs"
  25. }
  26. schema() {
  27. echo "executorch schema"
  28. [[ $(grep -U $'\x0D' ./source/executorch-schema.js) ]] && crlf=1
  29. node ./tools/flatc.js --out ./source/executorch-schema.js ${src_dir}/schema/program.fbs ${src_dir}/backends/xnnpack/serialization/schema.fbs ${src_dir}/backends/vulkan/serialization/schema.fbs
  30. if [[ -n ${crlf} ]]; then
  31. unix2dos --quiet --newfile ./source/executorch-schema.js ./source/executorch-schema.js
  32. fi
  33. }
  34. while [ "$#" != 0 ]; do
  35. command="$1" && shift
  36. case "${command}" in
  37. "clean") clean;;
  38. "sync") sync;;
  39. "schema") schema;;
  40. esac
  41. done