├── requirements-z.txt ├── .gitignore ├── requirements.txt ├── MAINTAINERS.md ├── .github └── dco.yml ├── CONTRIBUTING.md ├── Dockerfile ├── Dockerfile.s390x ├── README.md ├── torch_export_onnx.ipynb ├── tfonnx_conversion.ipynb └── LICENSE /requirements-z.txt: -------------------------------------------------------------------------------- 1 | jupyter 2 | tf2onnx 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | *.log 4 | .vscode/settings.json 5 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | tensorflow==2.7 2 | torch==1.11 3 | jupyter 4 | tf2onnx 5 | -------------------------------------------------------------------------------- /MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | # MAINTAINERS 2 | 3 | Andrew M. Sica - andrewsi@us.ibm.com 4 | Steve Lafalce - slafalce@us.ibm.com 5 | -------------------------------------------------------------------------------- /.github/dco.yml: -------------------------------------------------------------------------------- 1 | # This enables DCO bot for you, please take a look https://github.com/probot/dco 2 | # for more details. 3 | require: 4 | members: false 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing In General 2 | Our project welcomes external contributions. If you have an itch, please feel 3 | free to scratch it. 4 | 5 | To contribute code or documentation, please submit a [pull request](https://github.com/ibm/ai-on-z-samples/pulls). 6 | 7 | A good way to familiarize yourself with the codebase and contribution process is 8 | to look for and tackle low-hanging fruit in the [issue tracker](https://github.com/ibm/ai-on-z-samples/issues). 9 | 10 | ``` 11 | /* 12 | Copyright All Rights Reserved. 13 | 14 | SPDX-License-Identifier: Apache-2.0 15 | */ 16 | ``` 17 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # © Copyright IBM Corporation 2022. 2 | # LICENSE: Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) 3 | 4 | ################ Dockerfile for ONNX conversion lab ################################# 5 | # 6 | # This Dockerfile is intended for demonstration purposes to highlight simple 7 | # scenarios of converting TensorFlow and Torch models to ONNX 8 | # 9 | ##################################################################################### 10 | 11 | FROM python:3.8-slim 12 | 13 | RUN apt update && \ 14 | apt install --no-install-recommends -y build-essential gcc && \ 15 | apt clean && rm -rf /var/lib/apt/lists/* 16 | COPY ./requirements.txt /requirements.txt 17 | COPY ./tfonnx_conversion.ipynb /notebooks/ 18 | COPY ./torch_export_onnx.ipynb /notebooks/ 19 | 20 | RUN pip3 install --no-cache-dir -r requirements.txt 21 | 22 | WORKDIR /notebooks 23 | CMD jupyter notebook --allow-root --ip 0.0.0.0 --port 8888 -------------------------------------------------------------------------------- /Dockerfile.s390x: -------------------------------------------------------------------------------- 1 | # © Copyright IBM Corporation 2022. 2 | # LICENSE: Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) 3 | 4 | ################ Dockerfile for ONNX conversion lab ################################# 5 | # 6 | # This Dockerfile is intended for demonstration purposes to highlight simple 7 | # scenarios of converting TensorFlow and Torch models to ONNX 8 | # 9 | ##################################################################################### 10 | 11 | FROM icr.io/ibmz/tensorflow:2.7-opts-vector 12 | 13 | ARG DEBIAN_FRONTEND="noninteractive" 14 | 15 | RUN apt-get update && apt-get install -y \ 16 | software-properties-common \ 17 | cmake \ 18 | protobuf-compiler 19 | 20 | COPY ./tfonnx_conversion.ipynb /notebooks/ 21 | 22 | RUN pip3 install --upgrade pip \ 23 | && pip3 install --no-cache-dir \ 24 | onnx \ 25 | tf2onnx \ 26 | jupyter 27 | 28 | WORKDIR /notebooks 29 | CMD jupyter notebook --allow-root --ip 0.0.0.0 --port 8888 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lab exercises: Exporting or converting a model to the ONNX format 2 | 3 | ## Overview 4 | This project contains simple jupyter notebook lab exercises demonstrating [ONNX](https://github.com/onnx/onnx) model conversion. This includes: 5 | - Exporting a simple model from [Pytorch](https://github.com/pytorch/pytorch) to ONNX format. 6 | - Converting a tensorflow model to ONNX, using [tensorflow-onnx](https://github.com/onnx/tensorflow-onnx). 7 | 8 | These examples require you install needed packages. This is not done as part of the notebook; the steps here will guide you through building and running a docker container to complete the lab exercises. 9 | 10 | This lab is intended to be run on an x86/x64 environment to demonstrate converting a trained model to ONNX prior to deploying on IBM zSystems and LinuxONE. 11 | 12 | ## Steps: 13 | 14 | 1. Clone the lab github repository `git clone https://github.com/IBM/ai-on-z-samples.git` 15 | 16 | 2. Navigate to the subdirectoy. 17 | 18 | 3. Run docker build using the provided dockerfile `docker build .` 19 | - Using a python base image, this will create an environment with both recent Pytorch and TensorFlow releases, model conversion libraries, as well as the lab jupyter notebooks. 20 | 21 | 4. Create and run a docker container using the image created on the prior step. As part of this step, you should map the jupyter notebook port, 8888, to a port on your local system. An example follows: 22 | - `docker run -it --rm -p 8571:8888 ` 23 | - This states the image in interactive mode, tells docker to delete the container upon exit, and publishes container port 8888 to host port 8571. 24 | 25 | 5. From a web browser, connect to the jupyter URL provided on the prior step. Note, you must change port 8888 to port 8571. 26 | 27 | 6. Run through the lab exercises: 28 | - tfonnx_conversion.ipynb 29 | - torch_export_onnx.ipynb 30 | 31 | 7. Download the .ONNX models and inspect them using [Netron](https://netron.app/) 32 | 33 | 34 | ## Additional resources 35 | 36 | There are numerous additional examples and guidance available, not only for Pytorch and TensorFlow, but for other frameworks as well. 37 | 38 | This includes: 39 | - Building, exporting or converting a model [here](https://onnx.ai/supported-tools.html) 40 | - tensorflow-onnx [examples](https://github.com/onnx/tensorflow-onnx/tree/master/examples) 41 | - pytorch [guidance and examples](https://pytorch.org/tutorials/advanced/super_resolution_with_onnxruntime.html) 42 | 43 | 44 | On IBM Z and LinuxONE, you can run these models using [ONNX-MLIR](https://github.com/onnx/onnx-mlir). 45 | For z/OS users, we recommend you try Watson Machine Learning for z/OS Trial edition, available [here](https://www.ibm.com/products/machine-learning-for-zos). 46 | 47 | -------------------------------------------------------------------------------- /torch_export_onnx.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Exporting a PyTorch model to ONNX natively using PyTorch." 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "_Note: This example borrows from a PyTorch sample test used in BentoML_\n", 15 | "\n", 16 | "# Section 1: Create a simple PyTorch model." 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "metadata": {}, 22 | "source": [ 23 | "## Section 1.1: Import the packages we need:" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": null, 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "import torch\n", 33 | "import torch.nn as nn\n", 34 | "import torch.nn.functional as F\n", 35 | "import numpy as np" 36 | ] 37 | }, 38 | { 39 | "cell_type": "markdown", 40 | "metadata": {}, 41 | "source": [ 42 | "## Section 1.2: Build a simple model using the PyTorch function capability." 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": null, 48 | "metadata": {}, 49 | "outputs": [], 50 | "source": [ 51 | "class Net(nn.Module):\n", 52 | " def __init__(self):\n", 53 | " super().__init__()\n", 54 | "\n", 55 | " self.linear = nn.Linear(5, 1, bias=False)\n", 56 | " torch.nn.init.ones_(self.linear.weight)\n", 57 | "\n", 58 | " def forward(self, x):\n", 59 | " x = self.linear(x)\n", 60 | "\n", 61 | " return x" 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": {}, 67 | "source": [ 68 | "## Section 1.3: Test our model - it should return a result of 15." 69 | ] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "execution_count": null, 74 | "metadata": {}, 75 | "outputs": [], 76 | "source": [ 77 | "numpy_data = np.array([[1, 2, 3, 4, 5]], dtype=np.float32)\n", 78 | "input_tensor = torch.from_numpy(numpy_data)\n", 79 | "\n", 80 | "my_nn = Net()\n", 81 | "result = my_nn(input_tensor)\n", 82 | "print (result)" 83 | ] 84 | }, 85 | { 86 | "cell_type": "markdown", 87 | "metadata": {}, 88 | "source": [ 89 | "# Section 2: Convert our simple linear model using PyTorch built-in ONNX export capabilities" 90 | ] 91 | }, 92 | { 93 | "cell_type": "markdown", 94 | "metadata": {}, 95 | "source": [ 96 | "The PyTorch to ONNX export capability is invoked through a Python API as shown here. \n", 97 | "\n", 98 | "In our example, a model we created is being exported to ONNX; an existing model can be loaded and exported through the same mechanisms.\n", 99 | "\n", 100 | "Details on the full set of ONNX capabilities can be found here: \n", 101 | "https://pytorch.org/docs/stable/onnx.html" 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": null, 107 | "metadata": { 108 | "tags": [] 109 | }, 110 | "outputs": [], 111 | "source": [ 112 | "import torch.onnx\n", 113 | "\n", 114 | "torch.onnx.export(my_nn, # model being run\n", 115 | " input_tensor, # model input (or a tuple for multiple inputs)\n", 116 | " \"torch_matmul.onnx\") # output file name" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": null, 122 | "metadata": {}, 123 | "outputs": [], 124 | "source": [ 125 | "help(torch.onnx.export)" 126 | ] 127 | } 128 | ], 129 | "metadata": { 130 | "kernelspec": { 131 | "display_name": "Python 3", 132 | "language": "python", 133 | "name": "python3" 134 | }, 135 | "language_info": { 136 | "codemirror_mode": { 137 | "name": "ipython", 138 | "version": 3 139 | }, 140 | "file_extension": ".py", 141 | "mimetype": "text/x-python", 142 | "name": "python", 143 | "nbconvert_exporter": "python", 144 | "pygments_lexer": "ipython3", 145 | "version": "3.8.10" 146 | } 147 | }, 148 | "nbformat": 4, 149 | "nbformat_minor": 5 150 | } 151 | -------------------------------------------------------------------------------- /tfonnx_conversion.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "dd2dc185", 6 | "metadata": { 7 | "tags": [] 8 | }, 9 | "source": [ 10 | "# Converting a TensorFlow model to ONNX using TensorFlow-ONNX (TFONNX)" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "id": "2a6df7ad-6920-4136-b659-a15c0869a327", 16 | "metadata": {}, 17 | "source": [ 18 | "_Note: This example borrows from a PyTorch sample test used in BentoML_" 19 | ] 20 | }, 21 | { 22 | "cell_type": "markdown", 23 | "id": "60544eea", 24 | "metadata": {}, 25 | "source": [ 26 | "# Section 1: Create a simple TensorFlow model." 27 | ] 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "id": "cbb2458a", 32 | "metadata": {}, 33 | "source": [ 34 | "## Section 1.1: Import the packages we need:" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": null, 40 | "id": "8b9e4ac0", 41 | "metadata": {}, 42 | "outputs": [], 43 | "source": [ 44 | "import numpy as np\n", 45 | "import tensorflow as tf" 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "id": "ca0783d3", 51 | "metadata": {}, 52 | "source": [ 53 | "## Section 1.2: Build a simple model using the TensorFlow function capability." 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": null, 59 | "id": "13ffa16b", 60 | "metadata": {}, 61 | "outputs": [], 62 | "source": [ 63 | "class simplematmul(tf.Module):\n", 64 | " def __init__(self):\n", 65 | " super().__init__()\n", 66 | " self.weights = np.asfarray([[1.0], [1.0], [1.0], [1.0], [1.0]], dtype=np.float32)\n", 67 | " self.dense = lambda inputs: tf.matmul(inputs, self.weights)\n", 68 | "\n", 69 | " @tf.function(input_signature=[tf.TensorSpec(shape=[1, 5], dtype=tf.float32, name='inputs')])\n", 70 | " def __call__(self, inputs):\n", 71 | " return self.dense(inputs)\n" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": null, 77 | "id": "32f731a5", 78 | "metadata": {}, 79 | "outputs": [], 80 | "source": [ 81 | "# Create an instance of our model:\n", 82 | "model1 = simplematmul()" 83 | ] 84 | }, 85 | { 86 | "cell_type": "markdown", 87 | "id": "94b91231", 88 | "metadata": {}, 89 | "source": [ 90 | "## Section 1.3: Test our model - it should return a result of 15." 91 | ] 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": null, 96 | "id": "7d98af92", 97 | "metadata": {}, 98 | "outputs": [], 99 | "source": [ 100 | "# Let's create test data to make sure our model is working\n", 101 | "test_data = np.array([[1, 2, 3, 4, 5]], dtype=np.float32)\n", 102 | "test_tensor = np.asfarray(test_data)" 103 | ] 104 | }, 105 | { 106 | "cell_type": "code", 107 | "execution_count": null, 108 | "id": "1fc84da3", 109 | "metadata": {}, 110 | "outputs": [], 111 | "source": [ 112 | "print(model1(test_tensor))" 113 | ] 114 | }, 115 | { 116 | "cell_type": "markdown", 117 | "id": "d6a7fcbf", 118 | "metadata": {}, 119 | "source": [ 120 | "## Section 1.4: Save our model. " 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": null, 126 | "id": "2b1b5a49", 127 | "metadata": {}, 128 | "outputs": [], 129 | "source": [ 130 | "saved_dir = './tmp'\n", 131 | "tf.saved_model.save(model1, './tmp',signatures=model1.__call__.get_concrete_function(\n", 132 | " tf.TensorSpec(shape=[1, 5], dtype=tf.float32, name='inputs')))" 133 | ] 134 | }, 135 | { 136 | "cell_type": "markdown", 137 | "id": "e9953cf4", 138 | "metadata": {}, 139 | "source": [ 140 | "# Section 2: Convert our simple matrix multiply model using TFONNX" 141 | ] 142 | }, 143 | { 144 | "cell_type": "markdown", 145 | "id": "f2a96f1a", 146 | "metadata": {}, 147 | "source": [ 148 | "## Section 2.1 Model Conversion with tensorflow-onnx\n", 149 | "\n", 150 | "tensorflow-onnx is an open-source onnx model convertor, available through PYPI and from source here: https://github.com/onnx/tensorflow-onnx \n", 151 | "\n", 152 | "tensorflow-onnx can convert TensorFlow, TF.Keras and tflite models to the ONNX format.\n", 153 | "Both command line and python API conversion is supported. \n", 154 | "\n", 155 | "The command line tool is much simpler to use for most use cases.\n", 156 | "\n", 157 | "We recommend you always convert your model on the platform you trained it on. (i.e. if trained on Z, convert on Z)" 158 | ] 159 | }, 160 | { 161 | "cell_type": "code", 162 | "execution_count": null, 163 | "id": "4c7c4673", 164 | "metadata": {}, 165 | "outputs": [], 166 | "source": [ 167 | "# Execute tensorflow-onnx command line tool, specifying a target opset of 11 to target for ONNX\n", 168 | "!python -m tf2onnx.convert --opset 11 --saved-model $saved_dir --output tf_matmul.onnx" 169 | ] 170 | }, 171 | { 172 | "cell_type": "code", 173 | "execution_count": null, 174 | "id": "ff4f2351", 175 | "metadata": {}, 176 | "outputs": [], 177 | "source": [] 178 | } 179 | ], 180 | "metadata": { 181 | "interpreter": { 182 | "hash": "5b1396a34a05c172adb1f027fd5e1f06a0f31bc6679d97029342dad39b0921b5" 183 | }, 184 | "kernelspec": { 185 | "display_name": "Python 3", 186 | "language": "python", 187 | "name": "python3" 188 | }, 189 | "language_info": { 190 | "codemirror_mode": { 191 | "name": "ipython", 192 | "version": 3 193 | }, 194 | "file_extension": ".py", 195 | "mimetype": "text/x-python", 196 | "name": "python", 197 | "nbconvert_exporter": "python", 198 | "pygments_lexer": "ipython3", 199 | "version": "3.8.10" 200 | } 201 | }, 202 | "nbformat": 4, 203 | "nbformat_minor": 5 204 | } 205 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | --------------------------------------------------------------------------------