caffe 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. set -e
  3. pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
  4. bold() {
  5. echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)"
  6. }
  7. clean() {
  8. bold "caffe clean"
  9. rm -rf ./third_party/caffe
  10. }
  11. sync() {
  12. bold "caffe sync"
  13. mkdir -p "./third_party"
  14. if [ -d "./third_party/caffe" ]; then
  15. git -C "./third_party/caffe" pull --quiet --prune
  16. else
  17. git -C "./third_party" clone --quiet --recursive https://github.com/BVLC/caffe.git
  18. fi
  19. }
  20. schema() {
  21. bold "caffe schema"
  22. [[ $(file ./src/caffe-proto.js) =~ CRLF ]] && crlf=1
  23. sed 's/required float min = 1;/optional float min = 1;/g;s/required float max = 2;/optional float max = 2;/g' < ./third_party/caffe/src/caffe/proto/caffe.proto >./tools/caffe.proto
  24. npx pbjs -t static-module -w closure --no-encode --no-delimited --no-comments --no-convert --no-verify --no-create --keep-case --decode-text -r caffe -o ./src/caffe-proto.js ./tools/caffe.proto
  25. rm ./tools/caffe.proto
  26. node ./tools/update_pbjs.js array ./src/caffe-proto.js data float 1
  27. if [[ -n ${crlf} ]]; then
  28. unix2dos --quiet --newfile ./src/caffe-proto.js ./src/caffe-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