2
0

coreml 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. set -e
  3. pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
  4. src_dir=./third_party/source/coremltools
  5. case "${OSTYPE}" in
  6. msys*) python="winpty python";;
  7. *) python="python";;
  8. esac
  9. clean() {
  10. echo "coreml clean"
  11. rm -rf "${src_dir}"
  12. }
  13. sync() {
  14. echo "coreml sync"
  15. if [ ! -d "${src_dir}" ]; then
  16. git clone --quiet --depth=1 --branch main --single-branch https://github.com/apple/coremltools.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. }
  23. schema() {
  24. echo "coreml schema"
  25. [[ $(grep -U $'\x0D' ./source/coreml-proto.js) ]] && crlf=1
  26. node ./tools/protoc.js --binary --text --root coreml --out ./source/coreml-proto.js --path ./third_party/source/coremltools/mlmodel/format Model.proto
  27. if [[ -n ${crlf} ]]; then
  28. unix2dos --quiet --newfile ./source/coreml-proto.js ./source/coreml-proto.js
  29. fi
  30. }
  31. while [ "$#" != 0 ]; do
  32. command="$1" && shift
  33. case "${command}" in
  34. "clean") clean;;
  35. "sync") sync;;
  36. "schema") schema;;
  37. esac
  38. done