caffe 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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/src/caffe"
  10. }
  11. sync() {
  12. bold "caffe sync"
  13. [ -d "./third_party/src/caffe" ] || git clone --quiet https://github.com/BVLC/caffe.git "./third_party/src/caffe"
  14. pushd "./third_party/src/caffe" > /dev/null
  15. git pull --quiet --prune
  16. popd > /dev/null
  17. }
  18. schema() {
  19. bold "caffe schema"
  20. [[ $(grep -U $'\x0D' ./src/caffe-proto.js) ]] && crlf=1
  21. sed 's/required float min = 1;/optional float min = 1;/g;s/required float max = 2;/optional float max = 2;/g' < ./third_party/src/caffe/src/caffe/proto/caffe.proto >./tools/caffe.proto
  22. 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
  23. rm ./tools/caffe.proto
  24. node ./tools/update_pbjs.js array ./src/caffe-proto.js data float 1
  25. if [[ -n ${crlf} ]]; then
  26. unix2dos --quiet --newfile ./src/caffe-proto.js ./src/caffe-proto.js
  27. fi
  28. }
  29. while [ "$#" != 0 ]; do
  30. command="$1" && shift
  31. case "${command}" in
  32. "clean") clean;;
  33. "sync") sync;;
  34. "schema") schema;;
  35. esac
  36. done