├── GUIDE.md ├── README.md └── RELEASE_LICENSE /GUIDE.md: -------------------------------------------------------------------------------- 1 | # Building TensorFlow for Orange Pi Zero from source 2 | 3 | ## Index 4 | 1. [What you need](#what-you-need) 5 | 2. [Installing basic dependencies](#installing-basic-dependencies) 6 | 3. [Installing USB Memory as Swap](#installing-usb-memory-as-swap) 7 | 4. [Compiling Bazel](#compiling-bazel) 8 | 5. [Compiling TensorFlow](#compiling-tensorflow) 9 | 6. [Cleaning Up](#cleaning-up) 10 | 7. [References](#references) 11 | 8. [Some tips](#some-tips) 12 | 13 | ## What you need 14 | 15 | * Orange Pi Zero (512MB version) 16 | * A SD card (minimum of 16GB is recomended) with Armbian image 17 | * Internet connection to Orange Pi Zero 18 | * A USB memory drive (If you are going to use a flash drive, please read [tips](#some-tips) section to see what type of flash drive is better). 19 | * A fair amount of time 20 | 21 | ## Installing basic dependencies 22 | 23 | First 24 | ``` 25 | sudo add-apt-repository ppa:webupd8team/java 26 | sudo apt update 27 | ``` 28 | 29 | Then install Bazel dependencies 30 | ``` 31 | sudo apt install pkg-config zip g++ zlib1g-dev unzip gcc-4.8 g++-4.8 build-essential oracle-java8-installer oracle-java8-set-default 32 | ``` 33 | 34 | And then install TensorFlow dependencies depending on which version of python you want to use : 35 | 36 | ``` 37 | # For Python 2.x 38 | sudo apt-get install python-pip python-numpy swig python-dev 39 | sudo pip install wheel 40 | 41 | # For Python 3.x 42 | sudo apt-get install python3-pip python3-numpy swig python3-dev python3-wheel 43 | sudo pip3 install wheel 44 | ``` 45 | To be able to take advantage of certain optimization flags: 46 | ``` 47 | sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100 48 | sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 100 49 | ``` 50 | Finally, for cleanliness, make a directory that will hold the Protobuf, Bazel, and TensorFlow repositories. 51 | ``` 52 | mkdir temp 53 | cd temp 54 | ``` 55 | ## Installing USB Memory as Swap 56 | 57 | The compiling procedure of TensorFlow on Orange Pi Zero is quite similar to that on a Raspberry Pi board. The only difference is in the amount of RAM these boards have, as Orange Pi Zero has only 512MB memory, the effect of swap space is a lot more significant during the compiling procedure and this can cause many troubles during compile of both Bazel and TensorFlow. 58 | 59 | For swap space you need a USB drive with at least 1GB of memory for some tips on choosing this drive you can go to [tips](#some-tips) section. After choosing your driver, insert your USB drive, and find the `/dev/XXX` path for the device. 60 | 61 | ```shell 62 | sudo blkid 63 | ``` 64 | 65 | It could be something like `/dev/sda1` 66 | 67 | Then format your device to be swap: 68 | 69 | ```shell 70 | sudo mkswap /dev/XXX 71 | ``` 72 | 73 | If the previous command outputted an alphanumeric UUID, copy that now. Otherwise, find the UUID by running `blkid` again. Copy the UUID associated with `/dev/XXX` 74 | 75 | ```shell 76 | sudo blkid 77 | ``` 78 | 79 | Now edit your `/etc/fstab` file to register your swap file and increase the size of your tmpfs 80 | 81 | ```shell 82 | sudo nano /etc/fstab 83 | ``` 84 | 85 | On a separate line, enter the following information. Replace the X's with the UUID (without quotes) 86 | 87 | ```bash 88 | UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX none swap sw,pri=5 0 0 89 | ``` 90 | 91 | Add the following to the end of the tmpfs line 92 | ```bash 93 | defaults,nosuid,size=4G 0 0 94 | ``` 95 | 96 | Save `/etc/fstab`, exit your text editor, and run the following command: 97 | 98 | ```shell 99 | sudo swapon -a 100 | ``` 101 | ## Compiling Bazel 102 | 103 | To build [Bazel](https://github.com/bazelbuild/bazel), we're going to need to download a zip file containing a distribution archive. Let's do that now and extract it into a new directory called `bazel`: 104 | 105 | ```shell 106 | wget https://github.com/bazelbuild/bazel/releases/download/0.11.1/bazel-0.11.1-dist.zip 107 | unzip -d bazel bazel-0.11.1-dist.zip 108 | sudo chmod -R 777 bazel/ 109 | ``` 110 | 111 | Once it's done downloading and extracting, we can move into the directory to make a few changes: 112 | 113 | ```shell 114 | cd bazel 115 | ``` 116 | 117 | Now for preventing from any out of memory error : 118 | 119 | ```shell 120 | sed -i -e 's/-encoding UTF-8 "@${paramfile}"/-encoding UTF-8 "@${paramfile}" -J-Xmx500M/g' scripts/bootstrap/compile.sh 121 | ``` 122 | 123 | Let's say to Bazel that our CPU is ARM by adding return "arm" in get_cpu_value function before trying to find it from OS name : 124 | ```shell 125 | sed -i '95i\ return "arm"' tools/cpp/lib_cc_configure.bzl 126 | ``` 127 | 128 | Now you can compile bazel with the command below. This takes a lot of time and in my case it took around half a day. 129 | 130 | ```shell 131 | sudo ./compile.sh 132 | ``` 133 | 134 | When the build finishes, you end up with a new binary, `output/bazel`. Copy that to your `/usr/local/bin` directory. 135 | 136 | ```shell 137 | sudo cp output/bazel /usr/local/bin/bazel 138 | ``` 139 | 140 | To make sure it's working properly, run `bazel` on the command line and verify it prints help text. Note: this may take 15-30 seconds to run, so be patient! 141 | 142 | ``` 143 | bazel 144 | 145 | [bazel release 0.11.1- (@non-git)] 146 | Usage: bazel ... 147 | 148 | Available commands: 149 | analyze-profile Analyzes build profile data. 150 | build Builds the specified targets. 151 | canonicalize-flags Canonicalizes a list of bazel options. 152 | clean Removes output files and optionally stops the server. 153 | coverage Generates code coverage report for specified test targets. 154 | cquery Loads, analyzes, and queries the specified targets w/ configurations. 155 | dump Dumps the internal state of the bazel server process. 156 | fetch Fetches external repositories that are prerequisites to the targets. 157 | help Prints help for commands, or the index. 158 | info Displays runtime info about the bazel server. 159 | license Prints the license of this software. 160 | mobile-install Installs targets to mobile devices. 161 | print_action Prints the command line args for compiling a file. 162 | query Executes a dependency graph query. 163 | run Runs the specified target. 164 | shutdown Stops the bazel server. 165 | test Builds and runs the specified test targets. 166 | version Prints version information for bazel. 167 | 168 | Getting more help: 169 | bazel help 170 | Prints help and options for . 171 | bazel help startup_options 172 | Options for the JVM hosting bazel. 173 | bazel help target-syntax 174 | Explains the syntax for specifying targets. 175 | bazel help info-keys 176 | Displays a list of keys used by the info command. 177 | ``` 178 | 179 | Move out of the `bazel` directory, and we'll move onto the next step. 180 | 181 | ```shell 182 | cd .. 183 | ``` 184 | 185 | ## Compiling TensorFlow 186 | 187 | Download your desired TensorFlow version from TensorFlow github and extract it in 'tensorflow' directory : 188 | 189 | ```shell 190 | wget https://github.com/tensorflow/tensorflow/archive/v1.6.0.zip 191 | unzip -d tensorflow v1.6.0.zip 192 | cd tensorflow 193 | ``` 194 | 195 | Once in the directory, we have to write a nifty one-liner that is incredibly important. The next line goes through all files and changes references of 64-bit program implementations (which we don't have access to) to 32-bit implementations. Neat! 196 | 197 | ```shell 198 | grep -Rl 'lib64' | xargs sed -i 's/lib64/lib/g' 199 | ``` 200 | 201 | Next, we need to delete a particular line in `tensorflow/core/platform/platform.h`. Open up the file in your favorite text editor: 202 | 203 | ```shell 204 | sudo nano tensorflow/core/platform/platform.h 205 | ``` 206 | 207 | Now, scroll down toward the bottom and delete the following line containing `#define IS_MOBILE_PLATFORM` (around line 48): 208 | 209 | ```cpp 210 | #elif defined(__arm__) 211 | #define PLATFORM_POSIX 212 | ... 213 | #define IS_MOBILE_PLATFORM <----- DELETE THIS LINE 214 | ``` 215 | Now let's configure the build, enter options as entered below : 216 | 217 | ``` 218 | ./configure 219 | You have bazel 0.11.1- (@non-git) installed. 220 | Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3 221 | 222 | Found possible Python library paths: 223 | /usr/local/lib/python3.5/dist-packages 224 | /usr/lib/python3/dist-packages 225 | Please input the desired Python library path to use. Default is [/usr/local/lib/python3.5/dist-packages] 226 | 227 | Do you wish to build TensorFlow with jemalloc as malloc support? [Y/n]: y 228 | jemalloc as malloc support will be enabled for TensorFlow. 229 | 230 | Do you wish to build TensorFlow with Google Cloud Platform support? [Y/n]: n 231 | No Google Cloud Platform support will be enabled for TensorFlow. 232 | 233 | Do you wish to build TensorFlow with Hadoop File System support? [Y/n]: n 234 | No Hadoop File System support will be enabled for TensorFlow. 235 | 236 | Do you wish to build TensorFlow with Amazon S3 File System support? [Y/n]: n 237 | No Amazon S3 File System support will be enabled for TensorFlow. 238 | 239 | Do you wish to build TensorFlow with Apache Kafka Platform support? [y/N]: n 240 | No Apache Kafka Platform support will be enabled for TensorFlow. 241 | 242 | Do you wish to build TensorFlow with XLA JIT support? [y/N]: n 243 | No XLA JIT support will be enabled for TensorFlow. 244 | 245 | Do you wish to build TensorFlow with GDR support? [y/N]: n 246 | No GDR support will be enabled for TensorFlow. 247 | 248 | Do you wish to build TensorFlow with VERBS support? [y/N]: n 249 | No VERBS support will be enabled for TensorFlow. 250 | 251 | Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: n 252 | No OpenCL SYCL support will be enabled for TensorFlow. 253 | 254 | Do you wish to build TensorFlow with CUDA support? [y/N]: n 255 | No CUDA support will be enabled for TensorFlow. 256 | 257 | Do you wish to build TensorFlow with MPI support? [y/N]: n 258 | No MPI support will be enabled for TensorFlow. 259 | 260 | Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]: 261 | 262 | Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: n 263 | Not configuring the WORKSPACE for Android builds. 264 | 265 | Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See tools/bazel.rc for more details. 266 | --config=mkl # Build with MKL support. 267 | --config=monolithic # Config for mostly static monolithic build. 268 | --config=tensorrt # Build with TensorRT support. 269 | Configuration finished 270 | ``` 271 | Before building tensor one important step needs to be taken otherwise the resulted python wheel of TensorFlow will give you error when you try to import it inside python and that means you have wasted all of your precious time ! What we are going to do is commenting out some lines according to this [issue](https://github.com/tensorflow/tensorflow/issues/17986) : 272 | 273 | ```shell 274 | sed -i -e 's/#include "tensorflow\/core\/kernels\/concat_lib.h"/\/\/#include "tensorflow\/core\/kernels\/concat_lib.h"/g' core/kernels/list_kernels.h 275 | sed -i -e 's/#include "tensorflow\/core\/kernels\/concat_lib.h"/\/\/#include "tensorflow\/core\/kernels\/concat_lib.h"/g' core/kernels/list_kernels.cc 276 | sed -i -e 's/ConcatCPU(c->device(), inputs_flat, &output_flat);/\/\/ConcatCPU(c->device(), inputs_flat, &output_flat);/g' core/kernels/list_kernels.h 277 | ``` 278 | Now we are ready to build TensorFlow which on Orange Pi Zero is a little more time-consuming than 1GB RAM boards (when I say a little more it means maybe 3 to 10 times more !) so fire the command below and just leave your OPZ doing it's job while you check on it randomly. 279 | 280 | ```shell 281 | bazel build -c opt --copt="-mfpu=neon-vfpv4" --copt="-funsafe-math-optimizations" --copt="-ftree-vectorize" --copt="-fomit-frame-pointer" --local_resources 512,1.0,1.0 --verbose_failures tensorflow/tools/pip_package:build_pip_package 282 | ``` 283 | 284 | During build process, your Orange Pi Zero may freeze completely and you may not be able to reach it through ssh so it doesn't necessary mean that it is actually compiling anything and many times it means that you need to restart your device and run the above command again to continue the build process. I have provided some times in [tips](#some-tips) section to avoid these situations as much as possible. And finally you will see this line : 285 | 286 | ```shell 287 | INFO: Build completed successfully, 4 total actions 288 | ``` 289 | Now you can finally make a python wheel, issue the following command : 290 | 291 | ```shell 292 | bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg 293 | ``` 294 | This one will not take too much time and you can install your python package form `/tmp/tensorflow_pkg` directory : 295 | ```shell 296 | pip3 install --user /tmp/tensorflow_pkg/ensorflow-1.6.0-cp35-cp35m-linux_armv7l.whl 297 | ``` 298 | And your TensorFlow is ready to use. 299 | 300 | ## Cleaning Up 301 | 302 | There's one last bit of house-cleaning we need to do before we're done: remove the USB drive that we've been using as swap. 303 | 304 | First, turn off your drive as swap: 305 | 306 | ```shell 307 | sudo swapoff /dev/XXX 308 | ``` 309 | 310 | Finally, remove the line you wrote in `/etc/fstab` referencing the device 311 | 312 | ``` 313 | sudo nano /etc/fstab 314 | ``` 315 | 316 | Then reboot your Orange Pi. 317 | 318 | ## References 319 | 320 | 1. [tensorflow-on-raspberry-pi](https://github.com/samjabrahams/tensorflow-on-raspberry-pi) 321 | 2. [tensorflow-on-orange-pi](https://github.com/snowsquizy/tensorflow-on-orange-pi) 322 | 323 | ## Some Tips 324 | 325 | Here are some tips to build TensorFlow and Bazel as fast as possible while preventing from occasional freezes that can happen on Orange Pi Zero, these are my own experiences and may or may not work for you : 326 | 327 | * Use at least a 4GB flash memory drive (I saw some peaks of more than 1GB swap usage during my experience). 328 | * Use a USB3 flash memory drive (While OPZ has only USB2 port but because USB3 flash memories are generally faster even on USB2 ports they can speed up the process). 329 | * Disable any swap on SD card (Armbian comes with some swap space on SD card itself which slows down the building procedure, you can disable it from /etc/fstab) 330 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Installing TensorFlow on Orange Pi Zero (Compiled and tested on 512MB version) 3 | This repo provides 2 ways to install TensorFlow on Orange Pi Zero, the first and easy one is using a pre compiled python wheel and the second one is by compiling it yourself if the first one fails or if the wheel doesn't suit your needs. This repo can be considered as a fork of [this](https://github.com/samjabrahams/tensorflow-on-raspberry-pi) one but as I wanted to have different release files for Orange Pi only and keep it as clean as possible created it from scratch. 4 | ## Index 5 | 1. [Installing from wheel](#installing-from-wheel) 6 | 2. [Installing from source](#installing-from-source) 7 | 3. [Credits](#credits) 8 | 4. [License](#license) 9 | 10 | ## Installing from wheel 11 | **Note: These are unofficial binaries (though built from the minimally modified official source), and thus there is no expectation of support from the TensorFlow team. Please don't create issues for these files in the official TensorFlow repository.** 12 | 13 | Pre-built binary is built using Armbian 5.41 and is targeted for Orange Pi Zero running Armbian 5.41, so this method may or may not work for you. I currently only make wheels for latest versions of python 3.x available on Armbian. 14 | * Install Dependencies : `sudo apt update & sudo apt install python3-pip python3-dev` 15 | * Download latest release : `wget https://github.com/rezaxdi/tensorflow-on-orangepi-zero/releases/download/v1.6.0/tensorflow-1.6.0-cp35-cp35m-linux_armv7l.whl` 16 | * Install the wheel : `pip3 install --user tensorflow-1.6.0-cp35-cp35m-linux_armv7l.whl` 17 | 18 | ## Installing from source 19 | If the earlier method didn't work for you then you can build TensorFlow from the source. Orange Pi Zero suffers from lack of the memory and this can lead to occasional freezes during the build process even when you use lots of swap space so this is a process that can take more than 24 hour and even several days in the worst case. If you are ready follow the guide carefully, in the last part of the guide, I have provided some useful tips to prevent those occasional freezes as much as possible : 20 | 21 | [Building from source guide](https://github.com/rezaxdi/tensorflow-on-orangepi-zero/blob/master/GUIDE.md) 22 | 23 | ## Credits 24 | 25 | As told in the beginning this repo can be considered as a fork of @samjabrahams work so I will bring his repo credit section in continue but before that I want to add some more, it took a lot of time to compile binaries on Orange Pi Zero and after around 8 days [this](https://github.com/tensorflow/tensorflow/issues/17986) issue was just a lot of disappointment so thanks from @Lexicographical which finally made my binaries working in Orange Pi Zero. 26 | 27 | >While the final pieces of grunt work were done primarily by @samjabrahams and @petewarden, this effort has been going on for almost as long as TensorFlow has been open-source, and involves work that spans multiple months in separate codebases. This is an incomprehensive list of people and their work @samjabrahams ran across while working on this. 28 | 29 | >The majority of the source-building guide is a modified version of [these instructions for compiling TensorFlow on a Jetson TK1](http://cudamusing.blogspot.com/2015/11/building-tensorflow-for-jetson-tk1.html). Massimiliano, you are the real MVP. Note: the TK1 guide was [updated on June 17, 2016](http://cudamusing.blogspot.com/2016/06/tensorflow-08-on-jetson-tk1.html) 30 | 31 | >@vmayoral put a huge amount of time and effort trying to put together the pieces to build TensorFlow, and was the first to get something close to a working binary. 32 | 33 | >A bunch of awesome Googlers working in both the TensorFlow and Bazel repositories helped make this possible. In no particular order: @vrv, @damienmg, @petewarden, @danbri, @ulfjack, @girving, and @nlothian 34 | 35 | ## License 36 | 37 | The file RELEASE_LICENSE is TensorFlow's license file and applies to the binaries distributed in the [releases](https://github.com/rezaxdi/tensorflow-on-orangepi-zero/releases). 38 | 39 | The file LICENSE is for the repository itself. 40 | -------------------------------------------------------------------------------- /RELEASE_LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2018 The TensorFlow Authors. All rights reserved. 2 | 3 | Apache License 4 | Version 2.0, January 2004 5 | http://www.apache.org/licenses/ 6 | 7 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 8 | 9 | 1. Definitions. 10 | 11 | "License" shall mean the terms and conditions for use, reproduction, 12 | and distribution as defined by Sections 1 through 9 of this document. 13 | 14 | "Licensor" shall mean the copyright owner or entity authorized by 15 | the copyright owner that is granting the License. 16 | 17 | "Legal Entity" shall mean the union of the acting entity and all 18 | other entities that control, are controlled by, or are under common 19 | control with that entity. For the purposes of this definition, 20 | "control" means (i) the power, direct or indirect, to cause the 21 | direction or management of such entity, whether by contract or 22 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 23 | outstanding shares, or (iii) beneficial ownership of such entity. 24 | 25 | "You" (or "Your") shall mean an individual or Legal Entity 26 | exercising permissions granted by this License. 27 | 28 | "Source" form shall mean the preferred form for making modifications, 29 | including but not limited to software source code, documentation 30 | source, and configuration files. 31 | 32 | "Object" form shall mean any form resulting from mechanical 33 | transformation or translation of a Source form, including but 34 | not limited to compiled object code, generated documentation, 35 | and conversions to other media types. 36 | 37 | "Work" shall mean the work of authorship, whether in Source or 38 | Object form, made available under the License, as indicated by a 39 | copyright notice that is included in or attached to the work 40 | (an example is provided in the Appendix below). 41 | 42 | "Derivative Works" shall mean any work, whether in Source or Object 43 | form, that is based on (or derived from) the Work and for which the 44 | editorial revisions, annotations, elaborations, or other modifications 45 | represent, as a whole, an original work of authorship. For the purposes 46 | of this License, Derivative Works shall not include works that remain 47 | separable from, or merely link (or bind by name) to the interfaces of, 48 | the Work and Derivative Works thereof. 49 | 50 | "Contribution" shall mean any work of authorship, including 51 | the original version of the Work and any modifications or additions 52 | to that Work or Derivative Works thereof, that is intentionally 53 | submitted to Licensor for inclusion in the Work by the copyright owner 54 | or by an individual or Legal Entity authorized to submit on behalf of 55 | the copyright owner. For the purposes of this definition, "submitted" 56 | means any form of electronic, verbal, or written communication sent 57 | to the Licensor or its representatives, including but not limited to 58 | communication on electronic mailing lists, source code control systems, 59 | and issue tracking systems that are managed by, or on behalf of, the 60 | Licensor for the purpose of discussing and improving the Work, but 61 | excluding communication that is conspicuously marked or otherwise 62 | designated in writing by the copyright owner as "Not a Contribution." 63 | 64 | "Contributor" shall mean Licensor and any individual or Legal Entity 65 | on behalf of whom a Contribution has been received by Licensor and 66 | subsequently incorporated within the Work. 67 | 68 | 2. Grant of Copyright License. Subject to the terms and conditions of 69 | this License, each Contributor hereby grants to You a perpetual, 70 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 71 | copyright license to reproduce, prepare Derivative Works of, 72 | publicly display, publicly perform, sublicense, and distribute the 73 | Work and such Derivative Works in Source or Object form. 74 | 75 | 3. Grant of Patent License. Subject to the terms and conditions of 76 | this License, each Contributor hereby grants to You a perpetual, 77 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 78 | (except as stated in this section) patent license to make, have made, 79 | use, offer to sell, sell, import, and otherwise transfer the Work, 80 | where such license applies only to those patent claims licensable 81 | by such Contributor that are necessarily infringed by their 82 | Contribution(s) alone or by combination of their Contribution(s) 83 | with the Work to which such Contribution(s) was submitted. If You 84 | institute patent litigation against any entity (including a 85 | cross-claim or counterclaim in a lawsuit) alleging that the Work 86 | or a Contribution incorporated within the Work constitutes direct 87 | or contributory patent infringement, then any patent licenses 88 | granted to You under this License for that Work shall terminate 89 | as of the date such litigation is filed. 90 | 91 | 4. Redistribution. You may reproduce and distribute copies of the 92 | Work or Derivative Works thereof in any medium, with or without 93 | modifications, and in Source or Object form, provided that You 94 | meet the following conditions: 95 | 96 | (a) You must give any other recipients of the Work or 97 | Derivative Works a copy of this License; and 98 | 99 | (b) You must cause any modified files to carry prominent notices 100 | stating that You changed the files; and 101 | 102 | (c) You must retain, in the Source form of any Derivative Works 103 | that You distribute, all copyright, patent, trademark, and 104 | attribution notices from the Source form of the Work, 105 | excluding those notices that do not pertain to any part of 106 | the Derivative Works; and 107 | 108 | (d) If the Work includes a "NOTICE" text file as part of its 109 | distribution, then any Derivative Works that You distribute must 110 | include a readable copy of the attribution notices contained 111 | within such NOTICE file, excluding those notices that do not 112 | pertain to any part of the Derivative Works, in at least one 113 | of the following places: within a NOTICE text file distributed 114 | as part of the Derivative Works; within the Source form or 115 | documentation, if provided along with the Derivative Works; or, 116 | within a display generated by the Derivative Works, if and 117 | wherever such third-party notices normally appear. The contents 118 | of the NOTICE file are for informational purposes only and 119 | do not modify the License. You may add Your own attribution 120 | notices within Derivative Works that You distribute, alongside 121 | or as an addendum to the NOTICE text from the Work, provided 122 | that such additional attribution notices cannot be construed 123 | as modifying the License. 124 | 125 | You may add Your own copyright statement to Your modifications and 126 | may provide additional or different license terms and conditions 127 | for use, reproduction, or distribution of Your modifications, or 128 | for any such Derivative Works as a whole, provided Your use, 129 | reproduction, and distribution of the Work otherwise complies with 130 | the conditions stated in this License. 131 | 132 | 5. Submission of Contributions. Unless You explicitly state otherwise, 133 | any Contribution intentionally submitted for inclusion in the Work 134 | by You to the Licensor shall be under the terms and conditions of 135 | this License, without any additional terms or conditions. 136 | Notwithstanding the above, nothing herein shall supersede or modify 137 | the terms of any separate license agreement you may have executed 138 | with Licensor regarding such Contributions. 139 | 140 | 6. Trademarks. This License does not grant permission to use the trade 141 | names, trademarks, service marks, or product names of the Licensor, 142 | except as required for reasonable and customary use in describing the 143 | origin of the Work and reproducing the content of the NOTICE file. 144 | 145 | 7. Disclaimer of Warranty. Unless required by applicable law or 146 | agreed to in writing, Licensor provides the Work (and each 147 | Contributor provides its Contributions) on an "AS IS" BASIS, 148 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 149 | implied, including, without limitation, any warranties or conditions 150 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 151 | PARTICULAR PURPOSE. You are solely responsible for determining the 152 | appropriateness of using or redistributing the Work and assume any 153 | risks associated with Your exercise of permissions under this License. 154 | 155 | 8. Limitation of Liability. In no event and under no legal theory, 156 | whether in tort (including negligence), contract, or otherwise, 157 | unless required by applicable law (such as deliberate and grossly 158 | negligent acts) or agreed to in writing, shall any Contributor be 159 | liable to You for damages, including any direct, indirect, special, 160 | incidental, or consequential damages of any character arising as a 161 | result of this License or out of the use or inability to use the 162 | Work (including but not limited to damages for loss of goodwill, 163 | work stoppage, computer failure or malfunction, or any and all 164 | other commercial damages or losses), even if such Contributor 165 | has been advised of the possibility of such damages. 166 | 167 | 9. Accepting Warranty or Additional Liability. While redistributing 168 | the Work or Derivative Works thereof, You may choose to offer, 169 | and charge a fee for, acceptance of support, warranty, indemnity, 170 | or other liability obligations and/or rights consistent with this 171 | License. However, in accepting such obligations, You may act only 172 | on Your own behalf and on Your sole responsibility, not on behalf 173 | of any other Contributor, and only if You agree to indemnify, 174 | defend, and hold each Contributor harmless for any liability 175 | incurred by, or claims asserted against, such Contributor by reason 176 | of your accepting any such warranty or additional liability. 177 | 178 | END OF TERMS AND CONDITIONS 179 | 180 | APPENDIX: How to apply the Apache License to your work. 181 | 182 | To apply the Apache License to your work, attach the following 183 | boilerplate notice, with the fields enclosed by brackets "[]" 184 | replaced with your own identifying information. (Don't include 185 | the brackets!) The text should be enclosed in the appropriate 186 | comment syntax for the file format. We also recommend that a 187 | file or class name and description of purpose be included on the 188 | same "printed page" as the copyright notice for easier 189 | identification within third-party archives. 190 | 191 | Copyright 2017, The TensorFlow Authors. 192 | 193 | Licensed under the Apache License, Version 2.0 (the "License"); 194 | you may not use this file except in compliance with the License. 195 | You may obtain a copy of the License at 196 | 197 | http://www.apache.org/licenses/LICENSE-2.0 198 | 199 | Unless required by applicable law or agreed to in writing, software 200 | distributed under the License is distributed on an "AS IS" BASIS, 201 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 202 | See the License for the specific language governing permissions and 203 | limitations under the License. 204 | --------------------------------------------------------------------------------