| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #!/bin/bash
- set -e
- root=$(cd $(dirname ${0})/../..; pwd)
- build=${root}/build
- node_modules=${root}/node_modules
- src=${root}/src
- tools=${root}/tools
- third_party=${root}/third_party
- python="python"
- pip="pip"
- identifier=pytorch
- repository=https://github.com/pytorch/pytorch.git
- mkdir -p ${third_party}
- if [ -d "${third_party}/${identifier}" ]; then
- git -C "${third_party}/${identifier}" fetch -p
- git -C "${third_party}/${identifier}" reset --hard origin/master
- else
- echo "Clone ${repository}..."
- git -C "${third_party}" clone --recursive ${repository}
- fi
- git submodule update --init
- echo "Install Caffe2"
- if [ "$(uname -s)" == "Darwin" ] && [ "$(which brew)" != "" ]; then
- brew bundle --file=- <<-EOS
- brew "automake"
- brew "cmake"
- brew "gflags"
- brew "glog"
- EOS
- fi
- virtualenv=${build}/virtualenv/${identifier}
- virtualenv -p ${python} ${virtualenv}
- source ${virtualenv}/bin/activate
- ${pip} install --quiet future leveldb numpy protobuf pydot python-gflags pyyaml scikit-image setuptools six hypothesis typing
- pushd "${third_party}/pytorch" > /dev/null
- FULL_CAFFE2=1 ${python} setup.py install
- MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ ${python} setup.py install
- popd > /dev/null
- echo "Generate 'caffe2-metadata.json'"
- pushd ${tools}/metadata > /dev/null
- ${python} caffe2-metadata.py
- popd > /dev/null
- deactivate
- echo "Generate 'caffe2.js'"
- ${node_modules}/protobufjs/bin/pbjs -t static-module -w closure -r caffe2 -o ${src}/caffe2.js ${third_party}/pytorch/caffe2/proto/caffe2.proto
- node ${tools}/metadata/update_pbjs.js enumeration ${src}/caffe2.js floats float 1
|