|
| 1 | +# Copyright 2020 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +#!/bin/bash |
| 16 | + |
| 17 | +set -e |
| 18 | + |
| 19 | +readonly CPUINFO_REPOSITORY="https://github.com/pytorch/cpuinfo" |
| 20 | +readonly CPUINFO_TAG="5e63739504f0f8e18e941bd63b2d6d42536c7d90" |
| 21 | + |
| 22 | +readonly RUY_REPOSITORY="https://github.com/google/ruy" |
| 23 | +readonly RUY_TAG="841ea4172ba904fe3536789497f9565f2ef64129" |
| 24 | + |
| 25 | +readonly ABSEIL_REPOSITORY="https://github.com/abseil/abseil-cpp" |
| 26 | +readonly ABSEIL_TAG="dc370a82467cb35066475537b797197aee3e5164" |
| 27 | + |
| 28 | +readonly EIGEN_REPOSITORY="https://gitlab.com/libeigen/eigen" |
| 29 | +readonly EIGEN_TAG="0e187141679fdb91da33249d18cb79a011c0e2ea" |
| 30 | + |
| 31 | +readonly NEON_2_SSE_REPOSITORY="https://github.com/intel/ARM_NEON_2_x86_SSE" |
| 32 | +readonly NEON_2_SSE_TAG="cef9501d1d1c47223466bf2b8cd43f3368c37773" |
| 33 | + |
| 34 | +readonly FLATBUFFERS_REPOSITORY="https://github.com/google/flatbuffers" |
| 35 | +readonly FLATBUFFERS_TAG="615616cb5549a34bdf288c04bc1b94bd7a65c396" |
| 36 | + |
| 37 | +readonly PROTOBUF_REPOSITORY="https://github.com/protocolbuffers/protobuf" |
| 38 | +readonly PROTOBUF_TAG="c9869dc7803eb0a21d7e589c40ff4f9288cd34ae" |
| 39 | + |
| 40 | +readonly TENSORFLOW_REPOSITORY="https://github.com/tensorflow/tensorflow" |
| 41 | +readonly TENSORFLOW_TAG="d74d591e8f9e42be640dd93cfa0584914e25e98e" |
| 42 | + |
| 43 | +# cpuinfo |
| 44 | +git clone --filter=tree:0 --no-checkout ${CPUINFO_REPOSITORY} cpuinfo/src/cpuinfo |
| 45 | +git -C cpuinfo/src/cpuinfo checkout ${CPUINFO_TAG} |
| 46 | +cmake -GNinja -S cpuinfo/src/cpuinfo -B cpuinfo/src/cpuinfo-build \ |
| 47 | + -DCMAKE_FIND_PACKAGE_PREFER_CONFIG:BOOL=ON \ |
| 48 | + -DCMAKE_INSTALL_PREFIX:PATH=${PWD}/cpuinfo \ |
| 49 | + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \ |
| 50 | + -DCPUINFO_BUILD_UNIT_TESTS:BOOL=OFF \ |
| 51 | + -DCPUINFO_BUILD_MOCK_TESTS:BOOL=OFF \ |
| 52 | + -DCPUINFO_BUILD_BENCHMARKS:BOOL=OFF |
| 53 | +ninja -C cpuinfo/src/cpuinfo-build install |
| 54 | + |
| 55 | +# ruy |
| 56 | +git clone --filter=tree:0 --no-checkout ${RUY_REPOSITORY} ruy/src/ruy |
| 57 | +git -C ruy/src/ruy checkout ${RUY_TAG} |
| 58 | +cmake -GNinja -S ruy/src/ruy -B ruy/src/ruy-build \ |
| 59 | + -DCMAKE_FIND_PACKAGE_PREFER_CONFIG:BOOL=ON \ |
| 60 | + -DCMAKE_INSTALL_PREFIX:PATH=${PWD}/ruy \ |
| 61 | + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \ |
| 62 | + -Dcpuinfo_DIR:PATH=${PWD}/cpuinfo/share/cpuinfo \ |
| 63 | + -DRUY_MINIMAL_BUILD:BOOL=ON \ |
| 64 | + -DRUY_ENABLE_INSTALL:BOOL=ON \ |
| 65 | + -DRUY_FIND_CPUINFO:BOOL=ON |
| 66 | +ninja -C ruy/src/ruy-build install |
| 67 | + |
| 68 | +# absl |
| 69 | +git clone --filter=tree:0 --no-checkout ${ABSEIL_REPOSITORY} abseil-cpp/src/abseil-cpp |
| 70 | +git -C abseil-cpp/src/abseil-cpp checkout ${ABSEIL_TAG} |
| 71 | +cmake -GNinja -S abseil-cpp/src/abseil-cpp -B abseil-cpp/src/abseil-cpp-build \ |
| 72 | + -DCMAKE_FIND_PACKAGE_PREFER_CONFIG:BOOL=ON \ |
| 73 | + -DCMAKE_INSTALL_PREFIX:PATH=${PWD}/abseil-cpp \ |
| 74 | + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \ |
| 75 | + -DABSL_BUILD_TESTING:BOOL=OFF \ |
| 76 | + -DABSL_ENABLE_INSTALL:BOOL=ON |
| 77 | +ninja -C abseil-cpp/src/abseil-cpp-build install |
| 78 | + |
| 79 | +# eigen |
| 80 | +git clone --filter=tree:0 --no-checkout ${EIGEN_REPOSITORY} eigen/src/eigen |
| 81 | +git -C eigen/src/eigen checkout ${EIGEN_TAG} |
| 82 | +cmake -GNinja -S eigen/src/eigen -B eigen/src/eigen-build \ |
| 83 | + -DCMAKE_FIND_PACKAGE_PREFER_CONFIG:BOOL=ON \ |
| 84 | + -DCMAKE_INSTALL_PREFIX:PATH=${PWD}/eigen \ |
| 85 | + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \ |
| 86 | + -DEIGEN_BUILD_DOC:BOOL=OFF \ |
| 87 | + -DEIGEN_BUILD_TESTING:BOOL=OFF |
| 88 | +ninja -C eigen/src/eigen-build install |
| 89 | + |
| 90 | +# ARM_NEON_2_x86_SSE |
| 91 | +git clone --filter=tree:0 --no-checkout ${NEON_2_SSE_REPOSITORY} ARM_NEON_2_x86_SSE/src/ARM_NEON_2_x86_SSE |
| 92 | +git -C ARM_NEON_2_x86_SSE/src/ARM_NEON_2_x86_SSE checkout ${NEON_2_SSE_TAG} |
| 93 | +cmake -GNinja -S ARM_NEON_2_x86_SSE/src/ARM_NEON_2_x86_SSE -B ARM_NEON_2_x86_SSE/src/ARM_NEON_2_x86_SSE-build \ |
| 94 | + -DCMAKE_FIND_PACKAGE_PREFER_CONFIG:BOOL=ON \ |
| 95 | + -DCMAKE_INSTALL_PREFIX:PATH=${PWD}/ARM_NEON_2_x86_SSE \ |
| 96 | + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON |
| 97 | +ninja -C ARM_NEON_2_x86_SSE/src/ARM_NEON_2_x86_SSE-build install |
| 98 | + |
| 99 | +# flatbuffers |
| 100 | +git clone --filter=tree:0 --no-checkout ${FLATBUFFERS_REPOSITORY} flatbuffers/src/flatbuffers |
| 101 | +git -C flatbuffers/src/flatbuffers checkout ${FLATBUFFERS_TAG} |
| 102 | +cmake -GNinja -S flatbuffers/src/flatbuffers -B flatbuffers/src/flatbuffers-build \ |
| 103 | + -DCMAKE_FIND_PACKAGE_PREFER_CONFIG:BOOL=ON \ |
| 104 | + -DCMAKE_INSTALL_PREFIX:PATH=${PWD}/flatbuffers \ |
| 105 | + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \ |
| 106 | + -DFLATBUFFERS_BUILD_TESTS:BOOL=OFF |
| 107 | +ninja -C flatbuffers/src/flatbuffers-build install |
| 108 | + |
| 109 | +# tflite |
| 110 | +git clone --filter=tree:0 --no-checkout ${TENSORFLOW_REPOSITORY} tensorflow/src/tensorflow |
| 111 | +git -C tensorflow/src/tensorflow checkout ${TENSORFLOW_TAG} |
| 112 | +cmake -GNinja -S tensorflow/src/tensorflow/tensorflow/lite -B tensorflow/src/tensorflow-build \ |
| 113 | + -DCMAKE_FIND_PACKAGE_PREFER_CONFIG:BOOL=ON \ |
| 114 | + -DCMAKE_INSTALL_PREFIX:PATH=${PWD}/tensorflow \ |
| 115 | + -DCMAKE_FIND_PACKAGE_PREFER_CONFIG:BOOL=ON \ |
| 116 | + -DTFLITE_ENABLE_INSTALL:BOOL=ON \ |
| 117 | + -DTFLITE_ENABLE_XNNPACK:BOOL=OFF \ |
| 118 | + -Dcpuinfo_DIR:PATH=${PWD}/cpuinfo/share/cpuinfo \ |
| 119 | + -Druy_DIR:PATH=${PWD}/ruy/lib/cmake/ruy \ |
| 120 | + -Dabsl_DIR:PATH=${PWD}/abseil-cpp/lib/cmake/absl \ |
| 121 | + -DEigen3_DIR:PATH=${PWD}/eigen/share/eigen3/cmake \ |
| 122 | + -DNEON_2_SSE_DIR:PATH=${PWD}/ARM_NEON_2_x86_SSE/lib/cmake/NEON_2_SSE \ |
| 123 | + -DFlatbuffers_DIR:PATH=${PWD}/flatbuffers/lib/cmake/flatbuffers |
| 124 | +ninja -C tensorflow/src/tensorflow-build install |
| 125 | + |
| 126 | +# protobuf |
| 127 | +git clone --filter=tree:0 --no-checkout ${PROTOBUF_REPOSITORY} protobuf/src/protobuf |
| 128 | +git -C protobuf/src/protobuf checkout ${PROTOBUF_TAG} |
| 129 | +cmake -GNinja -S protobuf/src/protobuf/cmake -B protobuf/src/protobuf-build \ |
| 130 | + -DCMAKE_FIND_PACKAGE_PREFER_CONFIG:BOOL=ON \ |
| 131 | + -DCMAKE_INSTALL_PREFIX:PATH=${PWD}/protobuf \ |
| 132 | + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \ |
| 133 | + -Dprotobuf_BUILD_TESTS:BOOL=OFF |
| 134 | +ninja -C protobuf/src/protobuf-build install |
| 135 | + |
| 136 | +# CMake cache file |
| 137 | +cat <<EOF >>tflite.cmake |
| 138 | +set(cpuinfo_DIR "${PWD}/cpuinfo/share/cpuinfo" CACHE PATH "") |
| 139 | +set(ruy_DIR "${PWD}/ruy/lib/cmake/ruy" CACHE PATH "") |
| 140 | +set(absl_DIR "${PWD}/abseil-cpp/lib/cmake/absl" CACHE PATH "") |
| 141 | +set(Eigen3_DIR "${PWD}/eigen/share/eigen3/cmake" CACHE PATH "") |
| 142 | +set(NEON_2_SSE_DIR "${PWD}/ARM_NEON_2_x86_SSE/lib/cmake/NEON_2_SSE" CACHE PATH "") |
| 143 | +set(Flatbuffers_DIR "${PWD}/flatbuffers/lib/cmake/flatbuffers" CACHE PATH "") |
| 144 | +set(protobuf_DIR "${PWD}/output/lib/cmake/protobuf" CACHE PATH "") |
| 145 | +EOF |
0 commit comments