tf-update 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. set -e
  3. root=$(cd $(dirname ${0})/..; pwd)
  4. src=${root}/src
  5. tools=${root}/tools
  6. third_party=${root}/third_party
  7. identifier=tensorflow
  8. repository=https://github.com/tensorflow/${identifier}.git
  9. mkdir -p ${third_party}
  10. if [ -d "${third_party}/${identifier}" ]; then
  11. git -C "${third_party}/${identifier}" fetch -p
  12. git -C "${third_party}/${identifier}" reset --hard origin/master
  13. else
  14. echo "Clone ${repository}..."
  15. git -C "${third_party}" clone --recursive ${repository}
  16. fi
  17. echo "Generate '../src/tf.js'"
  18. ${root}/node_modules/protobufjs/bin/pbjs -t static-module -w closure -r tf -o ${src}/tf.js \
  19. ${third_party}/${identifier}/tensorflow/core/protobuf/saved_model.proto \
  20. ${third_party}/${identifier}/tensorflow/core/protobuf/meta_graph.proto \
  21. ${third_party}/${identifier}/tensorflow/core/protobuf/saver.proto \
  22. ${third_party}/${identifier}/tensorflow/core/framework/graph.proto \
  23. ${third_party}/${identifier}/tensorflow/core/framework/op_def.proto \
  24. ${third_party}/${identifier}/tensorflow/core/framework/tensor_shape.proto \
  25. ${third_party}/${identifier}/tensorflow/core/framework/types.proto \
  26. ${third_party}/${identifier}/tensorflow/core/framework/node_def.proto \
  27. ${third_party}/${identifier}/tensorflow/core/framework/versions.proto \
  28. ${third_party}/${identifier}/tensorflow/core/framework/function.proto \
  29. ${third_party}/${identifier}/tensorflow/core/framework/attr_value.proto \
  30. ${third_party}/${identifier}/tensorflow/core/framework/tensor.proto \
  31. ${third_party}/${identifier}/tensorflow/core/framework/resource_handle.proto \
  32. echo "Generate '../src/tf-metadata.json'"
  33. protoc --proto_path ${third_party}/${identifier} tensorflow/core/framework/attr_value.proto --python_out=${tools}
  34. protoc --proto_path ${third_party}/${identifier} tensorflow/core/framework/tensor.proto --python_out=${tools}
  35. protoc --proto_path ${third_party}/${identifier} tensorflow/core/framework/types.proto --python_out=${tools}
  36. protoc --proto_path ${third_party}/${identifier} tensorflow/core/framework/tensor_shape.proto --python_out=${tools}
  37. protoc --proto_path ${third_party}/${identifier} tensorflow/core/framework/resource_handle.proto --python_out=${tools}
  38. protoc --proto_path ${third_party}/${identifier} tensorflow/core/framework/api_def.proto --python_out=${tools}
  39. protoc --proto_path ${third_party}/${identifier} tensorflow/core/framework/op_def.proto --python_out=${tools}
  40. touch ${tools}/tensorflow/__init__.py
  41. touch ${tools}/tensorflow/core/__init__.py
  42. touch ${tools}/tensorflow/core/framework/__init__.py
  43. pushd ${tools} > /dev/null
  44. python tf-metadata.py
  45. popd > /dev/null
  46. rm -rf ${tools}/tensorflow