torchvulkan 0.2.2__cp315-cp315-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -0,0 +1,170 @@
1
+ import atexit
2
+ import sys
3
+ from collections import namedtuple
4
+
5
+ try:
6
+ import torch
7
+ except ImportError as e:
8
+ raise ImportError("PyTorch is required to use torchvulkan. Please install PyTorch and try again.") from e
9
+
10
+ try:
11
+ from ._version import __version__
12
+ except ImportError:
13
+ __version__ = "unknown"
14
+
15
+ try:
16
+ from ._build_info import torch_version as _built_torch_version # pyright: ignore[reportMissingImports]
17
+ except ImportError:
18
+ _built_torch_version = None
19
+
20
+ def _torch_minor(version: str) -> tuple:
21
+ return tuple(version.split("+")[0].split(".")[:2])
22
+
23
+ if _built_torch_version and _torch_minor(torch.__version__) != _torch_minor(_built_torch_version):
24
+ _built = ".".join(_torch_minor(_built_torch_version))
25
+ raise RuntimeError(
26
+ f"torchvulkan [ERROR]: torchvulkan {__version__} was built for PyTorch {_built}.x, but found {torch.__version__}. "
27
+ f"Install torch=={_built}.* or a torchvulkan release built for your PyTorch version."
28
+ )
29
+
30
+ from . import _C
31
+
32
+ def is_available() -> bool:
33
+ return _C.is_available()
34
+
35
+ def device_count() -> int:
36
+ return _C.device_count()
37
+
38
+ def current_device() -> int:
39
+ return _C.current_device()
40
+
41
+ def set_device(device) -> None:
42
+ index = _device_index(device)
43
+ if index >= 0:
44
+ torch.accelerator.set_device_index(index)
45
+
46
+ def is_initialized() -> bool:
47
+ return _C._is_initialized()
48
+
49
+ def _lazy_init() -> None:
50
+ _C._lazy_init()
51
+
52
+ def device(dev):
53
+ index = dev if isinstance(dev, int) or dev is None else torch.device(dev).index
54
+ return torch.accelerator.device_index(index)
55
+
56
+ def synchronize(device=None) -> None:
57
+ _C.synchronize(_device_index(device))
58
+
59
+ def empty_cache() -> None:
60
+ _C.empty_cache()
61
+
62
+ def memory_allocated(device=None) -> int:
63
+ return _C._memory_allocated(_device_index(device))
64
+
65
+ def max_memory_allocated(device=None) -> int:
66
+ return _C._max_memory_allocated(_device_index(device))
67
+
68
+ def memory_reserved(device=None) -> int:
69
+ return _C._memory_usage(_device_index(device))
70
+
71
+ def mem_get_info(device=None) -> tuple:
72
+ return _C._mem_get_info(_device_index(device))
73
+
74
+ def reset_peak_memory_stats(device=None) -> None:
75
+ _C._reset_peak_memory_stats(_device_index(device))
76
+
77
+ def memory_stats(device=None) -> dict:
78
+ index = _device_index(device)
79
+ allocated = _C._memory_allocated(index)
80
+ peak = _C._max_memory_allocated(index)
81
+ return {
82
+ "active_bytes.all.current": allocated,
83
+ "active_bytes.all.peak": peak,
84
+ "allocated_bytes.all.current": allocated,
85
+ "allocated_bytes.all.peak": peak,
86
+ "reserved_bytes.all.current": _C._memory_usage(index),
87
+ }
88
+
89
+ DeviceProperties = namedtuple("DeviceProperties", ["name", "total_memory", "vendor_id", "device_id", "api_version", "driver_version", "subgroup_size"])
90
+
91
+ def get_device_properties(device=None) -> DeviceProperties:
92
+ return DeviceProperties(**_C._device_properties(_device_index(device)))
93
+
94
+ def get_device_name(device=None) -> str:
95
+ return get_device_properties(device).name
96
+
97
+ def _device_index(dev) -> int:
98
+ if isinstance(dev, int):
99
+ return dev
100
+ index = None if dev is None else torch.device(dev).index
101
+ return current_device() if index is None else index
102
+
103
+ def _default_generator(dev=None) -> torch.Generator:
104
+ return _C._default_generator(_device_index(dev))
105
+
106
+ def _get_generator(device) -> torch.Generator:
107
+ return _default_generator(device)
108
+
109
+ def __getattr__(name):
110
+ if name == "default_generators":
111
+ return tuple(_default_generator(index) for index in range(device_count()))
112
+ if name == "_initialized":
113
+ return is_initialized()
114
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
115
+
116
+ def _uint64_seed(seed) -> int:
117
+ seed = int(seed)
118
+ return seed + (1 << 64) if seed < 0 else seed
119
+
120
+ def manual_seed(seed) -> None:
121
+ _C._manual_seed(current_device(), _uint64_seed(seed))
122
+
123
+ def manual_seed_all(seed) -> None:
124
+ _C._manual_seed_all(_uint64_seed(seed))
125
+
126
+ def seed() -> None:
127
+ _default_generator().seed()
128
+
129
+ def seed_all() -> None:
130
+ random_seed = _default_generator(0).seed()
131
+ for index in range(1, device_count()):
132
+ _default_generator(index).manual_seed(random_seed)
133
+
134
+ def initial_seed() -> int:
135
+ return _default_generator().initial_seed()
136
+
137
+ def get_rng_state(device="vulkan") -> torch.Tensor:
138
+ return _default_generator(device).get_state()
139
+
140
+ def set_rng_state(new_state: torch.Tensor, device="vulkan") -> None:
141
+ _default_generator(device).set_state(new_state.clone(memory_format=torch.contiguous_format))
142
+
143
+ def get_rng_state_all() -> list:
144
+ return [get_rng_state(index) for index in range(device_count())]
145
+
146
+ def set_rng_state_all(new_states) -> None:
147
+ for index, state in enumerate(new_states):
148
+ set_rng_state(state, index)
149
+
150
+ def get_amp_supported_dtype() -> list:
151
+ return _C._amp_supported_dtypes(current_device())
152
+
153
+ def is_bf16_supported() -> bool:
154
+ return torch.bfloat16 in get_amp_supported_dtype()
155
+
156
+ def _is_in_bad_fork() -> bool:
157
+ return _C._is_in_bad_fork()
158
+
159
+ atexit.register(_C._save_pipeline_caches)
160
+
161
+ torch.utils.rename_privateuse1_backend('vulkan')
162
+ torch._register_device_module('vulkan', sys.modules[__name__])
163
+
164
+ def _tensor_to_vulkan(self, device=None, non_blocking=False, **kwargs) -> torch.Tensor:
165
+ return self.to(torch.device("vulkan", _device_index(device)), non_blocking=non_blocking, **kwargs)
166
+
167
+ # override torch.Tensor existing implementations for torch's own Vulkan backend
168
+ torch.Tensor.vulkan = _tensor_to_vulkan
169
+ torch.Tensor.is_vulkan = property(lambda self: self.device.type == "vulkan")
170
+ torch.utils.generate_methods_for_privateuse1_backend(for_tensor=False)
@@ -0,0 +1 @@
1
+ torch_version = "2.15.0"
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.2.2'
22
+ __version_tuple__ = version_tuple = (0, 2, 2)
23
+
24
+ __commit_id__ = commit_id = None
@@ -0,0 +1,224 @@
1
+ Metadata-Version: 2.4
2
+ Name: torchvulkan
3
+ Version: 0.2.2
4
+ Summary: Cross-Platform Vulkan Backend for PyTorch
5
+ Author: Zain Sharief
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ License-File: licenses/MoltenVK-LICENSE
9
+ Project-URL: Homepage, https://github.com/zainsharief/torchvulkan
10
+ Project-URL: Repository, https://github.com/zainsharief/torchvulkan
11
+ Project-URL: Issues, https://github.com/zainsharief/torchvulkan/issues
12
+ Requires-Python: >=3.11
13
+ Requires-Dist: torch<2.16,>=2.15.0
14
+ Provides-Extra: test
15
+ Requires-Dist: pytest; extra == "test"
16
+ Requires-Dist: tox; extra == "test"
17
+ Description-Content-Type: text/markdown
18
+
19
+ <h1 align="center">torchvulkan</h1>
20
+ <p align="center">
21
+ <i>A Cross-Platform Vulkan Backend for PyTorch</i>
22
+ </p>
23
+
24
+ <p align="center">
25
+ <a href="https://github.com/zainsharief/torchvulkan/actions/workflows/test_torchvulkan.yml"><img alt="CI" src="https://github.com/zainsharief/torchvulkan/actions/workflows/test_torchvulkan.yml/badge.svg"></a>
26
+ <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-blue.svg"></a>
27
+ <img alt="Python 3.11+" src="https://img.shields.io/badge/python-3.11%2B-blue">
28
+ <img alt="Status: experimental" src="https://img.shields.io/badge/status-experimental-orange">
29
+ </p>
30
+
31
+ `torchvulkan` registers a `vulkan` device with PyTorch and runs tensor operations as [Vulkan](https://www.vulkan.org/) compute shaders. Vulkan runs on GPUs from AMD, Intel, NVIDIA, and Apple (via MoltenVK), plus software rasterizers, so you get one vendor-neutral GPU backend across Linux, macOS, and Windows.
32
+
33
+ You use it like any other PyTorch device:
34
+
35
+ ```python
36
+ import torch
37
+ import torchvulkan # registers the 'vulkan' device on import
38
+
39
+ x = torch.randn(1024, 1024).to("vulkan")
40
+ y = torch.randn(1024, 1024).to("vulkan")
41
+
42
+ z = (x @ y).relu() # runs on the GPU via Vulkan compute shaders
43
+ print(z.sum().item()) # move a scalar back to the CPU
44
+ ```
45
+
46
+ > [!WARNING]
47
+ > **Experimental.** `torchvulkan` is an early-stage project. Most of PyTorch's operators run natively on the GPU; the few that don't fall back to the CPU. Expect breaking changes before `1.0`.
48
+
49
+ ## Table of contents
50
+
51
+ - [Installation](#installation)
52
+ - [Quickstart](#quickstart)
53
+ - [Examples](#examples)
54
+ - [Benchmarks](#benchmarks)
55
+ - [Python API](#python-api)
56
+ - [CPU fallback](#cpu-fallback)
57
+ - [Environment variables](#environment-variables)
58
+ - [Limitations](#limitations)
59
+ - [How it works](#how-it-works)
60
+
61
+ ## Installation
62
+
63
+ ```bash
64
+ pip install torchvulkan
65
+ ```
66
+
67
+ At runtime you need a **Vulkan 1.3 (or newer) driver**: your GPU's driver on Linux and Windows. On macOS the wheel bundles [MoltenVK](https://github.com/KhronosGroup/MoltenVK), so nothing else is needed; set `TORCHVULKAN_SYSTEM_VULKAN=1` to use the system Vulkan loader instead. Verify it worked:
68
+
69
+ ```python
70
+ import torchvulkan
71
+ print(torchvulkan.is_available(), torchvulkan.device_count())
72
+ ```
73
+
74
+ ## Quickstart
75
+
76
+ ```python
77
+ import torch
78
+ import torchvulkan
79
+
80
+ # Move tensors to the Vulkan device
81
+ a = torch.tensor([[1.0, 2.0], [3.0, 4.0]], device="vulkan")
82
+ b = torch.ones(2, 2, device="vulkan")
83
+
84
+ c = a @ b + 1.0 # matmul + broadcasted add
85
+ d = c.exp().sum(dim=0) # elementwise + reduction
86
+
87
+ print(d.cpu()) # bring the result back to the CPU
88
+ ```
89
+
90
+ `nn.Module`s move to the device the usual way:
91
+
92
+ ```python
93
+ model = torch.nn.Linear(128, 10).to("vulkan")
94
+ out = model(torch.randn(32, 128).to("vulkan"))
95
+ ```
96
+
97
+ ## Examples
98
+
99
+ Each example trains a model end to end on the Vulkan device: forward pass, loss, backward pass and optimizer step all run through the backend.
100
+
101
+ | Example | Model | Data |
102
+ | --- | --- | --- |
103
+ | [`examples/mlp.py`](examples/mlp.py) | A multi-layer perceptron with GELU and dropout, trained with AdamW | MNIST |
104
+ | [`examples/llm.py`](examples/llm.py) | A small modern decoder-only transformer: RMSNorm, rotary embeddings, grouped-query attention, a SwiGLU MLP and tied embeddings. Samples text when it's done | Its own source code, character by character |
105
+ | [`examples/resnet.py`](examples/resnet.py) | A ResNet with residual blocks, batch norm and global average pooling, trained with SGD and a one-cycle schedule | CIFAR-10 |
106
+
107
+ ```bash
108
+ pip install torchvision # for the MNIST and CIFAR-10 datasets
109
+ python examples/mlp.py
110
+ python examples/llm.py
111
+ python examples/resnet.py
112
+ ```
113
+
114
+ Training looks the same as on any other device:
115
+
116
+ ```python
117
+ device = torch.device("vulkan" if torchvulkan.is_available() else "cpu")
118
+ model = ResNet().to(device)
119
+ optimizer = torch.optim.SGD(model.parameters(), lr=0.1, momentum=0.9)
120
+
121
+ for data, targets in train_loader:
122
+ data, targets = data.to(device), targets.to(device)
123
+ loss = criterion(model(data), targets)
124
+ optimizer.zero_grad()
125
+ loss.backward()
126
+ optimizer.step()
127
+ ```
128
+
129
+ ## Benchmarks
130
+
131
+ [`benchmark/benchmark.py`](benchmark/benchmark.py) times a combined forward + backward pass (`float16` on accelerators, `float32` on CPU) on every available backend, sweeping each model's size. Each backend runs in its own subprocess. The models are the ones from the [examples](#examples):
132
+
133
+ - `mlp`: sweeps the hidden width, up to ~141M parameters.
134
+ - `llm`: sweeps the model width (`n_embd`), up to ~26M parameters.
135
+ - `resnet`: sweeps the base channel width, up to ~6M parameters.
136
+
137
+ <p align="center">
138
+ <img alt="Forward + backward pass time vs. model size for the MLP, LLM and ResNet on an NVIDIA GPU: vulkan vs. CUDA and CPU" src="media/benchmark-cuda.png" width="100%">
139
+ </p>
140
+
141
+ <p align="center">
142
+ <i>Vulkan vs. CUDA vs. CPU.</i>
143
+ </p>
144
+
145
+ ```bash
146
+ pip install matplotlib
147
+ python benchmark/benchmark.py all # every model
148
+ ```
149
+
150
+ ## Python API
151
+
152
+ `torchvulkan` mirrors the `torch.cuda` module, and is also reachable as `torch.vulkan`:
153
+
154
+ ```python
155
+ import torchvulkan
156
+
157
+ # devices
158
+ torchvulkan.is_available() # -> bool: a usable Vulkan device was found
159
+ torchvulkan.device_count() # -> int: number of Vulkan devices (discrete GPUs first)
160
+ torchvulkan.current_device() # -> int: index of the current device
161
+ torchvulkan.set_device(1) # make "vulkan" mean "vulkan:1"
162
+ torchvulkan.get_device_name() # -> str
163
+ torchvulkan.get_device_properties() # -> name, total_memory, vendor_id, api_version, subgroup_size, ...
164
+ torchvulkan.synchronize() # block until queued GPU work has finished
165
+
166
+ # memory
167
+ torchvulkan.memory_allocated() # bytes held by tensors
168
+ torchvulkan.max_memory_allocated() # peak since the last reset_peak_memory_stats()
169
+ torchvulkan.memory_reserved() # bytes held by the allocator, including its cache
170
+ torchvulkan.memory_stats() # -> dict
171
+ torchvulkan.mem_get_info() # -> (free, total): what can be allocated given the budget
172
+ torchvulkan.empty_cache() # release cached device memory back to the driver
173
+
174
+ # random numbers (per-device)
175
+ torchvulkan.manual_seed(0) # also: manual_seed_all, seed, seed_all, initial_seed
176
+ torchvulkan.get_rng_state() # also: set_rng_state, get_rng_state_all, set_rng_state_all
177
+
178
+ torchvulkan.is_bf16_supported() # -> bool: bfloat16 runs on the GPU
179
+ torchvulkan.__version__ # package version
180
+ ```
181
+
182
+ Importing `torchvulkan` registers the backend, after which the device is addressed as `"vulkan"` / `torch.device("vulkan")` throughout PyTorch.
183
+
184
+ ## CPU fallback
185
+
186
+ By default, any operation, dtype, or tensor shape the backend doesn't implement natively runs on the **CPU**, so models keep working despite partial coverage. The warning is printed once, for the first operation that falls back; call `torch.set_warn_always(True)` to see every one.
187
+
188
+ Set `TORCHVULKAN_STRICT=1` to turn those silent fallbacks into errors. This is useful for finding which operators a workload actually needs:
189
+
190
+ ```bash
191
+ TORCHVULKAN_STRICT=1 python your_script.py
192
+ ```
193
+
194
+ ## Environment variables
195
+
196
+ | Variable | Effect |
197
+ | --- | --- |
198
+ | `TORCHVULKAN_STRICT=1` | Raise an error instead of falling back to the CPU. |
199
+ | `TORCHVULKAN_STRICT_ALLOCATION=1` | Raise an out-of-memory error instead of allocating past the VRAM budget. By default torchvulkan allocates anyway (with a one-time warning), and the driver may put the memory in system RAM, which is much slower. |
200
+ | `TORCHVULKAN_SYSTEM_VULKAN=1` | macOS: use the system Vulkan loader instead of the bundled MoltenVK. |
201
+ | `TORCHVULKAN_VALIDATION=1` | Enable the Khronos validation layer, if it's installed. `=sync` also enables synchronization validation. On macOS this needs `TORCHVULKAN_SYSTEM_VULKAN=1`. |
202
+ | `TORCHVULKAN_PROFILE=1` | Print each compute pipeline's driver statistics (such as register use) when it's compiled, on drivers that support `VK_KHR_pipeline_executable_properties`. |
203
+ | `TORCHVULKAN_PIPELINE_CACHE=0` | Don't cache compiled pipelines between runs. By default they're cached in `%LOCALAPPDATA%\torchvulkan` on Windows and `$XDG_CACHE_HOME/torchvulkan` (or `~/.cache/torchvulkan`) elsewhere. |
204
+ | `TORCHVULKAN_CACHE_DIR` | Directory for the pipeline cache. |
205
+
206
+ ## Limitations
207
+
208
+ - `torch.compile` with the default Inductor backend doesn't support the `vulkan` device. Run eagerly, or use `torch.compile(model, backend="aot_eager")`.
209
+ - Optimizers created with `fused=True` (such as `torch.optim.AdamW(..., fused=True)`) run their update on the CPU. The default (foreach) implementation runs on the GPU.
210
+ - `float64` runs on the GPU only on devices with `shaderFloat64`; elsewhere it falls back to the CPU. Transcendental functions such as `exp`, `sin` and `tanh` are computed in `float32` precision for `float64` tensors.
211
+ - `bfloat16` runs on the GPU only on devices with `VK_KHR_shader_bfloat16`; elsewhere it falls back to the CPU.
212
+ - Complex tensors can live on the device and FFTs run on the GPU, but most complex arithmetic falls back to the CPU.
213
+ - APIs and coverage may change before `1.0.0`.
214
+
215
+ ## How it works
216
+
217
+ 1. Importing the package registers a PyTorch `PrivateUse1` backend and renames it to `vulkan`.
218
+ 2. Operations dispatched to a `vulkan` tensor are routed to native implementations that record and submit **Vulkan compute shaders**. The shaders are written in [Slang](https://github.com/shader-slang/slang), compiled to SPIR-V at build time, and embedded into the extension.
219
+ 3. Device memory is managed with [VMA](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator); Vulkan entry points are loaded with [volk](https://github.com/zeux/volk).
220
+ 4. Anything without a native implementation is handled by [CPU fallback](#cpu-fallback).
221
+
222
+
223
+ > [!NOTE]
224
+ > **Disclaimer:** `torchvulkan` is an independent open-source project and is not affiliated with or endorsed by PyTorch or the Linux Foundation.
@@ -0,0 +1,9 @@
1
+ torchvulkan/__init__.py,sha256=5kNIuv8ybkCX19aNngYKSt0pVUuGedV44oqbG7OQxD8,5773
2
+ torchvulkan/_build_info.py,sha256=Yodeal3z1KbVSxiOZi8E_69_G54NU76EDe8tYDyrPSQ,26
3
+ torchvulkan/_C.cp315-win_amd64.pyd,sha256=se2wWhsOBAwCJKk9IxXyz8_dAeW4Fck1G5P1XUdlbww,20277760
4
+ torchvulkan/_version.py,sha256=32hf8oYWbnR5-IBkvDH6Xr2PwqXkA3Qk_Rg8kcFQMjQ,544
5
+ torchvulkan-0.2.2.dist-info/METADATA,sha256=19uSYC0gseov8Fd82E4a0pFdp606Km6dabJfHMNhFjo,10542
6
+ torchvulkan-0.2.2.dist-info/WHEEL,sha256=m_QT_bq-mMsHZpYGIpEBVccZC7Hu7h_-ha-581a-KNs,105
7
+ torchvulkan-0.2.2.dist-info/licenses/LICENSE,sha256=8JFuWZVWpdcfQYvjXUic7cAzqRw5ZOfIz1wcL8Ir4sc,1087
8
+ torchvulkan-0.2.2.dist-info/licenses/licenses/MoltenVK-LICENSE,sha256=Pd-b5cKP4n2tFDpdx27qJSIq0d1ok0oEcGTlbtL6QMU,11560
9
+ torchvulkan-0.2.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: scikit-build-core 1.1.2
3
+ Root-Is-Purelib: false
4
+ Tag: cp315-cp315-win_amd64
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 torchvulkan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.