| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #!/bin/bash
- set -e
- root=$(cd $(dirname ${0})/../..; pwd)
- build=${root}/build
- node_modules=${root}/node_modules
- src=${root}/src
- third_party=${root}/third_party
- tools=${root}/tools
- python=${python:-python}
- pip=${pip:-pip}
- identifier=onnx
- repository=https://github.com/onnx/${identifier}.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
- echo "Install ONNX"
- virtualenv=${build}/virtualenv/${identifier}
- virtualenv -p ${python} ${virtualenv}
- source ${virtualenv}/bin/activate
- export ONNX_ML=1
- export ONNX_NAMESPACE=onnx
- ${pip} install ${third_party}/${identifier}
- echo "Generate 'onnx-metadata.json'"
- pushd ${tools}/metadata > /dev/null
- ${python} onnx-metadata.py
- popd > /dev/null
- deactivate
- echo "Generate 'onnx.js'"
- ${node_modules}/protobufjs/bin/pbjs -t static-module -w closure -r onnx -o ${src}/onnx.js ${third_party}/${identifier}/onnx/onnx-ml.proto ${third_party}/${identifier}/onnx/onnx-operators-ml.proto
- node ${tools}/metadata/update_pbjs.js array ${src}/onnx.js floatData float 1
- node ${tools}/metadata/update_pbjs.js array ${src}/onnx.js doubleData double 1
|