pytorch-update 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. set -e
  3. root=$(cd $(dirname ${0})/../..; pwd)
  4. build=${root}/build
  5. node_modules=${root}/node_modules
  6. src=${root}/src
  7. tools=${root}/tools
  8. third_party=${root}/third_party
  9. python="python"
  10. pip="pip"
  11. identifier=pytorch
  12. repository=https://github.com/pytorch/pytorch.git
  13. mkdir -p ${third_party}
  14. if [ -d "${third_party}/${identifier}" ]; then
  15. git -C "${third_party}/${identifier}" fetch -p
  16. git -C "${third_party}/${identifier}" reset --hard origin/master
  17. else
  18. echo "Clone ${repository}..."
  19. git -C "${third_party}" clone --recursive ${repository}
  20. fi
  21. git submodule update --init
  22. echo "Install Caffe2"
  23. if [ "$(uname -s)" == "Darwin" ] && [ "$(which brew)" != "" ]; then
  24. brew bundle --file=- <<-EOS
  25. brew "automake"
  26. brew "cmake"
  27. brew "gflags"
  28. brew "glog"
  29. EOS
  30. fi
  31. virtualenv=${build}/virtualenv/${identifier}
  32. virtualenv -p ${python} ${virtualenv}
  33. source ${virtualenv}/bin/activate
  34. ${pip} install --quiet future leveldb numpy protobuf pydot python-gflags pyyaml scikit-image setuptools six hypothesis typing
  35. pushd "${third_party}/pytorch" > /dev/null
  36. FULL_CAFFE2=1 ${python} setup.py install
  37. MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ ${python} setup.py install
  38. popd > /dev/null
  39. echo "Generate 'caffe2-metadata.json'"
  40. pushd ${tools}/metadata > /dev/null
  41. ${python} caffe2-metadata.py
  42. popd > /dev/null
  43. deactivate
  44. echo "Generate 'caffe2.js'"
  45. ${node_modules}/protobufjs/bin/pbjs -t static-module -w closure -r caffe2 -o ${src}/caffe2.js ${third_party}/pytorch/caffe2/proto/caffe2.proto
  46. node ${tools}/metadata/update_pbjs.js enumeration ${src}/caffe2.js floats float 1