fastprep.mk 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # -*- Mode: Makefile -*-
  2. #
  3. # Copyright 2016 Google Inc. All Rights Reserved.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. # This makefile builds "fastprep", a faster version of prep.py that can be used
  17. # to build training data for Swivel.
  18. #
  19. # = Step 1. Install protobuf v3 =
  20. #
  21. # Ubuntu 16.10+: sudo apt install libprotobuf-dev
  22. # Ubuntu 16.04: https://launchpad.net/~maarten-fonville/+archive/ubuntu/ppa + replace xenial with yakkety in /etc/apt/sources.list.d/maarten-fonville-ubuntu-ppa-xenial.list
  23. # macOS: brew install protobuf
  24. #
  25. # = Step 2. Build "fastprep". =
  26. #
  27. # make -f fastprep.mk
  28. #
  29. # If all goes well, you should have a program that is "flag compatible" with
  30. # "prep.py" and runs significantly faster. Use it to generate the co-occurrence
  31. # matrices and other files necessary to train a Swivel matrix.
  32. CXXFLAGS=-std=c++11 -march=native -g -O2 -flto -Wall -I.
  33. LDLIBS=-lprotobuf -pthread -lm
  34. FETCHER=curl -L -o
  35. TF_URL=https://github.com/tensorflow/tensorflow/raw/master
  36. PROTOC=protoc
  37. %.proto: tensorflow/core/example
  38. $(FETCHER) $@ $(TF_URL)/$@
  39. %.pb.cc: %.proto
  40. $(PROTOC) --cpp_out=. $<
  41. fastprep: fastprep.cc tensorflow/core/example/feature.pb.cc tensorflow/core/example/example.pb.cc
  42. tensorflow/core/example:
  43. @mkdir -p tensorflow/core/example
  44. clean:
  45. @rm -f fastprep
  46. mrproper: clean
  47. @rm -rf tensorflow