Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +3 -0
- .venv/lib/python3.11/site-packages/compressed_tensors-0.9.1.dist-info/INSTALLER +1 -0
- .venv/lib/python3.11/site-packages/compressed_tensors-0.9.1.dist-info/LICENSE +201 -0
- .venv/lib/python3.11/site-packages/compressed_tensors-0.9.1.dist-info/METADATA +159 -0
- .venv/lib/python3.11/site-packages/compressed_tensors-0.9.1.dist-info/RECORD +100 -0
- .venv/lib/python3.11/site-packages/compressed_tensors-0.9.1.dist-info/WHEEL +5 -0
- .venv/lib/python3.11/site-packages/compressed_tensors-0.9.1.dist-info/top_level.txt +1 -0
- .venv/lib/python3.11/site-packages/httptools-0.6.4.dist-info/INSTALLER +1 -0
- .venv/lib/python3.11/site-packages/httptools-0.6.4.dist-info/LICENSE +21 -0
- .venv/lib/python3.11/site-packages/httptools-0.6.4.dist-info/METADATA +133 -0
- .venv/lib/python3.11/site-packages/httptools-0.6.4.dist-info/RECORD +21 -0
- .venv/lib/python3.11/site-packages/httptools-0.6.4.dist-info/WHEEL +8 -0
- .venv/lib/python3.11/site-packages/httptools-0.6.4.dist-info/top_level.txt +1 -0
- .venv/lib/python3.11/site-packages/httptools/parser/parser.cpython-311-x86_64-linux-gnu.so +3 -0
- .venv/lib/python3.11/site-packages/httptools/parser/url_parser.cpython-311-x86_64-linux-gnu.so +3 -0
- .venv/lib/python3.11/site-packages/networkx/utils/__pycache__/backends.cpython-311.pyc +3 -0
- .venv/lib/python3.11/site-packages/nvidia_cudnn_cu12-9.1.0.70.dist-info/INSTALLER +1 -0
- .venv/lib/python3.11/site-packages/nvidia_cudnn_cu12-9.1.0.70.dist-info/License.txt +154 -0
- .venv/lib/python3.11/site-packages/nvidia_cudnn_cu12-9.1.0.70.dist-info/METADATA +36 -0
- .venv/lib/python3.11/site-packages/nvidia_cudnn_cu12-9.1.0.70.dist-info/RECORD +36 -0
- .venv/lib/python3.11/site-packages/nvidia_cudnn_cu12-9.1.0.70.dist-info/WHEEL +5 -0
- .venv/lib/python3.11/site-packages/nvidia_cudnn_cu12-9.1.0.70.dist-info/top_level.txt +1 -0
- .venv/lib/python3.11/site-packages/oauth2client/__pycache__/__init__.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/__pycache__/_helpers.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/__pycache__/_openssl_crypt.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/__pycache__/_pkce.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/__pycache__/_pure_python_crypt.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/__pycache__/_pycrypto_crypt.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/__pycache__/client.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/__pycache__/clientsecrets.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/__pycache__/crypt.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/__pycache__/file.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/__pycache__/service_account.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/__pycache__/tools.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/__pycache__/transport.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/contrib/django_util/__pycache__/__init__.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/contrib/django_util/__pycache__/apps.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/contrib/django_util/__pycache__/decorators.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/contrib/django_util/__pycache__/models.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/contrib/django_util/__pycache__/signals.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/contrib/django_util/__pycache__/storage.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/oauth2client/contrib/django_util/__pycache__/views.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/py_spy-0.4.0.dist-info/INSTALLER +1 -0
- .venv/lib/python3.11/site-packages/py_spy-0.4.0.dist-info/METADATA +306 -0
- .venv/lib/python3.11/site-packages/py_spy-0.4.0.dist-info/RECORD +6 -0
- .venv/lib/python3.11/site-packages/py_spy-0.4.0.dist-info/WHEEL +4 -0
- .venv/lib/python3.11/site-packages/py_spy-0.4.0.dist-info/licenses/LICENSE +21 -0
- .venv/lib/python3.11/site-packages/sentencepiece/__init__.py +1224 -0
- .venv/lib/python3.11/site-packages/sentencepiece/__pycache__/__init__.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/sentencepiece/__pycache__/_version.cpython-311.pyc +0 -0
.gitattributes
CHANGED
|
@@ -325,3 +325,6 @@ tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cudnn/lib/
|
|
| 325 |
.venv/lib/python3.11/site-packages/OpenSSL/__pycache__/crypto.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 326 |
.venv/lib/python3.11/site-packages/OpenSSL/__pycache__/SSL.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 327 |
.venv/lib/python3.11/site-packages/networkx/algorithms/isomorphism/tests/__pycache__/test_vf2pp_helpers.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
.venv/lib/python3.11/site-packages/OpenSSL/__pycache__/crypto.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 326 |
.venv/lib/python3.11/site-packages/OpenSSL/__pycache__/SSL.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 327 |
.venv/lib/python3.11/site-packages/networkx/algorithms/isomorphism/tests/__pycache__/test_vf2pp_helpers.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 328 |
+
.venv/lib/python3.11/site-packages/networkx/utils/__pycache__/backends.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 329 |
+
.venv/lib/python3.11/site-packages/httptools/parser/url_parser.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 330 |
+
.venv/lib/python3.11/site-packages/httptools/parser/parser.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
.venv/lib/python3.11/site-packages/compressed_tensors-0.9.1.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
.venv/lib/python3.11/site-packages/compressed_tensors-0.9.1.dist-info/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|
.venv/lib/python3.11/site-packages/compressed_tensors-0.9.1.dist-info/METADATA
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.1
|
| 2 |
+
Name: compressed-tensors
|
| 3 |
+
Version: 0.9.1
|
| 4 |
+
Summary: Library for utilization of compressed safetensors of neural network models
|
| 5 |
+
Home-page: https://github.com/neuralmagic/compressed-tensors
|
| 6 |
+
Author: Neuralmagic, Inc.
|
| 7 |
+
Author-email: support@neuralmagic.com
|
| 8 |
+
License: Apache 2.0
|
| 9 |
+
Description-Content-Type: text/markdown
|
| 10 |
+
License-File: LICENSE
|
| 11 |
+
Requires-Dist: torch>=1.7.0
|
| 12 |
+
Requires-Dist: transformers
|
| 13 |
+
Requires-Dist: pydantic>=2.0
|
| 14 |
+
Provides-Extra: accelerate
|
| 15 |
+
Requires-Dist: accelerate; extra == "accelerate"
|
| 16 |
+
Provides-Extra: dev
|
| 17 |
+
Requires-Dist: black==22.12.0; extra == "dev"
|
| 18 |
+
Requires-Dist: isort==5.8.0; extra == "dev"
|
| 19 |
+
Requires-Dist: wheel>=0.36.2; extra == "dev"
|
| 20 |
+
Requires-Dist: flake8>=3.8.3; extra == "dev"
|
| 21 |
+
Requires-Dist: pytest>=6.0.0; extra == "dev"
|
| 22 |
+
Requires-Dist: nbconvert>=7.16.3; extra == "dev"
|
| 23 |
+
|
| 24 |
+
# compressed-tensors
|
| 25 |
+
|
| 26 |
+
The `compressed-tensors` library extends the [safetensors](https://github.com/huggingface/safetensors) format, providing a versatile and efficient way to store and manage compressed tensor data. This library supports various quantization and sparsity schemes, making it a unified format for handling different model optimizations like GPTQ, AWQ, SmoothQuant, INT8, FP8, SparseGPT, and more.
|
| 27 |
+
|
| 28 |
+
## Why `compressed-tensors`?
|
| 29 |
+
|
| 30 |
+
As model compression becomes increasingly important for efficient deployment of LLMs, the landscape of quantization and compression techniques has become increasingly fragmented.
|
| 31 |
+
Each method often comes with its own storage format and loading procedures, making it challenging to work with multiple techniques or switch between them.
|
| 32 |
+
`compressed-tensors` addresses this by providing a single, extensible format that can represent a wide variety of compression schemes.
|
| 33 |
+
|
| 34 |
+
* **Unified Checkpoint Format**: Supports various compression schemes in a single, consistent format.
|
| 35 |
+
* **Wide Compatibility**: Works with popular quantization methods like GPTQ, SmoothQuant, and FP8. See [llm-compressor](https://github.com/vllm-project/llm-compressor)
|
| 36 |
+
* **Flexible Quantization Support**:
|
| 37 |
+
* Weight-only quantization (e.g., W4A16, W8A16, WnA16)
|
| 38 |
+
* Activation quantization (e.g., W8A8)
|
| 39 |
+
* KV cache quantization
|
| 40 |
+
* Non-uniform schemes (different layers can be quantized in different ways!)
|
| 41 |
+
* **Sparsity Support**: Handles both unstructured and semi-structured (e.g., 2:4) sparsity patterns.
|
| 42 |
+
* **Open-Source Integration**: Designed to work seamlessly with Hugging Face models and PyTorch.
|
| 43 |
+
|
| 44 |
+
This allows developers and researchers to easily experiment with composing different quantization methods, simplify model deployment pipelines, and reduce the overhead of supporting multiple compression formats in inference engines.
|
| 45 |
+
|
| 46 |
+
## Installation
|
| 47 |
+
|
| 48 |
+
### From [PyPI](https://pypi.org/project/compressed-tensors)
|
| 49 |
+
|
| 50 |
+
Stable release:
|
| 51 |
+
```bash
|
| 52 |
+
pip install compressed-tensors
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
Nightly release:
|
| 56 |
+
```bash
|
| 57 |
+
pip install compressed-tensors-nightly
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
### From Source
|
| 61 |
+
|
| 62 |
+
```bash
|
| 63 |
+
git clone https://github.com/neuralmagic/compressed-tensors
|
| 64 |
+
cd compressed-tensors
|
| 65 |
+
pip install -e .
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
## Getting started
|
| 69 |
+
|
| 70 |
+
### Saving/Loading Compressed Tensors (Bitmask Compression)
|
| 71 |
+
|
| 72 |
+
The function `save_compressed` uses the `compression_format` argument to apply compression to tensors.
|
| 73 |
+
The function `load_compressed` reverses the process: converts the compressed weights on disk to decompressed weights in device memory.
|
| 74 |
+
|
| 75 |
+
```python
|
| 76 |
+
from compressed_tensors import save_compressed, load_compressed, BitmaskConfig
|
| 77 |
+
from torch import Tensor
|
| 78 |
+
from typing import Dict
|
| 79 |
+
|
| 80 |
+
# the example BitmaskConfig method efficiently compresses
|
| 81 |
+
# tensors with large number of zero entries
|
| 82 |
+
compression_config = BitmaskConfig()
|
| 83 |
+
|
| 84 |
+
tensors: Dict[str, Tensor] = {"tensor_1": Tensor(
|
| 85 |
+
[[0.0, 0.0, 0.0],
|
| 86 |
+
[1.0, 1.0, 1.0]]
|
| 87 |
+
)}
|
| 88 |
+
# compress tensors using BitmaskConfig compression format (save them efficiently on disk)
|
| 89 |
+
save_compressed(tensors, "model.safetensors", compression_format=compression_config.format)
|
| 90 |
+
|
| 91 |
+
# decompress tensors (load_compressed returns a generator for memory efficiency)
|
| 92 |
+
decompressed_tensors = {}
|
| 93 |
+
for tensor_name, tensor in load_compressed("model.safetensors", compression_config = compression_config):
|
| 94 |
+
decompressed_tensors[tensor_name] = tensor
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
## Saving/Loading Compressed Models (Bitmask Compression)
|
| 98 |
+
|
| 99 |
+
We can apply bitmask compression to a whole model. For more detailed example see `example` directory.
|
| 100 |
+
```python
|
| 101 |
+
from compressed_tensors import save_compressed_model, load_compressed, BitmaskConfig
|
| 102 |
+
from transformers import AutoModelForCausalLM
|
| 103 |
+
|
| 104 |
+
model_name = "neuralmagic/llama2.c-stories110M-pruned50"
|
| 105 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto")
|
| 106 |
+
|
| 107 |
+
original_state_dict = model.state_dict()
|
| 108 |
+
|
| 109 |
+
compression_config = BitmaskConfig()
|
| 110 |
+
|
| 111 |
+
# save compressed model weights
|
| 112 |
+
save_compressed_model(model, "compressed_model.safetensors", compression_format=compression_config.format)
|
| 113 |
+
|
| 114 |
+
# load compressed model weights (`dict` turns generator into a dictionary)
|
| 115 |
+
state_dict = dict(load_compressed("compressed_model.safetensors", compression_config))
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
For more in-depth tutorial on bitmask compression, refer to the [notebook](https://github.com/neuralmagic/compressed-tensors/blob/d707c5b84bc3fef164aebdcd97cb6eaa571982f8/examples/bitmask_compression.ipynb).
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
## Saving a Compressed Model with PTQ
|
| 122 |
+
|
| 123 |
+
We can use compressed-tensors to run basic post training quantization (PTQ) and save the quantized model compressed on disk
|
| 124 |
+
|
| 125 |
+
```python
|
| 126 |
+
model_name = "TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T"
|
| 127 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="cuda:0", torch_dtype="auto")
|
| 128 |
+
|
| 129 |
+
config = QuantizationConfig.parse_file("./examples/bit_packing/int4_config.json")
|
| 130 |
+
config.quantization_status = QuantizationStatus.CALIBRATION
|
| 131 |
+
apply_quantization_config(model, config)
|
| 132 |
+
|
| 133 |
+
dataset = load_dataset("ptb_text_only")["train"]
|
| 134 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 135 |
+
|
| 136 |
+
def tokenize_function(examples):
|
| 137 |
+
return tokenizer(examples["sentence"], padding=False, truncation=True, max_length=1024)
|
| 138 |
+
|
| 139 |
+
tokenized_dataset = dataset.map(tokenize_function, batched=True)
|
| 140 |
+
data_loader = DataLoader(tokenized_dataset, batch_size=1, collate_fn=DefaultDataCollator())
|
| 141 |
+
|
| 142 |
+
with torch.no_grad():
|
| 143 |
+
for idx, sample in tqdm(enumerate(data_loader), desc="Running calibration"):
|
| 144 |
+
sample = {key: value.to(device) for key,value in sample.items()}
|
| 145 |
+
_ = model(**sample)
|
| 146 |
+
|
| 147 |
+
if idx >= 512:
|
| 148 |
+
break
|
| 149 |
+
|
| 150 |
+
model.apply(freeze_module_quantization)
|
| 151 |
+
model.apply(compress_quantized_weights)
|
| 152 |
+
|
| 153 |
+
output_dir = "./ex_llama1.1b_w4a16_packed_quantize"
|
| 154 |
+
compressor = ModelCompressor(quantization_config=config)
|
| 155 |
+
compressed_state_dict = compressor.compress(model)
|
| 156 |
+
model.save_pretrained(output_dir, state_dict=compressed_state_dict)
|
| 157 |
+
```
|
| 158 |
+
|
| 159 |
+
For more in-depth tutorial on quantization compression, refer to the [notebook](./examples/quantize_and_pack_int4.ipynb).
|
.venv/lib/python3.11/site-packages/compressed_tensors-0.9.1.dist-info/RECORD
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
compressed_tensors-0.9.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 2 |
+
compressed_tensors-0.9.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
| 3 |
+
compressed_tensors-0.9.1.dist-info/METADATA,sha256=LTzdui2DBwsv09xaTEsW2X66rd775Jf2lY9v9hs_WJg,6782
|
| 4 |
+
compressed_tensors-0.9.1.dist-info/RECORD,,
|
| 5 |
+
compressed_tensors-0.9.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
| 6 |
+
compressed_tensors-0.9.1.dist-info/top_level.txt,sha256=w2i-GyPs2s1UwVxvutSvN_lM22SXC2hQFBmoMcPnV7Y,19
|
| 7 |
+
compressed_tensors/__init__.py,sha256=UtKmifNeBCSE2TZSAfduVNNzHY-3V7bLjZ7n7RuXLOE,812
|
| 8 |
+
compressed_tensors/__pycache__/__init__.cpython-311.pyc,,
|
| 9 |
+
compressed_tensors/__pycache__/base.cpython-311.pyc,,
|
| 10 |
+
compressed_tensors/__pycache__/version.cpython-311.pyc,,
|
| 11 |
+
compressed_tensors/base.py,sha256=73HYH7HY7O2roC89yG_piPFnZwrBfn_i7HmKl90SKc0,875
|
| 12 |
+
compressed_tensors/compressors/__init__.py,sha256=smSygTSfcfuujRrAXDc6uZm4L_ccV1tWZewqVnOb4lM,825
|
| 13 |
+
compressed_tensors/compressors/__pycache__/__init__.cpython-311.pyc,,
|
| 14 |
+
compressed_tensors/compressors/__pycache__/base.cpython-311.pyc,,
|
| 15 |
+
compressed_tensors/compressors/__pycache__/helpers.cpython-311.pyc,,
|
| 16 |
+
compressed_tensors/compressors/base.py,sha256=D9TNwQcjanDiAHODPbg8JUqc66e3j50rctY7A708NEs,6743
|
| 17 |
+
compressed_tensors/compressors/helpers.py,sha256=OK6qxX9j3bHwF9JfIYSGMgBJe2PWjlTA3byXKCJaTIQ,5431
|
| 18 |
+
compressed_tensors/compressors/model_compressors/__init__.py,sha256=5RGGPFu4YqEt_aOdFSQYFYFDjcZFJN0CsMqRtDZz3Js,666
|
| 19 |
+
compressed_tensors/compressors/model_compressors/__pycache__/__init__.cpython-311.pyc,,
|
| 20 |
+
compressed_tensors/compressors/model_compressors/__pycache__/model_compressor.cpython-311.pyc,,
|
| 21 |
+
compressed_tensors/compressors/model_compressors/model_compressor.py,sha256=3WyzAW2Rm_uLprxwO2QH6FR76W6Mk4r2yedayaSZHhw,18396
|
| 22 |
+
compressed_tensors/compressors/quantized_compressors/__init__.py,sha256=09UJq68Pht6Bf-4iP9xYl3tetKsncNPHD8IAGbePsr4,714
|
| 23 |
+
compressed_tensors/compressors/quantized_compressors/__pycache__/__init__.cpython-311.pyc,,
|
| 24 |
+
compressed_tensors/compressors/quantized_compressors/__pycache__/base.cpython-311.pyc,,
|
| 25 |
+
compressed_tensors/compressors/quantized_compressors/__pycache__/naive_quantized.cpython-311.pyc,,
|
| 26 |
+
compressed_tensors/compressors/quantized_compressors/__pycache__/pack_quantized.cpython-311.pyc,,
|
| 27 |
+
compressed_tensors/compressors/quantized_compressors/base.py,sha256=LVqSSqSjGi8LB-X13zC_0AFHc8BobGQVC0zjInDhOWE,7217
|
| 28 |
+
compressed_tensors/compressors/quantized_compressors/naive_quantized.py,sha256=fahmPJFz49rVS7q705uQwZ0kUtdP46GuXR7nPr6uIqI,4943
|
| 29 |
+
compressed_tensors/compressors/quantized_compressors/pack_quantized.py,sha256=OO5dceCfNVuY8A23kBg6z2wk-zGUVqR_MyLvObvT7pk,7741
|
| 30 |
+
compressed_tensors/compressors/sparse_compressors/__init__.py,sha256=Atuz-OdEgn8OCUhx7Ovd6gXdyImAI186uCR-uR0t_Nk,737
|
| 31 |
+
compressed_tensors/compressors/sparse_compressors/__pycache__/__init__.cpython-311.pyc,,
|
| 32 |
+
compressed_tensors/compressors/sparse_compressors/__pycache__/base.cpython-311.pyc,,
|
| 33 |
+
compressed_tensors/compressors/sparse_compressors/__pycache__/dense.cpython-311.pyc,,
|
| 34 |
+
compressed_tensors/compressors/sparse_compressors/__pycache__/sparse_24_bitmask.cpython-311.pyc,,
|
| 35 |
+
compressed_tensors/compressors/sparse_compressors/__pycache__/sparse_bitmask.cpython-311.pyc,,
|
| 36 |
+
compressed_tensors/compressors/sparse_compressors/base.py,sha256=9e841MQWr0j8m33ejDw_jP5_BIpQ5099x9_pvuZ-Nr0,5944
|
| 37 |
+
compressed_tensors/compressors/sparse_compressors/dense.py,sha256=lSKNWRx6H7aUqaJj1j4qbXk8Gkm1UohbnvW1Rvq6Ra4,1284
|
| 38 |
+
compressed_tensors/compressors/sparse_compressors/sparse_24_bitmask.py,sha256=_g139pe4iAFn5jvGIEk4v-qMoyx9ID6E88vriPSNYV4,8604
|
| 39 |
+
compressed_tensors/compressors/sparse_compressors/sparse_bitmask.py,sha256=7zSr9bqkpuH1ivQpxtYBNxXIoElal7Jo1nSKpZN_IFk,5633
|
| 40 |
+
compressed_tensors/compressors/sparse_quantized_compressors/__init__.py,sha256=4f_cwcKXB1nVVMoiKgTFAc8jAPjPLElo-Df_EDm1_xw,675
|
| 41 |
+
compressed_tensors/compressors/sparse_quantized_compressors/__pycache__/__init__.cpython-311.pyc,,
|
| 42 |
+
compressed_tensors/compressors/sparse_quantized_compressors/__pycache__/marlin_24.cpython-311.pyc,,
|
| 43 |
+
compressed_tensors/compressors/sparse_quantized_compressors/marlin_24.py,sha256=BMIQWTLlnUvxy14iEJegtiP75WHJeOVojey9mKOK1hE,9427
|
| 44 |
+
compressed_tensors/config/__init__.py,sha256=8sOoZ6xvYSC79mBvEtO8l6xk4PC80d29AnnJiGMrY2M,737
|
| 45 |
+
compressed_tensors/config/__pycache__/__init__.cpython-311.pyc,,
|
| 46 |
+
compressed_tensors/config/__pycache__/base.cpython-311.pyc,,
|
| 47 |
+
compressed_tensors/config/__pycache__/dense.cpython-311.pyc,,
|
| 48 |
+
compressed_tensors/config/__pycache__/sparse_24_bitmask.cpython-311.pyc,,
|
| 49 |
+
compressed_tensors/config/__pycache__/sparse_bitmask.cpython-311.pyc,,
|
| 50 |
+
compressed_tensors/config/base.py,sha256=R3iUmFf1MslEjin5LgwQbmfJHIsS7Uw0UIxfn780uqY,3479
|
| 51 |
+
compressed_tensors/config/dense.py,sha256=NgSxnFCnckU9-iunxEaqiFwqgdO7YYxlWKR74jNbjks,1317
|
| 52 |
+
compressed_tensors/config/sparse_24_bitmask.py,sha256=Lhj39zT2V1hxftprvxvneyhv45ShlXOKd75DBbDTyTE,1401
|
| 53 |
+
compressed_tensors/config/sparse_bitmask.py,sha256=pZUboRNZTu6NajGOQEFExoPknak5ynVAUeiiYpS1Gt8,1308
|
| 54 |
+
compressed_tensors/linear/__init__.py,sha256=fH6rjBYAxuwrTzBTlTjTgCYNyh6TCvCqajCz4Im4YrA,617
|
| 55 |
+
compressed_tensors/linear/__pycache__/__init__.cpython-311.pyc,,
|
| 56 |
+
compressed_tensors/linear/__pycache__/compressed_linear.cpython-311.pyc,,
|
| 57 |
+
compressed_tensors/linear/compressed_linear.py,sha256=MJa-UfoKhIkdUWRD1shrXXri2cOwR5GK0a4t4bNYosM,3268
|
| 58 |
+
compressed_tensors/quantization/__init__.py,sha256=83J5bPB7PavN2TfCoW7_vEDhfYpm4TDrqYO9vdSQ5bk,760
|
| 59 |
+
compressed_tensors/quantization/__pycache__/__init__.cpython-311.pyc,,
|
| 60 |
+
compressed_tensors/quantization/__pycache__/quant_args.cpython-311.pyc,,
|
| 61 |
+
compressed_tensors/quantization/__pycache__/quant_config.cpython-311.pyc,,
|
| 62 |
+
compressed_tensors/quantization/__pycache__/quant_scheme.cpython-311.pyc,,
|
| 63 |
+
compressed_tensors/quantization/lifecycle/__init__.py,sha256=_uItzFWusyV74Zco_pHLOTdE9a83cL-R-ZdyQrBkIyw,772
|
| 64 |
+
compressed_tensors/quantization/lifecycle/__pycache__/__init__.cpython-311.pyc,,
|
| 65 |
+
compressed_tensors/quantization/lifecycle/__pycache__/apply.cpython-311.pyc,,
|
| 66 |
+
compressed_tensors/quantization/lifecycle/__pycache__/compressed.cpython-311.pyc,,
|
| 67 |
+
compressed_tensors/quantization/lifecycle/__pycache__/forward.cpython-311.pyc,,
|
| 68 |
+
compressed_tensors/quantization/lifecycle/__pycache__/helpers.cpython-311.pyc,,
|
| 69 |
+
compressed_tensors/quantization/lifecycle/__pycache__/initialize.cpython-311.pyc,,
|
| 70 |
+
compressed_tensors/quantization/lifecycle/apply.py,sha256=XS4M6N1opKBybhkuQsS338QVb_CKMhUM5TUKrqoNQ0k,16517
|
| 71 |
+
compressed_tensors/quantization/lifecycle/compressed.py,sha256=Fj9n66IN0EWsOAkBHg3O0GlOQpxstqjCcs0ttzMXrJ0,2296
|
| 72 |
+
compressed_tensors/quantization/lifecycle/forward.py,sha256=DOWouUqfaLA4Qhg-ojVVBdhhSAlgZqFC26vZARxE0ko,12961
|
| 73 |
+
compressed_tensors/quantization/lifecycle/helpers.py,sha256=C0mhy2vJ0fCjVeN4kFNhw8Eq1wkteBGHiZ36RVLThRY,944
|
| 74 |
+
compressed_tensors/quantization/lifecycle/initialize.py,sha256=hymYtayTSumm8KCYAYPY267aWmlsJpt8oQFiRblk8qE,7452
|
| 75 |
+
compressed_tensors/quantization/quant_args.py,sha256=jwC__lSmuiJ2qSJYYZGgWgQNbZu6YhhS0e-qugrTNXE,9058
|
| 76 |
+
compressed_tensors/quantization/quant_config.py,sha256=vx06wBo91p4LCb3Vzd-2eCTUeIf_Sz2ZXRP263eQyjQ,10385
|
| 77 |
+
compressed_tensors/quantization/quant_scheme.py,sha256=eQ0JrRZ80GX69fpwW87VzPzzhajhk4mUaJScjk82OY4,6010
|
| 78 |
+
compressed_tensors/quantization/utils/__init__.py,sha256=VdtEmP0bvuND_IGQnyqUPc5lnFp-1_yD7StKSX4x80w,656
|
| 79 |
+
compressed_tensors/quantization/utils/__pycache__/__init__.cpython-311.pyc,,
|
| 80 |
+
compressed_tensors/quantization/utils/__pycache__/helpers.cpython-311.pyc,,
|
| 81 |
+
compressed_tensors/quantization/utils/helpers.py,sha256=DBP-sGRpGAY01K0LFE7qqonNj4hkTYL_mXrMs2LtAD8,14100
|
| 82 |
+
compressed_tensors/registry/__init__.py,sha256=FwLSNYqfIrb5JD_6OK_MT4_svvKTN_nEhpgQlQvGbjI,658
|
| 83 |
+
compressed_tensors/registry/__pycache__/__init__.cpython-311.pyc,,
|
| 84 |
+
compressed_tensors/registry/__pycache__/registry.cpython-311.pyc,,
|
| 85 |
+
compressed_tensors/registry/registry.py,sha256=vRcjVB1ITfSbfYUaGndBBmqhip_5vsS62weorVg0iXo,11896
|
| 86 |
+
compressed_tensors/utils/__init__.py,sha256=gS4gSU2pwcAbsKj-6YMaqhm25udFy6ISYaWBf-myRSM,808
|
| 87 |
+
compressed_tensors/utils/__pycache__/__init__.cpython-311.pyc,,
|
| 88 |
+
compressed_tensors/utils/__pycache__/helpers.cpython-311.pyc,,
|
| 89 |
+
compressed_tensors/utils/__pycache__/offload.cpython-311.pyc,,
|
| 90 |
+
compressed_tensors/utils/__pycache__/permutations_24.cpython-311.pyc,,
|
| 91 |
+
compressed_tensors/utils/__pycache__/permute.cpython-311.pyc,,
|
| 92 |
+
compressed_tensors/utils/__pycache__/safetensors_load.cpython-311.pyc,,
|
| 93 |
+
compressed_tensors/utils/__pycache__/semi_structured_conversions.cpython-311.pyc,,
|
| 94 |
+
compressed_tensors/utils/helpers.py,sha256=xQHZXwIAAybC8mMTiAtWSOeggZMT1JOC6_wcDvlo2yk,10320
|
| 95 |
+
compressed_tensors/utils/offload.py,sha256=cMmzd9IdlNbs29CReHj1PPSLUM6OWaT5YumlLT5eP3w,13845
|
| 96 |
+
compressed_tensors/utils/permutations_24.py,sha256=kx6fsfDHebx94zsSzhXGyCyuC9sVyah6BUUir_StT28,2530
|
| 97 |
+
compressed_tensors/utils/permute.py,sha256=V6tJLKo3Syccj-viv4F7ZKZgJeCB-hl-dK8RKI_kBwI,2355
|
| 98 |
+
compressed_tensors/utils/safetensors_load.py,sha256=fBuoHVPoBt1mkvqFJ60zQIASX_4nhl0-6QfFS27NY8I,11430
|
| 99 |
+
compressed_tensors/utils/semi_structured_conversions.py,sha256=XKNffPum54kPASgqKzgKvyeqWPAkair2XEQXjkp7ho8,13489
|
| 100 |
+
compressed_tensors/version.py,sha256=cPIrNBysxeJxrC4lzqGpVUu_oM56xF851VDnvn1gsew,1585
|
.venv/lib/python3.11/site-packages/compressed_tensors-0.9.1.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: bdist_wheel (0.45.1)
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
| 5 |
+
|
.venv/lib/python3.11/site-packages/compressed_tensors-0.9.1.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
compressed_tensors
|
.venv/lib/python3.11/site-packages/httptools-0.6.4.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
.venv/lib/python3.11/site-packages/httptools-0.6.4.dist-info/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2015 MagicStack Inc. http://magic.io
|
| 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
|
| 13 |
+
all 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,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: httptools
|
| 3 |
+
Version: 0.6.4
|
| 4 |
+
Summary: A collection of framework independent HTTP protocol utils.
|
| 5 |
+
Home-page: https://github.com/MagicStack/httptools
|
| 6 |
+
Author: Yury Selivanov
|
| 7 |
+
Author-email: yury@magic.io
|
| 8 |
+
License: MIT
|
| 9 |
+
Platform: macOS
|
| 10 |
+
Platform: POSIX
|
| 11 |
+
Platform: Windows
|
| 12 |
+
Classifier: License :: OSI Approved :: MIT License
|
| 13 |
+
Classifier: Intended Audience :: Developers
|
| 14 |
+
Classifier: Programming Language :: Python :: 3
|
| 15 |
+
Classifier: Operating System :: POSIX
|
| 16 |
+
Classifier: Operating System :: MacOS :: MacOS X
|
| 17 |
+
Classifier: Environment :: Web Environment
|
| 18 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 19 |
+
Requires-Python: >=3.8.0
|
| 20 |
+
Description-Content-Type: text/markdown
|
| 21 |
+
License-File: LICENSE
|
| 22 |
+
Provides-Extra: test
|
| 23 |
+
Requires-Dist: Cython>=0.29.24; extra == "test"
|
| 24 |
+
|
| 25 |
+

|
| 26 |
+
|
| 27 |
+
httptools is a Python binding for the nodejs HTTP parser.
|
| 28 |
+
|
| 29 |
+
The package is available on PyPI: `pip install httptools`.
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
# APIs
|
| 33 |
+
|
| 34 |
+
httptools contains two classes `httptools.HttpRequestParser`,
|
| 35 |
+
`httptools.HttpResponseParser` (fulfilled through
|
| 36 |
+
[llhttp](https://github.com/nodejs/llhttp)) and a function for
|
| 37 |
+
parsing URLs `httptools.parse_url` (through
|
| 38 |
+
[http-parse](https://github.com/nodejs/http-parser) for now).
|
| 39 |
+
See unittests for examples.
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
|
| 44 |
+
class HttpRequestParser:
|
| 45 |
+
|
| 46 |
+
def __init__(self, protocol):
|
| 47 |
+
"""HttpRequestParser
|
| 48 |
+
|
| 49 |
+
protocol -- a Python object with the following methods
|
| 50 |
+
(all optional):
|
| 51 |
+
|
| 52 |
+
- on_message_begin()
|
| 53 |
+
- on_url(url: bytes)
|
| 54 |
+
- on_header(name: bytes, value: bytes)
|
| 55 |
+
- on_headers_complete()
|
| 56 |
+
- on_body(body: bytes)
|
| 57 |
+
- on_message_complete()
|
| 58 |
+
- on_chunk_header()
|
| 59 |
+
- on_chunk_complete()
|
| 60 |
+
- on_status(status: bytes)
|
| 61 |
+
"""
|
| 62 |
+
|
| 63 |
+
def get_http_version(self) -> str:
|
| 64 |
+
"""Return an HTTP protocol version."""
|
| 65 |
+
|
| 66 |
+
def should_keep_alive(self) -> bool:
|
| 67 |
+
"""Return ``True`` if keep-alive mode is preferred."""
|
| 68 |
+
|
| 69 |
+
def should_upgrade(self) -> bool:
|
| 70 |
+
"""Return ``True`` if the parsed request is a valid Upgrade request.
|
| 71 |
+
The method exposes a flag set just before on_headers_complete.
|
| 72 |
+
Calling this method earlier will only yield `False`.
|
| 73 |
+
"""
|
| 74 |
+
|
| 75 |
+
def feed_data(self, data: bytes):
|
| 76 |
+
"""Feed data to the parser.
|
| 77 |
+
|
| 78 |
+
Will eventually trigger callbacks on the ``protocol``
|
| 79 |
+
object.
|
| 80 |
+
|
| 81 |
+
On HTTP upgrade, this method will raise an
|
| 82 |
+
``HttpParserUpgrade`` exception, with its sole argument
|
| 83 |
+
set to the offset of the non-HTTP data in ``data``.
|
| 84 |
+
"""
|
| 85 |
+
|
| 86 |
+
def get_method(self) -> bytes:
|
| 87 |
+
"""Return HTTP request method (GET, HEAD, etc)"""
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
class HttpResponseParser:
|
| 91 |
+
|
| 92 |
+
"""Has all methods except ``get_method()`` that
|
| 93 |
+
HttpRequestParser has."""
|
| 94 |
+
|
| 95 |
+
def get_status_code(self) -> int:
|
| 96 |
+
"""Return the status code of the HTTP response"""
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def parse_url(url: bytes):
|
| 100 |
+
"""Parse URL strings into a structured Python object.
|
| 101 |
+
|
| 102 |
+
Returns an instance of ``httptools.URL`` class with the
|
| 103 |
+
following attributes:
|
| 104 |
+
|
| 105 |
+
- schema: bytes
|
| 106 |
+
- host: bytes
|
| 107 |
+
- port: int
|
| 108 |
+
- path: bytes
|
| 109 |
+
- query: bytes
|
| 110 |
+
- fragment: bytes
|
| 111 |
+
- userinfo: bytes
|
| 112 |
+
"""
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
# Development
|
| 117 |
+
|
| 118 |
+
1. Clone this repository with
|
| 119 |
+
`git clone --recursive git@github.com:MagicStack/httptools.git`
|
| 120 |
+
|
| 121 |
+
2. Create a virtual environment with Python 3:
|
| 122 |
+
`python3 -m venv envname`
|
| 123 |
+
|
| 124 |
+
3. Activate the environment with `source envname/bin/activate`
|
| 125 |
+
|
| 126 |
+
4. Install development requirements with `pip install -e .[test]`
|
| 127 |
+
|
| 128 |
+
5. Run `make` and `make test`.
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
# License
|
| 132 |
+
|
| 133 |
+
MIT.
|
.venv/lib/python3.11/site-packages/httptools-0.6.4.dist-info/RECORD
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
httptools-0.6.4.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 2 |
+
httptools-0.6.4.dist-info/LICENSE,sha256=9Fc-fLdnZ0X7W402-lSKqT45HPtoct2s1lEwxF6mqS0,1093
|
| 3 |
+
httptools-0.6.4.dist-info/METADATA,sha256=U4VRvayKRJbdHp18Fagk4_L7RvIQJ4anhwtwS64rO9A,3583
|
| 4 |
+
httptools-0.6.4.dist-info/RECORD,,
|
| 5 |
+
httptools-0.6.4.dist-info/WHEEL,sha256=1xuwdrbeIuHvQX3uMggPJqjJpR5WLor7jKc2zZeYNs0,224
|
| 6 |
+
httptools-0.6.4.dist-info/top_level.txt,sha256=APjJKTbZcj0OQ4fdgf2eTCk82nK1n2BFXOD7ky41MPY,10
|
| 7 |
+
httptools/__init__.py,sha256=plt3MIbueJdco9Dy7zoH3ksLNeyirqWagat5rwRmAjo,147
|
| 8 |
+
httptools/__pycache__/__init__.cpython-311.pyc,,
|
| 9 |
+
httptools/__pycache__/_version.cpython-311.pyc,,
|
| 10 |
+
httptools/_version.py,sha256=ASqOB8fLS7jwZsM551Lc49WxYPyjteqnz1iDWmka-KA,575
|
| 11 |
+
httptools/parser/__init__.py,sha256=fWyconPEHZlJojzRwmBKSn4C85OGXmKEwiEcdjHqXO8,166
|
| 12 |
+
httptools/parser/__pycache__/__init__.cpython-311.pyc,,
|
| 13 |
+
httptools/parser/__pycache__/errors.cpython-311.pyc,,
|
| 14 |
+
httptools/parser/cparser.pxd,sha256=4qBxnma83Vz86Z9sOZRxjqYj20A-aLSWVGXZgTVLJqE,4977
|
| 15 |
+
httptools/parser/errors.py,sha256=ZVrtN1smPIb_opQ2Ud3uCbGlNLMlECYM2-6S7r5LnHs,566
|
| 16 |
+
httptools/parser/parser.cpython-311-x86_64-linux-gnu.so,sha256=UOjazfkDQuZnn0kC8JGK8CiM9JeOD9oBrP5Qr6PbAaw,1068536
|
| 17 |
+
httptools/parser/parser.pyx,sha256=x0BUY9EzHNKCDaw-U8bkZ1MaKGtrOQ8iVCm1IuOtEQI,15140
|
| 18 |
+
httptools/parser/python.pxd,sha256=zWCdGZh34fyQNt3BUHIUjPqY8a5sodRUkfdABxqYHgQ,138
|
| 19 |
+
httptools/parser/url_cparser.pxd,sha256=X5dDI8A7T0l5HL_Czt0mTs0l_d2lXnUDHx1TN8LeiCM,779
|
| 20 |
+
httptools/parser/url_parser.cpython-311-x86_64-linux-gnu.so,sha256=lXhCXgLJvVc3i6lhRppiuOEB3p7mKWrBd_inE7JNZDg,455336
|
| 21 |
+
httptools/parser/url_parser.pyx,sha256=ZJVUZqrIDdhzVodA7tTtoFb570av-SczIyh2oAZXKzM,3758
|
.venv/lib/python3.11/site-packages/httptools-0.6.4.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: setuptools (75.1.0)
|
| 3 |
+
Root-Is-Purelib: false
|
| 4 |
+
Tag: cp311-cp311-manylinux_2_5_x86_64
|
| 5 |
+
Tag: cp311-cp311-manylinux1_x86_64
|
| 6 |
+
Tag: cp311-cp311-manylinux_2_17_x86_64
|
| 7 |
+
Tag: cp311-cp311-manylinux2014_x86_64
|
| 8 |
+
|
.venv/lib/python3.11/site-packages/httptools-0.6.4.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
httptools
|
.venv/lib/python3.11/site-packages/httptools/parser/parser.cpython-311-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:50e8dacdf90342e6679f4902f0918af0288cf4978e0fda01acfe50afa3db01ac
|
| 3 |
+
size 1068536
|
.venv/lib/python3.11/site-packages/httptools/parser/url_parser.cpython-311-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9578425e02c9bd57378ba961469a62b8e101de9ee6296ac177f8a713b24d6438
|
| 3 |
+
size 455336
|
.venv/lib/python3.11/site-packages/networkx/utils/__pycache__/backends.cpython-311.pyc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b2373c4c1cea9ffed4078a7dd1eb72fa70a887af62d64fcf618f3c3a838a27b9
|
| 3 |
+
size 102722
|
.venv/lib/python3.11/site-packages/nvidia_cudnn_cu12-9.1.0.70.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
.venv/lib/python3.11/site-packages/nvidia_cudnn_cu12-9.1.0.70.dist-info/License.txt
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
LICENSE AGREEMENT FOR NVIDIA SOFTWARE DEVELOPMENT KITS
|
| 2 |
+
|
| 3 |
+
This license agreement, including exhibits attached ("Agreement”) is a legal agreement between you and NVIDIA Corporation ("NVIDIA") and governs your use of a NVIDIA software development kit (“SDK”).
|
| 4 |
+
|
| 5 |
+
Each SDK has its own set of software and materials, but here is a description of the types of items that may be included in a SDK: source code, header files, APIs, data sets and assets (examples include images, textures, models, scenes, videos, native API input/output files), binary software, sample code, libraries, utility programs, programming code and documentation.
|
| 6 |
+
|
| 7 |
+
This Agreement can be accepted only by an adult of legal age of majority in the country in which the SDK is used.
|
| 8 |
+
|
| 9 |
+
If you are entering into this Agreement on behalf of a company or other legal entity, you represent that you have the legal authority to bind the entity to this Agreement, in which case “you” will mean the entity you represent.
|
| 10 |
+
|
| 11 |
+
If you don’t have the required age or authority to accept this Agreement, or if you don’t accept all the terms and conditions of this Agreement, do not download, install or use the SDK.
|
| 12 |
+
|
| 13 |
+
You agree to use the SDK only for purposes that are permitted by (a) this Agreement, and (b) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions.
|
| 14 |
+
|
| 15 |
+
1. License.
|
| 16 |
+
|
| 17 |
+
1.1 Grant
|
| 18 |
+
|
| 19 |
+
Subject to the terms of this Agreement, NVIDIA hereby grants you a non-exclusive, non-transferable license, without the right to sublicense (except as expressly provided in this Agreement) to:
|
| 20 |
+
|
| 21 |
+
(i) Install and use the SDK,
|
| 22 |
+
|
| 23 |
+
(ii) Modify and create derivative works of sample source code delivered in the SDK, and
|
| 24 |
+
|
| 25 |
+
(iii) Distribute those portions of the SDK that are identified in this Agreement as distributable, as incorporated in object code format into a software application that meets the distribution requirements indicated in this Agreement.
|
| 26 |
+
|
| 27 |
+
1.2 Distribution Requirements
|
| 28 |
+
|
| 29 |
+
These are the distribution requirements for you to exercise the distribution grant:
|
| 30 |
+
|
| 31 |
+
(i) Your application must have material additional functionality, beyond the included portions of the SDK.
|
| 32 |
+
|
| 33 |
+
(ii) The distributable portions of the SDK shall only be accessed by your application.
|
| 34 |
+
|
| 35 |
+
(iii) The following notice shall be included in modifications and derivative works of sample source code distributed: “This software contains source code provided by NVIDIA Corporation.”
|
| 36 |
+
|
| 37 |
+
(iv) Unless a developer tool is identified in this Agreement as distributable, it is delivered for your internal use only.
|
| 38 |
+
|
| 39 |
+
(v) The terms under which you distribute your application must be consistent with the terms of this Agreement, including (without limitation) terms relating to the license grant and license restrictions and protection of NVIDIA’s intellectual property rights. Additionally, you agree that you will protect the privacy, security and legal rights of your application users.
|
| 40 |
+
|
| 41 |
+
(vi) You agree to notify NVIDIA in writing of any known or suspected distribution or use of the SDK not in compliance with the requirements of this Agreement, and to enforce the terms of your agreements with respect to distributed SDK.
|
| 42 |
+
|
| 43 |
+
1.3 Authorized Users
|
| 44 |
+
|
| 45 |
+
You may allow employees and contractors of your entity or of your subsidiary(ies) to access and use the SDK from your secure network to perform work on your behalf.
|
| 46 |
+
|
| 47 |
+
If you are an academic institution you may allow users enrolled or employed by the academic institution to access and use the SDK from your secure network.
|
| 48 |
+
|
| 49 |
+
You are responsible for the compliance with the terms of this Agreement by your authorized users. If you become aware that your authorized users didn’t follow the terms of this Agreement, you agree to take reasonable steps to resolve the non-compliance and prevent new occurrences.
|
| 50 |
+
|
| 51 |
+
1.4 Pre-Release SDK
|
| 52 |
+
The SDK versions identified as alpha, beta, preview or otherwise as pre-release, may not be fully functional, may contain errors or design flaws, and may have reduced or different security, privacy, accessibility, availability, and reliability standards relative to commercial versions of NVIDIA software and materials. Use of a pre-release SDK may result in unexpected results, loss of data, project delays or other unpredictable damage or loss.
|
| 53 |
+
You may use a pre-release SDK at your own risk, understanding that pre-release SDKs are not intended for use in production or business-critical systems.
|
| 54 |
+
NVIDIA may choose not to make available a commercial version of any pre-release SDK. NVIDIA may also choose to abandon development and terminate the availability of a pre-release SDK at any time without liability.
|
| 55 |
+
1.5 Updates
|
| 56 |
+
|
| 57 |
+
NVIDIA may, at its option, make available patches, workarounds or other updates to this SDK. Unless the updates are provided with their separate governing terms, they are deemed part of the SDK licensed to you as provided in this Agreement.
|
| 58 |
+
|
| 59 |
+
You agree that the form and content of the SDK that NVIDIA provides may change without prior notice to you. While NVIDIA generally maintains compatibility between versions, NVIDIA may in some cases make changes that introduce incompatibilities in future versions of the SDK.
|
| 60 |
+
|
| 61 |
+
1.6 Third Party Licenses
|
| 62 |
+
|
| 63 |
+
The SDK may come bundled with, or otherwise include or be distributed with, third party software licensed by a NVIDIA supplier and/or open source software provided under an open source license. Use of third party software is subject to the third-party license terms, or in the absence of third party terms, the terms of this Agreement. Copyright to third party software is held by the copyright holders indicated in the third-party software or license.
|
| 64 |
+
|
| 65 |
+
1.7 Reservation of Rights
|
| 66 |
+
|
| 67 |
+
NVIDIA reserves all rights, title and interest in and to the SDK not expressly granted to you under this Agreement.
|
| 68 |
+
|
| 69 |
+
2. Limitations.
|
| 70 |
+
|
| 71 |
+
The following license limitations apply to your use of the SDK:
|
| 72 |
+
|
| 73 |
+
2.1 You may not reverse engineer, decompile or disassemble, or remove copyright or other proprietary notices from any portion of the SDK or copies of the SDK.
|
| 74 |
+
|
| 75 |
+
2.2 Except as expressly provided in this Agreement, you may not copy, sell, rent, sublicense, transfer, distribute, modify, or create derivative works of any portion of the SDK.
|
| 76 |
+
|
| 77 |
+
2.3 Unless you have an agreement with NVIDIA for this purpose, you may not indicate that an application created with the SDK is sponsored or endorsed by NVIDIA.
|
| 78 |
+
|
| 79 |
+
2.4 You may not bypass, disable, or circumvent any encryption, security, digital rights management or authentication mechanism in the SDK.
|
| 80 |
+
|
| 81 |
+
2.5 You may not use the SDK in any manner that would cause it to become subject to an open source software license. As examples, licenses that require as a condition of use, modification, and/or distribution that the SDK be (i) disclosed or distributed in source code form; (ii) licensed for the purpose of making derivative works; or (iii) redistributable at no charge.
|
| 82 |
+
|
| 83 |
+
2.6 Unless you have an agreement with NVIDIA for this purpose, you may not use the SDK with any system or application where the use or failure of the system or application can reasonably be expected to threaten or result in personal injury, death, or catastrophic loss. Examples include use in avionics, navigation, military, medical, life support or other life critical applications. NVIDIA does not design, test or manufacture the SDK for these critical uses and NVIDIA shall not be liable to you or any third party, in whole or in part, for any claims or damages arising from such uses.
|
| 84 |
+
|
| 85 |
+
2.7 You agree to defend, indemnify and hold harmless NVIDIA and its affiliates, and their respective employees, contractors, agents, officers and directors, from and against any and all claims, damages, obligations, losses, liabilities, costs or debt, fines, restitutions and expenses (including but not limited to attorney’s fees and costs incident to establishing the right of indemnification) arising out of or related to your use of the SDK outside of the scope of this Agreement, or not in compliance with its terms.
|
| 86 |
+
|
| 87 |
+
3. Ownership.
|
| 88 |
+
|
| 89 |
+
3.1 NVIDIA or its licensors hold all rights, title and interest in and to the SDK and its modifications and derivative works, including their respective intellectual property rights, subject to your rights under Section 3.2. This SDK may include software and materials from NVIDIA’s licensors, and these licensors are intended third party beneficiaries that may enforce this Agreement with respect to their intellectual property rights.
|
| 90 |
+
|
| 91 |
+
3.2 You hold all rights, title and interest in and to your applications and your derivative works of the sample source code delivered in the SDK, including their respective intellectual property rights, subject to NVIDIA’s rights under section 3.1.
|
| 92 |
+
|
| 93 |
+
3.3 You may, but don’t have to, provide to NVIDIA suggestions, feature requests or other feedback regarding the SDK, including possible enhancements or modifications to the SDK. For any feedback that you voluntarily provide, you hereby grant NVIDIA and its affiliates a perpetual, non-exclusive, worldwide, irrevocable license to use, reproduce, modify, license, sublicense (through multiple tiers of sublicensees), and distribute (through multiple tiers of distributors) it without the payment of any royalties or fees to you. NVIDIA will use feedback at its choice. NVIDIA is constantly looking for ways to improve its products, so you may send feedback to NVIDIA through the developer portal at https://developer.nvidia.com.
|
| 94 |
+
|
| 95 |
+
4. No Warranties.
|
| 96 |
+
|
| 97 |
+
THE SDK IS PROVIDED BY NVIDIA “AS IS” AND “WITH ALL FAULTS.” TO THE MAXIMUM EXTENT PERMITTED BY LAW, NVIDIA AND ITS AFFILIATES EXPRESSLY DISCLAIM ALL WARRANTIES OF ANY KIND OR NATURE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR THE ABSENCE OF ANY DEFECTS THEREIN, WHETHER LATENT OR PATENT. NO WARRANTY IS MADE ON THE BASIS OF TRADE USAGE, COURSE OF DEALING OR COURSE OF TRADE.
|
| 98 |
+
|
| 99 |
+
5. Limitations of Liability.
|
| 100 |
+
|
| 101 |
+
TO THE MAXIMUM EXTENT PERMITTED BY LAW, NVIDIA AND ITS AFFILIATES SHALL NOT BE LIABLE FOR ANY SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, OR ANY LOST PROFITS, LOSS OF USE, LOSS OF DATA OR LOSS OF GOODWILL, OR THE COSTS OF PROCURING SUBSTITUTE PRODUCTS, ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT OR THE USE OR PERFORMANCE OF THE SDK, WHETHER SUCH LIABILITY ARISES FROM ANY CLAIM BASED UPON BREACH OF CONTRACT, BREACH OF WARRANTY, TORT (INCLUDING NEGLIGENCE), PRODUCT LIABILITY OR ANY OTHER CAUSE OF ACTION OR THEORY OF LIABILITY. IN NO EVENT WILL NVIDIA’S AND ITS AFFILIATES TOTAL CUMULATIVE LIABILITY UNDER OR ARISING OUT OF THIS AGREEMENT EXCEED US$10.00. THE NATURE OF THE LIABILITY OR THE NUMBER OF CLAIMS OR SUITS SHALL NOT ENLARGE OR EXTEND THIS LIMIT.
|
| 102 |
+
|
| 103 |
+
These exclusions and limitations of liability shall apply regardless if NVIDIA or its affiliates have been advised of the possibility of such damages, and regardless of whether a remedy fails its essential purpose. These exclusions and limitations of liability form an essential basis of the bargain between the parties, and, absent any of these exclusions or limitations of liability, the provisions of this Agreement, including, without limitation, the economic terms, would be substantially different.
|
| 104 |
+
|
| 105 |
+
6. Termination.
|
| 106 |
+
|
| 107 |
+
6.1 This Agreement will continue to apply until terminated by either you or NVIDIA as described below.
|
| 108 |
+
|
| 109 |
+
6.2 If you want to terminate this Agreement, you may do so by stopping to use the SDK.
|
| 110 |
+
|
| 111 |
+
6.3 NVIDIA may, at any time, terminate this Agreement if: (i) you fail to comply with any term of this Agreement and the non-compliance is not fixed within thirty (30) days following notice from NVIDIA (or immediately if you violate NVIDIA’s intellectual property rights); (ii) you commence or participate in any legal proceeding against NVIDIA with respect to the SDK; or (iii) NVIDIA decides to no longer provide the SDK in a country or, in NVIDIA’s sole discretion, the continued use of it is no longer commercially viable.
|
| 112 |
+
|
| 113 |
+
6.4 Upon any termination of this Agreement, you agree to promptly discontinue use of the SDK and destroy all copies in your possession or control. Your prior distributions in accordance with this Agreement are not affected by the termination of this Agreement. Upon written request, you will certify in writing that you have complied with your commitments under this section. Upon any termination of this Agreement all provisions survive except for the licenses granted to you.
|
| 114 |
+
|
| 115 |
+
7. General.
|
| 116 |
+
|
| 117 |
+
If you wish to assign this Agreement or your rights and obligations, including by merger, consolidation, dissolution or operation of law, contact NVIDIA to ask for permission. Any attempted assignment not approved by NVIDIA in writing shall be void and of no effect. NVIDIA may assign, delegate or transfer this Agreement and its rights and obligations, and if to a non-affiliate you will be notified.
|
| 118 |
+
|
| 119 |
+
You agree to cooperate with NVIDIA and provide reasonably requested information to verify your compliance with this Agreement.
|
| 120 |
+
|
| 121 |
+
This Agreement will be governed in all respects by the laws of the United States and of the State of Delaware as those laws are applied to contracts entered into and performed entirely within Delaware by Delaware residents, without regard to the conflicts of laws principles. The United Nations Convention on Contracts for the International Sale of Goods is specifically disclaimed. You agree to all terms of this Agreement in the English language.
|
| 122 |
+
|
| 123 |
+
The state or federal courts residing in Santa Clara County, California shall have exclusive jurisdiction over any dispute or claim arising out of this Agreement. Notwithstanding this, you agree that NVIDIA shall still be allowed to apply for injunctive remedies or an equivalent type of urgent legal relief in any jurisdiction.
|
| 124 |
+
|
| 125 |
+
If any court of competent jurisdiction determines that any provision of this Agreement is illegal, invalid or unenforceable, such provision will be construed as limited to the extent necessary to be consistent with and fully enforceable under the law and the remaining provisions will remain in full force and effect. Unless otherwise specified, remedies are cumulative.
|
| 126 |
+
|
| 127 |
+
Each party acknowledges and agrees that the other is an independent contractor in the performance of this Agreement.
|
| 128 |
+
|
| 129 |
+
The SDK has been developed entirely at private expense and is “commercial items” consisting of “commercial computer software” and “commercial computer software documentation” provided with RESTRICTED RIGHTS. Use, duplication or disclosure by the U.S. Government or a U.S. Government subcontractor is subject to the restrictions in this Agreement pursuant to DFARS 227.7202-3(a) or as set forth in subparagraphs (b)(1) and (2) of the Commercial Computer Software - Restricted Rights clause at FAR 52.227-19, as applicable. Contractor/manufacturer is NVIDIA, 2788 San Tomas Expressway, Santa Clara, CA 95051.
|
| 130 |
+
|
| 131 |
+
The SDK is subject to United States export laws and regulations. You agree that you will not ship, transfer or export the SDK into any country, or use the SDK in any manner, prohibited by the United States Bureau of Industry and Security or economic sanctions regulations administered by the U.S. Department of Treasury’s Office of Foreign Assets Control (OFAC), or any applicable export laws, restrictions or regulations. These laws include restrictions on destinations, end users and end use. By accepting this Agreement, you confirm that you are not a resident or citizen of any country currently embargoed by the U.S. and that you are not otherwise prohibited from receiving the SDK.
|
| 132 |
+
|
| 133 |
+
Any notice delivered by NVIDIA to you under this Agreement will be delivered via mail, email or fax. You agree that any notices that NVIDIA sends you electronically will satisfy any legal communication requirements. Please direct your legal notices or other correspondence to NVIDIA Corporation, 2788 San Tomas Expressway, Santa Clara, California 95051, United States of America, Attention: Legal Department.
|
| 134 |
+
|
| 135 |
+
This Agreement and any exhibits incorporated into this Agreement constitute the entire agreement of the parties with respect to the subject matter of this Agreement and supersede all prior negotiations or documentation exchanged between the parties relating to this SDK license. Any additional and/or conflicting terms on documents issued by you are null, void, and invalid. Any amendment or waiver under this Agreement shall be in writing and signed by representatives of both parties.
|
| 136 |
+
|
| 137 |
+
(v. January 28, 2020)
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
cuDNN SUPPLEMENT TO SOFTWARE LICENSE AGREEMENT FOR NVIDIA SOFTWARE DEVELOPMENT KITS
|
| 141 |
+
|
| 142 |
+
The terms in this supplement govern your use of the NVIDIA cuDNN SDK under the terms of your license agreement (“Agreement”) as modified by this supplement. Capitalized terms used but not defined below have the meaning assigned to them in the Agreement.
|
| 143 |
+
|
| 144 |
+
This supplement is an exhibit to the Agreement and is incorporated as an integral part of the Agreement. In the event of conflict between the terms in this supplement and the terms in the Agreement, the terms in this supplement govern.
|
| 145 |
+
|
| 146 |
+
4.1 License Scope. The SDK is licensed for you to develop applications only for use in systems with NVIDIA GPUs.
|
| 147 |
+
|
| 148 |
+
2. Distribution. The following portions of the SDK are distributable under the Agreement: the runtime files .so and .h, cudnn64_7.dll, and cudnn.lib.
|
| 149 |
+
|
| 150 |
+
In addition to the rights above, for parties that are developing software intended solely for use on Jetson development kits or Jetson modules and running Linux for Tegra software the following shall apply: the SDK may be distributed in its entirety, as provided by NVIDIA and without separation of its components, for you and/or your licensees to create software development kits for use only on the Jetson platform and running Linux for Tegra software.
|
| 151 |
+
|
| 152 |
+
3. Licensing. If the distribution terms in this Agreement are not suitable for your organization, or for any questions regarding this Agreement, please contact NVIDIA at nvidia-compute-license-questions@nvidia.com.
|
| 153 |
+
(v. January 28, 2020)
|
| 154 |
+
|
.venv/lib/python3.11/site-packages/nvidia_cudnn_cu12-9.1.0.70.dist-info/METADATA
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.1
|
| 2 |
+
Name: nvidia-cudnn-cu12
|
| 3 |
+
Version: 9.1.0.70
|
| 4 |
+
Summary: cuDNN runtime libraries
|
| 5 |
+
Home-page: https://developer.nvidia.com/cuda-zone
|
| 6 |
+
Author: Nvidia CUDA Installer Team
|
| 7 |
+
Author-email: cuda_installer@nvidia.com
|
| 8 |
+
License: NVIDIA Proprietary Software
|
| 9 |
+
Keywords: cuda,nvidia,runtime,machine learning,deep learning
|
| 10 |
+
Classifier: Development Status :: 4 - Beta
|
| 11 |
+
Classifier: Intended Audience :: Developers
|
| 12 |
+
Classifier: Intended Audience :: Education
|
| 13 |
+
Classifier: Intended Audience :: Science/Research
|
| 14 |
+
Classifier: License :: Other/Proprietary License
|
| 15 |
+
Classifier: Natural Language :: English
|
| 16 |
+
Classifier: Programming Language :: Python :: 3
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.5
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.6
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.7
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 21 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 22 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 23 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 24 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 25 |
+
Classifier: Topic :: Scientific/Engineering
|
| 26 |
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
| 27 |
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
| 28 |
+
Classifier: Topic :: Software Development
|
| 29 |
+
Classifier: Topic :: Software Development :: Libraries
|
| 30 |
+
Classifier: Operating System :: Microsoft :: Windows
|
| 31 |
+
Classifier: Operating System :: POSIX :: Linux
|
| 32 |
+
Requires-Python: >=3
|
| 33 |
+
License-File: License.txt
|
| 34 |
+
Requires-Dist: nvidia-cublas-cu12
|
| 35 |
+
|
| 36 |
+
cuDNN runtime libraries containing primitives for deep neural networks.
|
.venv/lib/python3.11/site-packages/nvidia_cudnn_cu12-9.1.0.70.dist-info/RECORD
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
nvidia/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 2 |
+
nvidia/__pycache__/__init__.cpython-311.pyc,,
|
| 3 |
+
nvidia/cudnn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 4 |
+
nvidia/cudnn/__pycache__/__init__.cpython-311.pyc,,
|
| 5 |
+
nvidia/cudnn/include/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 6 |
+
nvidia/cudnn/include/__pycache__/__init__.cpython-311.pyc,,
|
| 7 |
+
nvidia/cudnn/include/cudnn.h,sha256=EILVHTtWS6zo72_G7jNbZosr-lF_V8Bu_UKCY-XCGFU,2841
|
| 8 |
+
nvidia/cudnn/include/cudnn_adv.h,sha256=S-ddXP6m4morsP31Uxk3Thx4VO-FF-t333vq2mY4Zlg,30820
|
| 9 |
+
nvidia/cudnn/include/cudnn_adv_v9.h,sha256=S-ddXP6m4morsP31Uxk3Thx4VO-FF-t333vq2mY4Zlg,30820
|
| 10 |
+
nvidia/cudnn/include/cudnn_backend.h,sha256=rdTyTGHQftsrhWeJS6bQwZDQCzrdyAFhoj0gbRkn1F8,2751
|
| 11 |
+
nvidia/cudnn/include/cudnn_backend_v9.h,sha256=rdTyTGHQftsrhWeJS6bQwZDQCzrdyAFhoj0gbRkn1F8,2751
|
| 12 |
+
nvidia/cudnn/include/cudnn_cnn.h,sha256=BDVryoG36A-oIfj-pPWldDsBoUds58TOCT6eNZVBr-s,36699
|
| 13 |
+
nvidia/cudnn/include/cudnn_cnn_v9.h,sha256=BDVryoG36A-oIfj-pPWldDsBoUds58TOCT6eNZVBr-s,36699
|
| 14 |
+
nvidia/cudnn/include/cudnn_graph.h,sha256=kKH3ylAvBBXYEj5p6rWX63imMBfx-O-dOrwOozFYE-k,37961
|
| 15 |
+
nvidia/cudnn/include/cudnn_graph_v9.h,sha256=kKH3ylAvBBXYEj5p6rWX63imMBfx-O-dOrwOozFYE-k,37961
|
| 16 |
+
nvidia/cudnn/include/cudnn_ops.h,sha256=B56tkXg6lAwKfSPH5-hid3UQi4uhRnHQbbROmBppmZ0,63633
|
| 17 |
+
nvidia/cudnn/include/cudnn_ops_v9.h,sha256=B56tkXg6lAwKfSPH5-hid3UQi4uhRnHQbbROmBppmZ0,63633
|
| 18 |
+
nvidia/cudnn/include/cudnn_v9.h,sha256=EILVHTtWS6zo72_G7jNbZosr-lF_V8Bu_UKCY-XCGFU,2841
|
| 19 |
+
nvidia/cudnn/include/cudnn_version.h,sha256=PGhK3WeGHAhJAJgHBF3RuX5vZSB-ClQHiPYBPPR1EGI,3112
|
| 20 |
+
nvidia/cudnn/include/cudnn_version_v9.h,sha256=PGhK3WeGHAhJAJgHBF3RuX5vZSB-ClQHiPYBPPR1EGI,3112
|
| 21 |
+
nvidia/cudnn/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 22 |
+
nvidia/cudnn/lib/__pycache__/__init__.cpython-311.pyc,,
|
| 23 |
+
nvidia/cudnn/lib/libcudnn.so.9,sha256=dKTElaJtUQQVAkHoShCEJELAJMEpzcJ0rYtqeoeUmA4,104664
|
| 24 |
+
nvidia/cudnn/lib/libcudnn_adv.so.9,sha256=voF0cmqNFSvPbhNrLR-Bdjh23rHStzKbvH0qUmNbAgI,240706416
|
| 25 |
+
nvidia/cudnn/lib/libcudnn_cnn.so.9,sha256=P4w7j3yZS-f7HOYL1WeitJ4WmJHTUVzB5ZUz6XA7byw,4724176
|
| 26 |
+
nvidia/cudnn/lib/libcudnn_engines_precompiled.so.9,sha256=7lSDboo9BIDyq1QRh3CpfLfwLx9CjVpdBHHGuJuQz8w,569645536
|
| 27 |
+
nvidia/cudnn/lib/libcudnn_engines_runtime_compiled.so.9,sha256=UZ_0FROjqBVfQw8IWsxYpfhdwWyGW4KH1UgkCVB-4sA,9585864
|
| 28 |
+
nvidia/cudnn/lib/libcudnn_graph.so.9,sha256=j9hFIHx0d3AOVqA5Wkp0ag3GGBNYU1CAJAgZu2fxoTg,3442456
|
| 29 |
+
nvidia/cudnn/lib/libcudnn_heuristic.so.9,sha256=lPq5jBUEBVjDyA8sGi9f2puqcq_Dmoi9zIIYX0nSQcM,86326864
|
| 30 |
+
nvidia/cudnn/lib/libcudnn_ops.so.9,sha256=JCudupU64uSHjWYDJiQTWpEYoWFsokWI7VhtS8xHXGk,108421928
|
| 31 |
+
nvidia_cudnn_cu12-9.1.0.70.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 32 |
+
nvidia_cudnn_cu12-9.1.0.70.dist-info/License.txt,sha256=Sc95vbNXNLUv5iAwE7O9dZ-B6ZjNMqosZcUduaiMYdI,18174
|
| 33 |
+
nvidia_cudnn_cu12-9.1.0.70.dist-info/METADATA,sha256=V1vE7NqVAZDUF6pjtO5uhb9auIBe9qfRi_tR3rYIK3E,1570
|
| 34 |
+
nvidia_cudnn_cu12-9.1.0.70.dist-info/RECORD,,
|
| 35 |
+
nvidia_cudnn_cu12-9.1.0.70.dist-info/WHEEL,sha256=XDTs3wIbcE-BcRO08VJlZpA6z9OaC1mOKPCGGGwuM2g,109
|
| 36 |
+
nvidia_cudnn_cu12-9.1.0.70.dist-info/top_level.txt,sha256=fTkAtiFuL16nUrB9ytDDtpytz2t0B4NvYTnRzwAhO14,7
|
.venv/lib/python3.11/site-packages/nvidia_cudnn_cu12-9.1.0.70.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: bdist_wheel (0.42.0)
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-manylinux2014_x86_64
|
| 5 |
+
|
.venv/lib/python3.11/site-packages/nvidia_cudnn_cu12-9.1.0.70.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
nvidia
|
.venv/lib/python3.11/site-packages/oauth2client/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (642 Bytes). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/__pycache__/_helpers.cpython-311.pyc
ADDED
|
Binary file (13.6 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/__pycache__/_openssl_crypt.cpython-311.pyc
ADDED
|
Binary file (5.79 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/__pycache__/_pkce.cpython-311.pyc
ADDED
|
Binary file (2.27 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/__pycache__/_pure_python_crypt.cpython-311.pyc
ADDED
|
Binary file (8.61 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/__pycache__/_pycrypto_crypt.cpython-311.pyc
ADDED
|
Binary file (5.61 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/__pycache__/client.cpython-311.pyc
ADDED
|
Binary file (94.2 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/__pycache__/clientsecrets.cpython-311.pyc
ADDED
|
Binary file (6.02 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/__pycache__/crypt.cpython-311.pyc
ADDED
|
Binary file (9.3 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/__pycache__/file.cpython-311.pyc
ADDED
|
Binary file (4.15 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/__pycache__/service_account.cpython-311.pyc
ADDED
|
Binary file (28.7 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/__pycache__/tools.cpython-311.pyc
ADDED
|
Binary file (11.3 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/__pycache__/transport.cpython-311.pyc
ADDED
|
Binary file (11.2 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/contrib/django_util/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (19.6 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/contrib/django_util/__pycache__/apps.cpython-311.pyc
ADDED
|
Binary file (1.04 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/contrib/django_util/__pycache__/decorators.cpython-311.pyc
ADDED
|
Binary file (6.35 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/contrib/django_util/__pycache__/models.cpython-311.pyc
ADDED
|
Binary file (3.87 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/contrib/django_util/__pycache__/signals.cpython-311.pyc
ADDED
|
Binary file (638 Bytes). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/contrib/django_util/__pycache__/storage.cpython-311.pyc
ADDED
|
Binary file (3.81 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/oauth2client/contrib/django_util/__pycache__/views.cpython-311.pyc
ADDED
|
Binary file (8.65 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/py_spy-0.4.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
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6 |
+
Classifier: Programming Language :: Python :: 2
|
| 7 |
+
Classifier: Intended Audience :: Developers
|
| 8 |
+
Classifier: License :: OSI Approved :: MIT License
|
| 9 |
+
Classifier: Topic :: Software Development :: Libraries
|
| 10 |
+
Classifier: Topic :: Utilities
|
| 11 |
+
License-File: LICENSE
|
| 12 |
+
Summary: Sampling profiler for Python programs
|
| 13 |
+
Home-Page: https://github.com/benfred/py-spy
|
| 14 |
+
Author: Ben Frederickson <github@benfrederickson.com>
|
| 15 |
+
Author-email: Ben Frederickson <github@benfrederickson.com>
|
| 16 |
+
License: MIT
|
| 17 |
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
| 18 |
+
Project-URL: Source Code, https://github.com/benfred/py-spy
|
| 19 |
+
|
| 20 |
+
py-spy: Sampling profiler for Python programs
|
| 21 |
+
=====
|
| 22 |
+
[](https://github.com/benfred/py-spy/actions?query=branch%3Amaster)
|
| 23 |
+
[](https://cirrus-ci.com/github/benfred/py-spy)
|
| 24 |
+
|
| 25 |
+
py-spy is a sampling profiler for Python programs. It lets you visualize what your Python
|
| 26 |
+
program is spending time on without restarting the program or modifying the code in any way.
|
| 27 |
+
py-spy is extremely low overhead: it is written in Rust for speed and doesn't run
|
| 28 |
+
in the same process as the profiled Python program. This means py-spy is safe to use against production Python code.
|
| 29 |
+
|
| 30 |
+
py-spy works on Linux, OSX, Windows and FreeBSD, and supports profiling all recent versions of the CPython
|
| 31 |
+
interpreter (versions 2.3-2.7 and 3.3-3.13).
|
| 32 |
+
|
| 33 |
+
## Installation
|
| 34 |
+
|
| 35 |
+
Prebuilt binary wheels can be installed from PyPI with:
|
| 36 |
+
|
| 37 |
+
```
|
| 38 |
+
pip install py-spy
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
You can also download prebuilt binaries from the [GitHub Releases
|
| 42 |
+
Page](https://github.com/benfred/py-spy/releases).
|
| 43 |
+
|
| 44 |
+
If you're a Rust user, py-spy can also be installed with: ```cargo install py-spy```. Note this
|
| 45 |
+
builds py-spy from source and requires `libunwind` on Linux and Window, e.g.,
|
| 46 |
+
`apt install libunwind-dev`.
|
| 47 |
+
|
| 48 |
+
On macOS, [py-spy is in Homebrew](https://formulae.brew.sh/formula/py-spy#default) and
|
| 49 |
+
can be installed with ```brew install py-spy```.
|
| 50 |
+
|
| 51 |
+
On Arch Linux, [py-spy is in AUR](https://aur.archlinux.org/packages/py-spy/) and can be
|
| 52 |
+
installed with ```yay -S py-spy```.
|
| 53 |
+
|
| 54 |
+
On Alpine Linux, [py-spy is in testing repository](https://pkgs.alpinelinux.org/packages?name=py-spy&branch=edge&repo=testing) and
|
| 55 |
+
can be installed with ```apk add py-spy --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted```.
|
| 56 |
+
|
| 57 |
+
## Usage
|
| 58 |
+
|
| 59 |
+
py-spy works from the command line and takes either the PID of the program you want to sample from
|
| 60 |
+
or the command line of the python program you want to run. py-spy has three subcommands
|
| 61 |
+
```record```, ```top``` and ```dump```:
|
| 62 |
+
|
| 63 |
+
### record
|
| 64 |
+
|
| 65 |
+
py-spy supports recording profiles to a file using the ```record``` command. For example, you can
|
| 66 |
+
generate a [flame graph](http://www.brendangregg.com/flamegraphs.html) of your python process by
|
| 67 |
+
going:
|
| 68 |
+
|
| 69 |
+
``` bash
|
| 70 |
+
py-spy record -o profile.svg --pid 12345
|
| 71 |
+
# OR
|
| 72 |
+
py-spy record -o profile.svg -- python myprogram.py
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
Which will generate an interactive SVG file looking like:
|
| 76 |
+
|
| 77 |
+

|
| 78 |
+
|
| 79 |
+
You can change the file format to generate
|
| 80 |
+
[speedscope](https://github.com/jlfwong/speedscope) profiles or raw data with the ```--format``` parameter.
|
| 81 |
+
See ```py-spy record --help``` for information on other options including changing
|
| 82 |
+
the sampling rate, filtering to only include threads that hold the GIL, profiling native C extensions,
|
| 83 |
+
showing thread-ids, profiling subprocesses and more.
|
| 84 |
+
|
| 85 |
+
### top
|
| 86 |
+
|
| 87 |
+
Top shows a live view of what functions are taking the most time in your python program, similar
|
| 88 |
+
to the Unix [top](https://linux.die.net/man/1/top) command. Running py-spy with:
|
| 89 |
+
|
| 90 |
+
``` bash
|
| 91 |
+
py-spy top --pid 12345
|
| 92 |
+
# OR
|
| 93 |
+
py-spy top -- python myprogram.py
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
will bring up a live updating high level view of your python program:
|
| 97 |
+
|
| 98 |
+

|
| 99 |
+
|
| 100 |
+
### dump
|
| 101 |
+
|
| 102 |
+
py-spy can also display the current call stack for each python thread with the ```dump``` command:
|
| 103 |
+
|
| 104 |
+
```bash
|
| 105 |
+
py-spy dump --pid 12345
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
This will dump out the call stacks for each thread, and some other basic process info to the
|
| 109 |
+
console:
|
| 110 |
+
|
| 111 |
+

|
| 112 |
+
|
| 113 |
+
This is useful for the case where you just need a single call stack to figure out where your
|
| 114 |
+
python program is hung on. This command also has the ability to print out the local variables
|
| 115 |
+
associated with each stack frame by setting the ```--locals``` flag.
|
| 116 |
+
|
| 117 |
+
## Frequently Asked Questions
|
| 118 |
+
|
| 119 |
+
### Why do we need another Python profiler?
|
| 120 |
+
|
| 121 |
+
This project aims to let you profile and debug any running Python program, even if the program is
|
| 122 |
+
serving production traffic.
|
| 123 |
+
|
| 124 |
+
While there are many other python profiling projects, almost all of them require modifying
|
| 125 |
+
the profiled program in some way. Usually, the profiling code runs inside of the target python process,
|
| 126 |
+
which will slow down and change how the program operates. This means it's not generally safe
|
| 127 |
+
to use these profilers for debugging issues in production services since they will usually have
|
| 128 |
+
a noticeable impact on performance.
|
| 129 |
+
|
| 130 |
+
### How does py-spy work?
|
| 131 |
+
|
| 132 |
+
py-spy works by directly reading the memory of the python program using the
|
| 133 |
+
[process_vm_readv](http://man7.org/linux/man-pages/man2/process_vm_readv.2.html) system call on Linux,
|
| 134 |
+
the [vm_read](https://developer.apple.com/documentation/kernel/1585350-vm_read?language=objc) call on OSX
|
| 135 |
+
or the [ReadProcessMemory](https://msdn.microsoft.com/en-us/library/windows/desktop/ms680553(v=vs.85).aspx) call
|
| 136 |
+
on Windows.
|
| 137 |
+
|
| 138 |
+
Figuring out the call stack of the Python program is done by looking at the global PyInterpreterState variable
|
| 139 |
+
to get all the Python threads running in the interpreter, and then iterating over each PyFrameObject in each thread
|
| 140 |
+
to get the call stack. Since the Python ABI changes between versions, we use rust's [bindgen](https://github.com/rust-lang-nursery/rust-bindgen) to generate different rust structures for each Python interpreter
|
| 141 |
+
class we care about and use these generated structs to figure out the memory layout in the Python program.
|
| 142 |
+
|
| 143 |
+
Getting the memory address of the Python Interpreter can be a little tricky due to [Address Space Layout Randomization](https://en.wikipedia.org/wiki/Address_space_layout_randomization). If the target python interpreter ships
|
| 144 |
+
with symbols it is pretty easy to figure out the memory address of the interpreter by dereferencing the
|
| 145 |
+
```interp_head``` or ```_PyRuntime``` variables depending on the Python version. However, many Python
|
| 146 |
+
versions are shipped with either stripped binaries or shipped without the corresponding PDB symbol files on Windows. In
|
| 147 |
+
these cases we scan through the BSS section for addresses that look like they may point to a valid PyInterpreterState
|
| 148 |
+
and check if the layout of that address is what we expect.
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
### Can py-spy profile native extensions?
|
| 152 |
+
|
| 153 |
+
Yes! py-spy supports profiling native python extensions written in languages like C/C++ or Cython,
|
| 154 |
+
on x86_64 Linux and Windows. You can enable this mode by passing ```--native``` on the
|
| 155 |
+
command line. For best results, you should compile your Python extension with symbols. Also worth
|
| 156 |
+
noting for Cython programs is that py-spy needs the generated C or C++ file in order to return line
|
| 157 |
+
numbers of the original .pyx file. Read the [blog post](https://www.benfrederickson.com/profiling-native-python-extensions-with-py-spy/)
|
| 158 |
+
for more information.
|
| 159 |
+
|
| 160 |
+
### How can I profile subprocesses?
|
| 161 |
+
|
| 162 |
+
By passing in the ```--subprocesses``` flag to either the record or top view, py-spy will also include
|
| 163 |
+
the output from any python process that is a child process of the target program. This is useful
|
| 164 |
+
for profiling applications that use multiprocessing or gunicorn worker pools. py-spy will monitor
|
| 165 |
+
for new processes being created, and automatically attach to them and include samples from them in
|
| 166 |
+
the output. The record view will include the PID and cmdline of each program in the callstack,
|
| 167 |
+
with subprocesses appearing as children of their parent processes.
|
| 168 |
+
|
| 169 |
+
### When do you need to run as sudo?
|
| 170 |
+
|
| 171 |
+
py-spy works by reading memory from a different python process, and this might not be allowed for security reasons depending on
|
| 172 |
+
your OS and system settings. In many cases, running as a root user (with sudo or similar) gets around these security restrictions.
|
| 173 |
+
OSX always requires running as root, but on Linux it depends on how you are launching py-spy and the system
|
| 174 |
+
security settings.
|
| 175 |
+
|
| 176 |
+
On Linux the default configuration is to require root permissions when attaching to a process that isn't a child.
|
| 177 |
+
For py-spy this means you can profile without root access by getting py-spy to create the process
|
| 178 |
+
(```py-spy record -- python myprogram.py```) but attaching to an existing process by specifying a
|
| 179 |
+
PID will usually require root (```sudo py-spy record --pid 123456```).
|
| 180 |
+
You can remove this restriction on Linux by setting the [ptrace_scope sysctl variable](https://wiki.ubuntu.com/SecurityTeam/Roadmap/KernelHardening#ptrace_Protection).
|
| 181 |
+
|
| 182 |
+
### How do you detect if a thread is idle or not?
|
| 183 |
+
|
| 184 |
+
py-spy attempts to only include stack traces from threads that are actively running code, and exclude threads that
|
| 185 |
+
are sleeping or otherwise idle. When possible, py-spy attempts to get this thread activity information
|
| 186 |
+
from the OS: by reading in ```/proc/PID/stat``` on Linux, by using the mach
|
| 187 |
+
[thread_basic_info](https://opensource.apple.com/source/xnu/xnu-792/osfmk/mach/thread_info.h.auto.html)
|
| 188 |
+
call on OSX, and by looking if the current SysCall is [known to be
|
| 189 |
+
idle](https://github.com/benfred/py-spy/blob/8326c6dbc6241d60125dfd4c01b70fed8b8b8138/remoteprocess/src/windows/mod.rs#L212-L229)
|
| 190 |
+
on Windows.
|
| 191 |
+
|
| 192 |
+
There are some limitations with this approach though that may cause idle threads to still be
|
| 193 |
+
marked as active. First off, we have to get this thread activity information before pausing the
|
| 194 |
+
program, because getting this from a paused program will cause it to always return that this is
|
| 195 |
+
idle. This means there is a potential race condition, where we get the thread activity and
|
| 196 |
+
then the thread is in a different state when we get the stack trace. Querying the OS for thread
|
| 197 |
+
activity also isn't implemented yet for FreeBSD and i686/ARM processors on Linux. On Windows,
|
| 198 |
+
calls that are blocked on IO also won't be marked as idle yet, for instance when reading input
|
| 199 |
+
from stdin. Finally, on some Linux calls the ptrace attach that we are using may cause idle threads
|
| 200 |
+
to wake up momentarily, causing false positives when reading from procfs. For these reasons,
|
| 201 |
+
we also have a heuristic fallback that marks known certain known calls in
|
| 202 |
+
python as being idle.
|
| 203 |
+
|
| 204 |
+
You can disable this functionality by setting the ```--idle``` flag, which
|
| 205 |
+
will include frames that py-spy considers idle.
|
| 206 |
+
|
| 207 |
+
### How does GIL detection work?
|
| 208 |
+
|
| 209 |
+
We get GIL activity by looking at the threadid value pointed to by the ```_PyThreadState_Current``` symbol
|
| 210 |
+
for Python 3.6 and earlier and by figuring out the equivalent from the ```_PyRuntime``` struct in
|
| 211 |
+
Python 3.7 and later. These symbols might not be included in your python distribution, which will
|
| 212 |
+
cause resolving which thread holds on to the GIL to fail. Current GIL usage is also shown in the
|
| 213 |
+
```top``` view as %GIL.
|
| 214 |
+
|
| 215 |
+
Passing the ```--gil``` flag will only include traces for threads that are holding on to the
|
| 216 |
+
[Global Interpreter Lock](https://wiki.python.org/moin/GlobalInterpreterLock). In some cases this
|
| 217 |
+
might be a more accurate view of how your python program is spending its time, though you should
|
| 218 |
+
be aware that this will miss activity in extensions that release the GIL while still active.
|
| 219 |
+
|
| 220 |
+
### Why am I having issues profiling /usr/bin/python on OSX?
|
| 221 |
+
|
| 222 |
+
OSX has a feature called [System Integrity Protection](https://en.wikipedia.org/wiki/System_Integrity_Protection) that prevents even the root user from reading memory from any binary located in /usr/bin. Unfortunately, this includes the python interpreter that ships with OSX.
|
| 223 |
+
|
| 224 |
+
There are a couple of different ways to deal with this:
|
| 225 |
+
* You can install a different Python distribution. The built-in Python [will be removed](https://developer.apple.com/documentation/macos_release_notes/macos_catalina_10_15_release_notes) in a future OSX, and you probably want to migrate away from Python 2 anyways =).
|
| 226 |
+
* You can use [virtualenv](https://virtualenv.pypa.io/en/stable/) to run the system python in an environment where SIP doesn't apply.
|
| 227 |
+
* You can [disable System Integrity Protection](https://www.macworld.co.uk/how-to/mac/how-turn-off-mac-os-x-system-integrity-protection-rootless-3638975/).
|
| 228 |
+
|
| 229 |
+
### How do I run py-spy in Docker?
|
| 230 |
+
|
| 231 |
+
Running py-spy inside of a docker container will also usually bring up a permissions denied error even when running as root.
|
| 232 |
+
|
| 233 |
+
This error is caused by docker restricting the process_vm_readv system call we are using. This can
|
| 234 |
+
be overridden by setting
|
| 235 |
+
[```--cap-add SYS_PTRACE```](https://docs.docker.com/engine/security/seccomp/) when starting the docker container.
|
| 236 |
+
|
| 237 |
+
Alternatively you can edit the docker-compose yaml file
|
| 238 |
+
|
| 239 |
+
```
|
| 240 |
+
your_service:
|
| 241 |
+
cap_add:
|
| 242 |
+
- SYS_PTRACE
|
| 243 |
+
```
|
| 244 |
+
|
| 245 |
+
Note that you'll need to restart the docker container in order for this setting to take effect.
|
| 246 |
+
|
| 247 |
+
You can also use py-spy from the Host OS to profile a running process running inside the docker
|
| 248 |
+
container.
|
| 249 |
+
|
| 250 |
+
### How do I run py-spy in Kubernetes?
|
| 251 |
+
|
| 252 |
+
py-spy needs `SYS_PTRACE` to be able to read process memory. Kubernetes drops that capability by default, resulting in the error
|
| 253 |
+
```
|
| 254 |
+
Permission Denied: Try running again with elevated permissions by going 'sudo env "PATH=$PATH" !!'
|
| 255 |
+
```
|
| 256 |
+
The recommended way to deal with this is to edit the spec and add that capability. For a deployment, this is done by adding this to `Deployment.spec.template.spec.containers`
|
| 257 |
+
```
|
| 258 |
+
securityContext:
|
| 259 |
+
capabilities:
|
| 260 |
+
add:
|
| 261 |
+
- SYS_PTRACE
|
| 262 |
+
```
|
| 263 |
+
More details on this here: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-capabilities-for-a-container
|
| 264 |
+
Note that this will remove the existing pods and create those again.
|
| 265 |
+
|
| 266 |
+
### How do I install py-spy on Alpine Linux?
|
| 267 |
+
|
| 268 |
+
Alpine python opts out of the `manylinux` wheels: [pypa/pip#3969 (comment)](https://github.com/pypa/pip/issues/3969#issuecomment-247381915).
|
| 269 |
+
You can override this behaviour to use pip to install py-spy on Alpine by going:
|
| 270 |
+
|
| 271 |
+
echo 'manylinux1_compatible = True' > /usr/local/lib/python3.7/site-packages/_manylinux.py
|
| 272 |
+
|
| 273 |
+
Alternatively you can download a musl binary from the [GitHub releases page](https://github.com/benfred/py-spy/releases).
|
| 274 |
+
|
| 275 |
+
### How can I avoid pausing the Python program?
|
| 276 |
+
|
| 277 |
+
By setting the ```--nonblocking``` option, py-spy won't pause the target python you are profiling from. While
|
| 278 |
+
the performance impact of sampling from a process with py-spy is usually extremely low, setting this option
|
| 279 |
+
will totally avoid interrupting your running python program.
|
| 280 |
+
|
| 281 |
+
With this option set, py-spy will instead read the interpreter state from the python process as it is running.
|
| 282 |
+
Since the calls we use to read memory from are not atomic, and we have to issue multiple calls to get a stack trace this
|
| 283 |
+
means that occasionally we get errors when sampling. This can show up as an increased error rate when sampling, or as
|
| 284 |
+
partial stack frames being included in the output.
|
| 285 |
+
|
| 286 |
+
### Does py-spy support 32-bit Windows? Integrate with PyPy? Work with USC2 versions of Python2?
|
| 287 |
+
|
| 288 |
+
Not yet =).
|
| 289 |
+
|
| 290 |
+
If there are features you'd like to see in py-spy either thumb up the [appropriate
|
| 291 |
+
issue](https://github.com/benfred/py-spy/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc) or create a new one that describes what functionality is missing.
|
| 292 |
+
|
| 293 |
+
### How to force colored output when piping to a pager?
|
| 294 |
+
|
| 295 |
+
py-spy follows the [CLICOLOR](https://bixense.com/clicolors/) specification, thus setting `CLICOLOR_FORCE=1` in your environment will have py-spy print colored output even when piped to a pager.
|
| 296 |
+
|
| 297 |
+
## Credits
|
| 298 |
+
|
| 299 |
+
py-spy is heavily inspired by [Julia Evans](https://github.com/jvns/) excellent work on [rbspy](http://github.com/rbspy/rbspy).
|
| 300 |
+
In particular, the code to generate flamegraph and speedscope files is taken directly from rbspy, and this project uses the
|
| 301 |
+
[read-process-memory](https://github.com/luser/read-process-memory) and [proc-maps](https://github.com/benfred/proc-maps) crates that were spun off from rbspy.
|
| 302 |
+
|
| 303 |
+
## License
|
| 304 |
+
|
| 305 |
+
py-spy is released under the MIT License, see the [LICENSE](https://github.com/benfred/py-spy/blob/master/LICENSE) file for the full text.
|
| 306 |
+
|
.venv/lib/python3.11/site-packages/py_spy-0.4.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
../../../bin/py-spy,sha256=rPM5-WiLmVQZ1Ox5lM_MgA8ZF8pkjon68C-HWKel7zo,7658552
|
| 2 |
+
py_spy-0.4.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 3 |
+
py_spy-0.4.0.dist-info/METADATA,sha256=T74VqNoB9RgvkC9_eTA9w54U2ulg0I9vqiupazuWEus,16461
|
| 4 |
+
py_spy-0.4.0.dist-info/RECORD,,
|
| 5 |
+
py_spy-0.4.0.dist-info/WHEEL,sha256=McrmRllnOpiJfNX5v2otJqnu23qUciIDu9Ur1276LCQ,122
|
| 6 |
+
py_spy-0.4.0.dist-info/licenses/LICENSE,sha256=gLu4cx21nNg19Z_NBvEnlTgEu1EchIf9Jl2Wx8cCzQA,1088
|
.venv/lib/python3.11/site-packages/py_spy-0.4.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: maturin (1.7.4)
|
| 3 |
+
Root-Is-Purelib: false
|
| 4 |
+
Tag: py3-none-manylinux_2_5_x86_64.manylinux1_x86_64
|
.venv/lib/python3.11/site-packages/py_spy-0.4.0.dist-info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2018-2019 Ben Frederickson
|
| 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.
|
.venv/lib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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file was automatically generated by SWIG (https://www.swig.org).
|
| 2 |
+
# Version 4.1.0
|
| 3 |
+
#
|
| 4 |
+
# Do not make changes to this file unless you know what you are doing - modify
|
| 5 |
+
# the SWIG interface file instead.
|
| 6 |
+
|
| 7 |
+
from sys import version_info as _swig_python_version_info
|
| 8 |
+
# Import the low-level C/C++ module
|
| 9 |
+
if __package__ or "." in __name__:
|
| 10 |
+
from . import _sentencepiece
|
| 11 |
+
else:
|
| 12 |
+
import _sentencepiece
|
| 13 |
+
|
| 14 |
+
try:
|
| 15 |
+
import builtins as __builtin__
|
| 16 |
+
except ImportError:
|
| 17 |
+
import __builtin__
|
| 18 |
+
|
| 19 |
+
def _swig_repr(self):
|
| 20 |
+
try:
|
| 21 |
+
strthis = "proxy of " + self.this.__repr__()
|
| 22 |
+
except __builtin__.Exception:
|
| 23 |
+
strthis = ""
|
| 24 |
+
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _swig_setattr_nondynamic_instance_variable(set):
|
| 28 |
+
def set_instance_attr(self, name, value):
|
| 29 |
+
if name == "this":
|
| 30 |
+
set(self, name, value)
|
| 31 |
+
elif name == "thisown":
|
| 32 |
+
self.this.own(value)
|
| 33 |
+
elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
|
| 34 |
+
set(self, name, value)
|
| 35 |
+
else:
|
| 36 |
+
raise AttributeError("You cannot add instance attributes to %s" % self)
|
| 37 |
+
return set_instance_attr
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def _swig_setattr_nondynamic_class_variable(set):
|
| 41 |
+
def set_class_attr(cls, name, value):
|
| 42 |
+
if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
|
| 43 |
+
set(cls, name, value)
|
| 44 |
+
else:
|
| 45 |
+
raise AttributeError("You cannot add class attributes to %s" % cls)
|
| 46 |
+
return set_class_attr
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def _swig_add_metaclass(metaclass):
|
| 50 |
+
"""Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
|
| 51 |
+
def wrapper(cls):
|
| 52 |
+
return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
|
| 53 |
+
return wrapper
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
class _SwigNonDynamicMeta(type):
|
| 57 |
+
"""Meta class to enforce nondynamic attributes (no new attributes) for a class"""
|
| 58 |
+
__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
class ImmutableSentencePieceText_ImmutableSentencePiece(object):
|
| 62 |
+
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
| 63 |
+
__repr__ = _swig_repr
|
| 64 |
+
|
| 65 |
+
def __init__(self):
|
| 66 |
+
_sentencepiece.ImmutableSentencePieceText_ImmutableSentencePiece_swiginit(self, _sentencepiece.new_ImmutableSentencePieceText_ImmutableSentencePiece())
|
| 67 |
+
__swig_destroy__ = _sentencepiece.delete_ImmutableSentencePieceText_ImmutableSentencePiece
|
| 68 |
+
|
| 69 |
+
def _piece(self):
|
| 70 |
+
return _sentencepiece.ImmutableSentencePieceText_ImmutableSentencePiece__piece(self)
|
| 71 |
+
|
| 72 |
+
def _surface(self):
|
| 73 |
+
return _sentencepiece.ImmutableSentencePieceText_ImmutableSentencePiece__surface(self)
|
| 74 |
+
|
| 75 |
+
def _id(self):
|
| 76 |
+
return _sentencepiece.ImmutableSentencePieceText_ImmutableSentencePiece__id(self)
|
| 77 |
+
|
| 78 |
+
def _begin(self):
|
| 79 |
+
return _sentencepiece.ImmutableSentencePieceText_ImmutableSentencePiece__begin(self)
|
| 80 |
+
|
| 81 |
+
def _end(self):
|
| 82 |
+
return _sentencepiece.ImmutableSentencePieceText_ImmutableSentencePiece__end(self)
|
| 83 |
+
|
| 84 |
+
def _surface_as_bytes(self):
|
| 85 |
+
return _sentencepiece.ImmutableSentencePieceText_ImmutableSentencePiece__surface_as_bytes(self)
|
| 86 |
+
|
| 87 |
+
def _piece_as_bytes(self):
|
| 88 |
+
return _sentencepiece.ImmutableSentencePieceText_ImmutableSentencePiece__piece_as_bytes(self)
|
| 89 |
+
|
| 90 |
+
piece = property(_piece)
|
| 91 |
+
piece_as_bytes = property(_piece_as_bytes)
|
| 92 |
+
surface = property(_surface)
|
| 93 |
+
surface_as_bytes = property(_surface_as_bytes)
|
| 94 |
+
id = property(_id)
|
| 95 |
+
begin = property(_begin)
|
| 96 |
+
end = property(_end)
|
| 97 |
+
|
| 98 |
+
def __str__(self):
|
| 99 |
+
return ('piece: \"{}\"\n'
|
| 100 |
+
'id: {}\n'
|
| 101 |
+
'surface: \"{}\"\n'
|
| 102 |
+
'begin: {}\n'
|
| 103 |
+
'end: {}\n').format(self.piece, self.id, self.surface,
|
| 104 |
+
self.begin, self.end)
|
| 105 |
+
|
| 106 |
+
def __eq__(self, other):
|
| 107 |
+
return self.piece == other.piece and self.id == other.id and self.surface == other.surface and self.begin == other.begin and self.end == other.end
|
| 108 |
+
|
| 109 |
+
def __hash__(self):
|
| 110 |
+
return hash(str(self))
|
| 111 |
+
|
| 112 |
+
__repr__ = __str__
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
# Register ImmutableSentencePieceText_ImmutableSentencePiece in _sentencepiece:
|
| 116 |
+
_sentencepiece.ImmutableSentencePieceText_ImmutableSentencePiece_swigregister(ImmutableSentencePieceText_ImmutableSentencePiece)
|
| 117 |
+
class ImmutableSentencePieceText(object):
|
| 118 |
+
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
| 119 |
+
__repr__ = _swig_repr
|
| 120 |
+
|
| 121 |
+
def __init__(self):
|
| 122 |
+
_sentencepiece.ImmutableSentencePieceText_swiginit(self, _sentencepiece.new_ImmutableSentencePieceText())
|
| 123 |
+
__swig_destroy__ = _sentencepiece.delete_ImmutableSentencePieceText
|
| 124 |
+
|
| 125 |
+
def _pieces_size(self):
|
| 126 |
+
return _sentencepiece.ImmutableSentencePieceText__pieces_size(self)
|
| 127 |
+
|
| 128 |
+
def _pieces(self, index):
|
| 129 |
+
return _sentencepiece.ImmutableSentencePieceText__pieces(self, index)
|
| 130 |
+
|
| 131 |
+
def _text(self):
|
| 132 |
+
return _sentencepiece.ImmutableSentencePieceText__text(self)
|
| 133 |
+
|
| 134 |
+
def _score(self):
|
| 135 |
+
return _sentencepiece.ImmutableSentencePieceText__score(self)
|
| 136 |
+
|
| 137 |
+
def SerializeAsString(self):
|
| 138 |
+
return _sentencepiece.ImmutableSentencePieceText_SerializeAsString(self)
|
| 139 |
+
|
| 140 |
+
def _text_as_bytes(self):
|
| 141 |
+
return _sentencepiece.ImmutableSentencePieceText__text_as_bytes(self)
|
| 142 |
+
|
| 143 |
+
text = property(_text)
|
| 144 |
+
text_as_bytes = property(_text_as_bytes)
|
| 145 |
+
score = property(_score)
|
| 146 |
+
|
| 147 |
+
class ImmutableSentencePieceIterator:
|
| 148 |
+
def __init__(self, proto):
|
| 149 |
+
self.proto = proto
|
| 150 |
+
self.len = self.proto._pieces_size()
|
| 151 |
+
|
| 152 |
+
def __len__(self):
|
| 153 |
+
return self.len
|
| 154 |
+
|
| 155 |
+
def __getitem__(self, index):
|
| 156 |
+
if isinstance(index, slice):
|
| 157 |
+
return [self.proto._pieces(i) for i in range(self.len)][index.start:index.stop:index.step]
|
| 158 |
+
if index < 0:
|
| 159 |
+
index = index + self.len
|
| 160 |
+
if index < 0 or index >= self.len:
|
| 161 |
+
raise IndexError('piece index is out of range')
|
| 162 |
+
return self.proto._pieces(index)
|
| 163 |
+
|
| 164 |
+
def __str__(self):
|
| 165 |
+
return '\n'.join(['pieces {{\n{}}}'.format(str(x)) for x in self])
|
| 166 |
+
|
| 167 |
+
__repr__ = __str__
|
| 168 |
+
|
| 169 |
+
@property
|
| 170 |
+
def pieces(self):
|
| 171 |
+
return ImmutableSentencePieceText.ImmutableSentencePieceIterator(self)
|
| 172 |
+
|
| 173 |
+
def __eq__(self, other):
|
| 174 |
+
return self.SerializeAsString() == other.SerializeAsString()
|
| 175 |
+
|
| 176 |
+
def __hash__(self):
|
| 177 |
+
return hash(self.SerializeAsString())
|
| 178 |
+
|
| 179 |
+
def __str__(self):
|
| 180 |
+
return ('text: \"{}\"\n'
|
| 181 |
+
'score: {}\n'
|
| 182 |
+
'{}').format(self.text, self.score,
|
| 183 |
+
'\n'.join(['pieces {{\n{}}}'.format(str(x)) for x in self.pieces]))
|
| 184 |
+
|
| 185 |
+
__repr__ = __str__
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
# Register ImmutableSentencePieceText in _sentencepiece:
|
| 189 |
+
_sentencepiece.ImmutableSentencePieceText_swigregister(ImmutableSentencePieceText)
|
| 190 |
+
class ImmutableNBestSentencePieceText(object):
|
| 191 |
+
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
| 192 |
+
__repr__ = _swig_repr
|
| 193 |
+
|
| 194 |
+
def __init__(self):
|
| 195 |
+
_sentencepiece.ImmutableNBestSentencePieceText_swiginit(self, _sentencepiece.new_ImmutableNBestSentencePieceText())
|
| 196 |
+
__swig_destroy__ = _sentencepiece.delete_ImmutableNBestSentencePieceText
|
| 197 |
+
|
| 198 |
+
def _nbests_size(self):
|
| 199 |
+
return _sentencepiece.ImmutableNBestSentencePieceText__nbests_size(self)
|
| 200 |
+
|
| 201 |
+
def _nbests(self, index):
|
| 202 |
+
return _sentencepiece.ImmutableNBestSentencePieceText__nbests(self, index)
|
| 203 |
+
|
| 204 |
+
def SerializeAsString(self):
|
| 205 |
+
return _sentencepiece.ImmutableNBestSentencePieceText_SerializeAsString(self)
|
| 206 |
+
|
| 207 |
+
class ImmutableSentencePieceTextIterator:
|
| 208 |
+
def __init__(self, proto):
|
| 209 |
+
self.proto = proto
|
| 210 |
+
self.len = self.proto._nbests_size()
|
| 211 |
+
|
| 212 |
+
def __len__(self):
|
| 213 |
+
return self.len
|
| 214 |
+
|
| 215 |
+
def __getitem__(self, index):
|
| 216 |
+
if isinstance(index, slice):
|
| 217 |
+
return [self.proto._nbests(i) for i in range(self.len)][index.start:index.stop:index.step]
|
| 218 |
+
if index < 0:
|
| 219 |
+
index = index + self.len
|
| 220 |
+
if index < 0 or index >= self.len:
|
| 221 |
+
raise IndexError('nbests index is out of range')
|
| 222 |
+
return self.proto._nbests(index)
|
| 223 |
+
|
| 224 |
+
def __str__(self):
|
| 225 |
+
return '\n'.join(['nbests {{\n{}}}'.format(str(x)) for x in self])
|
| 226 |
+
|
| 227 |
+
__repr__ = __str__
|
| 228 |
+
|
| 229 |
+
@property
|
| 230 |
+
def nbests(self):
|
| 231 |
+
return ImmutableNBestSentencePieceText.ImmutableSentencePieceTextIterator(self)
|
| 232 |
+
|
| 233 |
+
def __eq__(self, other):
|
| 234 |
+
return self.SerializeAsString() == other.SerializeAsString()
|
| 235 |
+
|
| 236 |
+
def __hash__(self):
|
| 237 |
+
return hash(self.SerializeAsString())
|
| 238 |
+
|
| 239 |
+
def __str__(self):
|
| 240 |
+
return '\n'.join(['nbests {{\n{}}}'.format(str(x)) for x in self.nbests])
|
| 241 |
+
|
| 242 |
+
__repr__ = __str__
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
# Register ImmutableNBestSentencePieceText in _sentencepiece:
|
| 246 |
+
_sentencepiece.ImmutableNBestSentencePieceText_swigregister(ImmutableNBestSentencePieceText)
|
| 247 |
+
class SentencePieceProcessor(object):
|
| 248 |
+
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
| 249 |
+
__repr__ = _swig_repr
|
| 250 |
+
|
| 251 |
+
def __init__(self):
|
| 252 |
+
_sentencepiece.SentencePieceProcessor_swiginit(self, _sentencepiece.new_SentencePieceProcessor())
|
| 253 |
+
__swig_destroy__ = _sentencepiece.delete_SentencePieceProcessor
|
| 254 |
+
|
| 255 |
+
def LoadFromSerializedProto(self, serialized):
|
| 256 |
+
return _sentencepiece.SentencePieceProcessor_LoadFromSerializedProto(self, serialized)
|
| 257 |
+
|
| 258 |
+
def SetEncodeExtraOptions(self, extra_option):
|
| 259 |
+
return _sentencepiece.SentencePieceProcessor_SetEncodeExtraOptions(self, extra_option)
|
| 260 |
+
|
| 261 |
+
def SetDecodeExtraOptions(self, extra_option):
|
| 262 |
+
return _sentencepiece.SentencePieceProcessor_SetDecodeExtraOptions(self, extra_option)
|
| 263 |
+
|
| 264 |
+
def SetVocabulary(self, valid_vocab):
|
| 265 |
+
return _sentencepiece.SentencePieceProcessor_SetVocabulary(self, valid_vocab)
|
| 266 |
+
|
| 267 |
+
def ResetVocabulary(self):
|
| 268 |
+
return _sentencepiece.SentencePieceProcessor_ResetVocabulary(self)
|
| 269 |
+
|
| 270 |
+
def LoadVocabulary(self, filename, threshold):
|
| 271 |
+
return _sentencepiece.SentencePieceProcessor_LoadVocabulary(self, filename, threshold)
|
| 272 |
+
|
| 273 |
+
def CalculateEntropy(self, *args):
|
| 274 |
+
return _sentencepiece.SentencePieceProcessor_CalculateEntropy(self, *args)
|
| 275 |
+
|
| 276 |
+
def GetPieceSize(self):
|
| 277 |
+
return _sentencepiece.SentencePieceProcessor_GetPieceSize(self)
|
| 278 |
+
|
| 279 |
+
def PieceToId(self, piece):
|
| 280 |
+
return _sentencepiece.SentencePieceProcessor_PieceToId(self, piece)
|
| 281 |
+
|
| 282 |
+
def IdToPiece(self, id):
|
| 283 |
+
return _sentencepiece.SentencePieceProcessor_IdToPiece(self, id)
|
| 284 |
+
|
| 285 |
+
def GetScore(self, id):
|
| 286 |
+
return _sentencepiece.SentencePieceProcessor_GetScore(self, id)
|
| 287 |
+
|
| 288 |
+
def IsUnknown(self, id):
|
| 289 |
+
return _sentencepiece.SentencePieceProcessor_IsUnknown(self, id)
|
| 290 |
+
|
| 291 |
+
def IsControl(self, id):
|
| 292 |
+
return _sentencepiece.SentencePieceProcessor_IsControl(self, id)
|
| 293 |
+
|
| 294 |
+
def IsUnused(self, id):
|
| 295 |
+
return _sentencepiece.SentencePieceProcessor_IsUnused(self, id)
|
| 296 |
+
|
| 297 |
+
def IsByte(self, id):
|
| 298 |
+
return _sentencepiece.SentencePieceProcessor_IsByte(self, id)
|
| 299 |
+
|
| 300 |
+
def unk_id(self):
|
| 301 |
+
return _sentencepiece.SentencePieceProcessor_unk_id(self)
|
| 302 |
+
|
| 303 |
+
def bos_id(self):
|
| 304 |
+
return _sentencepiece.SentencePieceProcessor_bos_id(self)
|
| 305 |
+
|
| 306 |
+
def eos_id(self):
|
| 307 |
+
return _sentencepiece.SentencePieceProcessor_eos_id(self)
|
| 308 |
+
|
| 309 |
+
def pad_id(self):
|
| 310 |
+
return _sentencepiece.SentencePieceProcessor_pad_id(self)
|
| 311 |
+
|
| 312 |
+
def serialized_model_proto(self):
|
| 313 |
+
return _sentencepiece.SentencePieceProcessor_serialized_model_proto(self)
|
| 314 |
+
|
| 315 |
+
def LoadFromFile(self, arg):
|
| 316 |
+
return _sentencepiece.SentencePieceProcessor_LoadFromFile(self, arg)
|
| 317 |
+
|
| 318 |
+
def _EncodeAsIds(self, text, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece):
|
| 319 |
+
return _sentencepiece.SentencePieceProcessor__EncodeAsIds(self, text, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 320 |
+
|
| 321 |
+
def _EncodeAsPieces(self, text, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece):
|
| 322 |
+
return _sentencepiece.SentencePieceProcessor__EncodeAsPieces(self, text, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 323 |
+
|
| 324 |
+
def _EncodeAsSerializedProto(self, text, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece):
|
| 325 |
+
return _sentencepiece.SentencePieceProcessor__EncodeAsSerializedProto(self, text, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 326 |
+
|
| 327 |
+
def _EncodeAsImmutableProto(self, text, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece):
|
| 328 |
+
return _sentencepiece.SentencePieceProcessor__EncodeAsImmutableProto(self, text, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 329 |
+
|
| 330 |
+
def _EncodeAsIdsBatch(self, ins, num_threads, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece):
|
| 331 |
+
return _sentencepiece.SentencePieceProcessor__EncodeAsIdsBatch(self, ins, num_threads, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 332 |
+
|
| 333 |
+
def _EncodeAsPiecesBatch(self, ins, num_threads, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece):
|
| 334 |
+
return _sentencepiece.SentencePieceProcessor__EncodeAsPiecesBatch(self, ins, num_threads, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 335 |
+
|
| 336 |
+
def _EncodeAsSerializedProtoBatch(self, ins, num_threads, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece):
|
| 337 |
+
return _sentencepiece.SentencePieceProcessor__EncodeAsSerializedProtoBatch(self, ins, num_threads, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 338 |
+
|
| 339 |
+
def _EncodeAsImmutableProtoBatch(self, ins, num_threads, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece):
|
| 340 |
+
return _sentencepiece.SentencePieceProcessor__EncodeAsImmutableProtoBatch(self, ins, num_threads, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 341 |
+
|
| 342 |
+
def _DecodeIds(self, ids):
|
| 343 |
+
return _sentencepiece.SentencePieceProcessor__DecodeIds(self, ids)
|
| 344 |
+
|
| 345 |
+
def _DecodeIdsAsBytes(self, ids):
|
| 346 |
+
return _sentencepiece.SentencePieceProcessor__DecodeIdsAsBytes(self, ids)
|
| 347 |
+
|
| 348 |
+
def _DecodePieces(self, pieces):
|
| 349 |
+
return _sentencepiece.SentencePieceProcessor__DecodePieces(self, pieces)
|
| 350 |
+
|
| 351 |
+
def _DecodeIdsAsSerializedProto(self, ids):
|
| 352 |
+
return _sentencepiece.SentencePieceProcessor__DecodeIdsAsSerializedProto(self, ids)
|
| 353 |
+
|
| 354 |
+
def _DecodePiecesAsSerializedProto(self, pieces):
|
| 355 |
+
return _sentencepiece.SentencePieceProcessor__DecodePiecesAsSerializedProto(self, pieces)
|
| 356 |
+
|
| 357 |
+
def _DecodeIdsAsImmutableProto(self, ids):
|
| 358 |
+
return _sentencepiece.SentencePieceProcessor__DecodeIdsAsImmutableProto(self, ids)
|
| 359 |
+
|
| 360 |
+
def _DecodePiecesAsImmutableProto(self, pieces):
|
| 361 |
+
return _sentencepiece.SentencePieceProcessor__DecodePiecesAsImmutableProto(self, pieces)
|
| 362 |
+
|
| 363 |
+
def _DecodeIdsBatch(self, ins, num_threads):
|
| 364 |
+
return _sentencepiece.SentencePieceProcessor__DecodeIdsBatch(self, ins, num_threads)
|
| 365 |
+
|
| 366 |
+
def _DecodeIdsAsBytesBatch(self, ins, num_threads):
|
| 367 |
+
return _sentencepiece.SentencePieceProcessor__DecodeIdsAsBytesBatch(self, ins, num_threads)
|
| 368 |
+
|
| 369 |
+
def _DecodeIdsAsSerializedProtoBatch(self, ins, num_threads):
|
| 370 |
+
return _sentencepiece.SentencePieceProcessor__DecodeIdsAsSerializedProtoBatch(self, ins, num_threads)
|
| 371 |
+
|
| 372 |
+
def _DecodeIdsAsImmutableProtoBatch(self, ins, num_threads):
|
| 373 |
+
return _sentencepiece.SentencePieceProcessor__DecodeIdsAsImmutableProtoBatch(self, ins, num_threads)
|
| 374 |
+
|
| 375 |
+
def _DecodePiecesBatch(self, ins, num_threads):
|
| 376 |
+
return _sentencepiece.SentencePieceProcessor__DecodePiecesBatch(self, ins, num_threads)
|
| 377 |
+
|
| 378 |
+
def _DecodePiecesAsSerializedProtoBatch(self, ins, num_threads):
|
| 379 |
+
return _sentencepiece.SentencePieceProcessor__DecodePiecesAsSerializedProtoBatch(self, ins, num_threads)
|
| 380 |
+
|
| 381 |
+
def _DecodePiecesAsImmutableProtoBatch(self, ins, num_threads):
|
| 382 |
+
return _sentencepiece.SentencePieceProcessor__DecodePiecesAsImmutableProtoBatch(self, ins, num_threads)
|
| 383 |
+
|
| 384 |
+
def _NBestEncodeAsIds(self, text, nbest_size, add_bos, add_eos, reverse, emit_unk_piece):
|
| 385 |
+
return _sentencepiece.SentencePieceProcessor__NBestEncodeAsIds(self, text, nbest_size, add_bos, add_eos, reverse, emit_unk_piece)
|
| 386 |
+
|
| 387 |
+
def _NBestEncodeAsPieces(self, text, nbest_size, add_bos, add_eos, reverse, emit_unk_piece):
|
| 388 |
+
return _sentencepiece.SentencePieceProcessor__NBestEncodeAsPieces(self, text, nbest_size, add_bos, add_eos, reverse, emit_unk_piece)
|
| 389 |
+
|
| 390 |
+
def _NBestEncodeAsSerializedProto(self, text, nbest_size, add_bos, add_eos, reverse, emit_unk_piece):
|
| 391 |
+
return _sentencepiece.SentencePieceProcessor__NBestEncodeAsSerializedProto(self, text, nbest_size, add_bos, add_eos, reverse, emit_unk_piece)
|
| 392 |
+
|
| 393 |
+
def _NBestEncodeAsImmutableProto(self, text, nbest_size, add_bos, add_eos, reverse, emit_unk_piece):
|
| 394 |
+
return _sentencepiece.SentencePieceProcessor__NBestEncodeAsImmutableProto(self, text, nbest_size, add_bos, add_eos, reverse, emit_unk_piece)
|
| 395 |
+
|
| 396 |
+
def _SampleEncodeAndScoreAsIds(self, text, num_samples, alpha, wor, include_best, add_bos, add_eos, reverse, emit_unk_piece):
|
| 397 |
+
return _sentencepiece.SentencePieceProcessor__SampleEncodeAndScoreAsIds(self, text, num_samples, alpha, wor, include_best, add_bos, add_eos, reverse, emit_unk_piece)
|
| 398 |
+
|
| 399 |
+
def _SampleEncodeAndScoreAsPieces(self, text, num_samples, alpha, wor, include_best, add_bos, add_eos, reverse, emit_unk_piece):
|
| 400 |
+
return _sentencepiece.SentencePieceProcessor__SampleEncodeAndScoreAsPieces(self, text, num_samples, alpha, wor, include_best, add_bos, add_eos, reverse, emit_unk_piece)
|
| 401 |
+
|
| 402 |
+
def _SampleEncodeAndScoreAsSerializedProto(self, text, num_samples, alpha, wor, include_best, add_bos, add_eos, reverse, emit_unk_piece):
|
| 403 |
+
return _sentencepiece.SentencePieceProcessor__SampleEncodeAndScoreAsSerializedProto(self, text, num_samples, alpha, wor, include_best, add_bos, add_eos, reverse, emit_unk_piece)
|
| 404 |
+
|
| 405 |
+
def _SampleEncodeAndScoreAsImmutableProto(self, text, num_samples, alpha, wor, include_best, add_bos, add_eos, reverse, emit_unk_piece):
|
| 406 |
+
return _sentencepiece.SentencePieceProcessor__SampleEncodeAndScoreAsImmutableProto(self, text, num_samples, alpha, wor, include_best, add_bos, add_eos, reverse, emit_unk_piece)
|
| 407 |
+
|
| 408 |
+
def _Normalize(self, text):
|
| 409 |
+
return _sentencepiece.SentencePieceProcessor__Normalize(self, text)
|
| 410 |
+
|
| 411 |
+
def _NormalizeWithOffsets(self, text):
|
| 412 |
+
return _sentencepiece.SentencePieceProcessor__NormalizeWithOffsets(self, text)
|
| 413 |
+
|
| 414 |
+
def _CalculateEntropy(self, text, alpha):
|
| 415 |
+
return _sentencepiece.SentencePieceProcessor__CalculateEntropy(self, text, alpha)
|
| 416 |
+
|
| 417 |
+
def _CalculateEntropyBatch(self, ins, alpha, num_threads):
|
| 418 |
+
return _sentencepiece.SentencePieceProcessor__CalculateEntropyBatch(self, ins, alpha, num_threads)
|
| 419 |
+
|
| 420 |
+
def _OverrideNormalizerSpec(self, args):
|
| 421 |
+
return _sentencepiece.SentencePieceProcessor__OverrideNormalizerSpec(self, args)
|
| 422 |
+
|
| 423 |
+
def Init(self,
|
| 424 |
+
model_file=None,
|
| 425 |
+
model_proto=None,
|
| 426 |
+
out_type=int,
|
| 427 |
+
add_bos=False,
|
| 428 |
+
add_eos=False,
|
| 429 |
+
reverse=False,
|
| 430 |
+
emit_unk_piece=False,
|
| 431 |
+
enable_sampling=False,
|
| 432 |
+
nbest_size=-1,
|
| 433 |
+
alpha=0.1,
|
| 434 |
+
num_threads=-1):
|
| 435 |
+
"""Initialzie sentencepieceProcessor.
|
| 436 |
+
|
| 437 |
+
Args:
|
| 438 |
+
model_file: The sentencepiece model file path.
|
| 439 |
+
model_proto: The sentencepiece model serialized proto.
|
| 440 |
+
out_type: output type. int or str.
|
| 441 |
+
add_bos: Add <s> to the result (Default = false)
|
| 442 |
+
add_eos: Add </s> to the result (Default = false) <s>/</s> is added after
|
| 443 |
+
reversing (if enabled).
|
| 444 |
+
reverse: Reverses the tokenized sequence (Default = false)
|
| 445 |
+
emit_unk_piece: Emits the unk literal string (Default = false)
|
| 446 |
+
nbest_size: sampling parameters for unigram. Invalid in BPE-Dropout.
|
| 447 |
+
nbest_size = {0,1}: No sampling is performed.
|
| 448 |
+
nbest_size > 1: samples from the nbest_size results.
|
| 449 |
+
nbest_size < 0: assuming that nbest_size is infinite and samples
|
| 450 |
+
from the all hypothesis (lattice) using
|
| 451 |
+
forward-filtering-and-backward-sampling algorithm.
|
| 452 |
+
alpha: Soothing parameter for unigram sampling, and dropout probability of
|
| 453 |
+
merge operations for BPE-dropout.
|
| 454 |
+
num_threads: number of threads in batch processing (Default = -1, auto-detected)
|
| 455 |
+
"""
|
| 456 |
+
|
| 457 |
+
_sentencepiece_processor_init_native(self)
|
| 458 |
+
self._out_type = out_type
|
| 459 |
+
self._add_bos = add_bos
|
| 460 |
+
self._add_eos = add_eos
|
| 461 |
+
self._reverse = reverse
|
| 462 |
+
self._emit_unk_piece = emit_unk_piece
|
| 463 |
+
self._enable_sampling = enable_sampling
|
| 464 |
+
self._nbest_size = nbest_size
|
| 465 |
+
self._alpha = alpha
|
| 466 |
+
self._num_threads = num_threads
|
| 467 |
+
if model_file or model_proto:
|
| 468 |
+
self.Load(model_file=model_file, model_proto=model_proto)
|
| 469 |
+
|
| 470 |
+
|
| 471 |
+
def Encode(self,
|
| 472 |
+
input,
|
| 473 |
+
out_type=None,
|
| 474 |
+
add_bos=None,
|
| 475 |
+
add_eos=None,
|
| 476 |
+
reverse=None,
|
| 477 |
+
emit_unk_piece=None,
|
| 478 |
+
enable_sampling=None,
|
| 479 |
+
nbest_size=None,
|
| 480 |
+
alpha=None,
|
| 481 |
+
num_threads=None):
|
| 482 |
+
"""Encode text input to segmented ids or tokens.
|
| 483 |
+
|
| 484 |
+
Args:
|
| 485 |
+
input: input string. accepsts list of string.
|
| 486 |
+
out_type: output type. int or str.
|
| 487 |
+
add_bos: Add <s> to the result (Default = false)
|
| 488 |
+
add_eos: Add </s> to the result (Default = false) <s>/</s> is added after
|
| 489 |
+
reversing (if enabled).
|
| 490 |
+
reverse: Reverses the tokenized sequence (Default = false)
|
| 491 |
+
emit_unk_piece: Emits the unk literal string (Default = false)
|
| 492 |
+
nbest_size: sampling parameters for unigram. Invalid in BPE-Dropout.
|
| 493 |
+
nbest_size = {0,1}: No sampling is performed.
|
| 494 |
+
nbest_size > 1: samples from the nbest_size results.
|
| 495 |
+
nbest_size < 0: assuming that nbest_size is infinite and samples
|
| 496 |
+
from the all hypothesis (lattice) using
|
| 497 |
+
forward-filtering-and-backward-sampling algorithm.
|
| 498 |
+
alpha: Soothing parameter for unigram sampling, and merge probability for
|
| 499 |
+
BPE-dropout (probablity 'p' in BPE-dropout paper).
|
| 500 |
+
num_threads: the number of threads used in the batch processing (Default = -1).
|
| 501 |
+
"""
|
| 502 |
+
|
| 503 |
+
if out_type is None:
|
| 504 |
+
out_type = self._out_type
|
| 505 |
+
if add_bos is None:
|
| 506 |
+
add_bos = self._add_bos
|
| 507 |
+
if add_eos is None:
|
| 508 |
+
add_eos = self._add_eos
|
| 509 |
+
if reverse is None:
|
| 510 |
+
reverse = self._reverse
|
| 511 |
+
if emit_unk_piece is None:
|
| 512 |
+
emit_unk_piece = self._emit_unk_piece
|
| 513 |
+
if enable_sampling is None:
|
| 514 |
+
enable_sampling = self._enable_sampling
|
| 515 |
+
if nbest_size is None:
|
| 516 |
+
nbest_size = self._nbest_size
|
| 517 |
+
if alpha is None:
|
| 518 |
+
alpha = self._alpha
|
| 519 |
+
if num_threads is None:
|
| 520 |
+
num_threads = self._num_threads
|
| 521 |
+
|
| 522 |
+
if enable_sampling == True and (nbest_size is None or nbest_size == 0 or
|
| 523 |
+
nbest_size == 1 or alpha is None):
|
| 524 |
+
raise RuntimeError(
|
| 525 |
+
'When enable_sampling is True, We must specify "nbest_size > 1" or "nbest_size = -1", '
|
| 526 |
+
'and "alpha". "nbest_size" is enabled only on unigram mode ignored in BPE-dropout. '
|
| 527 |
+
'when "nbest_size = -1" , this method samples from all candidates on the lattice '
|
| 528 |
+
'instead of nbest segmentations.'
|
| 529 |
+
)
|
| 530 |
+
|
| 531 |
+
if num_threads is None or type(num_threads) is not int:
|
| 532 |
+
raise RuntimeError('num_threads must be int')
|
| 533 |
+
|
| 534 |
+
if type(input) is list:
|
| 535 |
+
if out_type is int:
|
| 536 |
+
return self._EncodeAsIdsBatch(input, num_threads, enable_sampling, nbest_size,
|
| 537 |
+
alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 538 |
+
if out_type is str:
|
| 539 |
+
return self._EncodeAsPiecesBatch(input, num_threads, enable_sampling, nbest_size,
|
| 540 |
+
alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 541 |
+
if out_type == 'serialized_proto' or out_type == 'proto':
|
| 542 |
+
return self._EncodeAsSerializedProtoBatch(input, num_threads, enable_sampling, nbest_size,
|
| 543 |
+
alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 544 |
+
if out_type == 'immutable_proto':
|
| 545 |
+
return self._EncodeAsImmutableProtoBatch(input, num_threads, enable_sampling, nbest_size,
|
| 546 |
+
alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 547 |
+
|
| 548 |
+
if out_type is int:
|
| 549 |
+
return self._EncodeAsIds(input, enable_sampling, nbest_size,
|
| 550 |
+
alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 551 |
+
if out_type is str:
|
| 552 |
+
return self._EncodeAsPieces(input, enable_sampling, nbest_size,
|
| 553 |
+
alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 554 |
+
if out_type == 'serialized_proto' or out_type == 'proto':
|
| 555 |
+
return self._EncodeAsSerializedProto(input, enable_sampling, nbest_size,
|
| 556 |
+
alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 557 |
+
if out_type == 'immutable_proto':
|
| 558 |
+
return self._EncodeAsImmutableProto(input, enable_sampling, nbest_size,
|
| 559 |
+
alpha, add_bos, add_eos, reverse, emit_unk_piece)
|
| 560 |
+
|
| 561 |
+
raise RuntimeError('unknown out_type={}'.format(out_type))
|
| 562 |
+
return None
|
| 563 |
+
|
| 564 |
+
|
| 565 |
+
def EncodeAsPieces(self, input, **kwargs):
|
| 566 |
+
return self.Encode(input=input, out_type=str, **kwargs)
|
| 567 |
+
|
| 568 |
+
|
| 569 |
+
def EncodeAsIds(self, input, **kwargs):
|
| 570 |
+
return self.Encode(input=input, out_type=int, **kwargs)
|
| 571 |
+
|
| 572 |
+
|
| 573 |
+
def EncodeAsSerializedProto(self, input, **kwargs):
|
| 574 |
+
return self.Encode(input=input, out_type='serialized_proto', **kwargs)
|
| 575 |
+
|
| 576 |
+
|
| 577 |
+
def EncodeAsImmutableProto(self, input, **kwargs):
|
| 578 |
+
return self.Encode(input=input, out_type='immutable_proto', **kwargs)
|
| 579 |
+
|
| 580 |
+
|
| 581 |
+
def SampleEncodeAsPieces(self, input, nbest_size=None, alpha=None, **kwargs):
|
| 582 |
+
return self.Encode(input=input, nbest_size=nbest_size, alpha=alpha,
|
| 583 |
+
out_type=str, enable_sampling=True, **kwargs)
|
| 584 |
+
|
| 585 |
+
|
| 586 |
+
def SampleEncodeAsIds(self, input, nbest_size=None, alpha=None,**kwargs):
|
| 587 |
+
return self.Encode(input=input, nbest_size=nbest_size, alpha=alpha,
|
| 588 |
+
out_type=int, enable_sampling=True, **kwargs)
|
| 589 |
+
|
| 590 |
+
|
| 591 |
+
def SampleEncodeAsSerializedProto(self, input, nbest_size=None, alpha=None, **kwargs):
|
| 592 |
+
return self.Encode(input=input, nbest_size=nbest_size, alpha=alpha,
|
| 593 |
+
out_type='serialized_proto', enable_sampling=True, **kwargs)
|
| 594 |
+
|
| 595 |
+
|
| 596 |
+
def SampleEncodeAsImmutableProto(self, input, nbest_size=None, alpha=None, **kwargs):
|
| 597 |
+
return self.Encode(input=input, nbest_size=nbest_size, alpha=alpha,
|
| 598 |
+
out_type='immutable_proto', enable_sampling=True, **kwargs)
|
| 599 |
+
|
| 600 |
+
|
| 601 |
+
def NBestEncode(self,
|
| 602 |
+
input,
|
| 603 |
+
out_type=None,
|
| 604 |
+
add_bos=None,
|
| 605 |
+
add_eos=None,
|
| 606 |
+
reverse=None,
|
| 607 |
+
emit_unk_piece=None,
|
| 608 |
+
nbest_size=None):
|
| 609 |
+
"""NBestEncode text input to segmented ids or tokens.
|
| 610 |
+
|
| 611 |
+
Args:
|
| 612 |
+
input: input string. accepsts list of string.
|
| 613 |
+
out_type: output type. int or str.
|
| 614 |
+
add_bos: Add <s> to the result (Default = false)
|
| 615 |
+
add_eos: Add </s> to the result (Default = false) <s>/</s> is added after reversing (if enabled).
|
| 616 |
+
reverse: Reverses the tokenized sequence (Default = false)
|
| 617 |
+
emit_unk_piece: Emits the unk literal string (Default = false)
|
| 618 |
+
nbest_size: nbest size
|
| 619 |
+
"""
|
| 620 |
+
|
| 621 |
+
if out_type is None:
|
| 622 |
+
out_type = self._out_type
|
| 623 |
+
if add_bos is None:
|
| 624 |
+
add_bos = self._add_bos
|
| 625 |
+
if add_eos is None:
|
| 626 |
+
add_eos = self._add_eos
|
| 627 |
+
if reverse is None:
|
| 628 |
+
reverse = self._reverse
|
| 629 |
+
if emit_unk_piece is None:
|
| 630 |
+
emit_unk_piece = self._emit_unk_piece
|
| 631 |
+
if nbest_size is None:
|
| 632 |
+
nbest_size = self._nbest_size
|
| 633 |
+
|
| 634 |
+
if nbest_size <= 0:
|
| 635 |
+
nbest_size=1
|
| 636 |
+
|
| 637 |
+
def _encode(text):
|
| 638 |
+
if out_type is int:
|
| 639 |
+
return self._NBestEncodeAsIds(text, nbest_size,
|
| 640 |
+
add_bos, add_eos, reverse, emit_unk_piece)
|
| 641 |
+
if out_type is str:
|
| 642 |
+
return self._NBestEncodeAsPieces(text, nbest_size,
|
| 643 |
+
add_bos, add_eos, reverse, emit_unk_piece)
|
| 644 |
+
if out_type == 'serialized_proto' or out_type == 'proto':
|
| 645 |
+
return self._NBestEncodeAsSerializedProto(text, nbest_size,
|
| 646 |
+
add_bos, add_eos, reverse, emit_unk_piece)
|
| 647 |
+
if out_type == 'immutable_proto':
|
| 648 |
+
return self._NBestEncodeAsImmutableProto(text, nbest_size,
|
| 649 |
+
add_bos, add_eos, reverse, emit_unk_piece)
|
| 650 |
+
|
| 651 |
+
raise RuntimeError('unknown out_type')
|
| 652 |
+
|
| 653 |
+
if type(input) is list:
|
| 654 |
+
return [_encode(n) for n in input]
|
| 655 |
+
|
| 656 |
+
return _encode(input)
|
| 657 |
+
|
| 658 |
+
|
| 659 |
+
def NBestEncodeAsPieces(self, input, nbest_size=None, **kwargs):
|
| 660 |
+
return self.NBestEncode(input=input, nbest_size=nbest_size,
|
| 661 |
+
out_type=str, **kwargs)
|
| 662 |
+
|
| 663 |
+
|
| 664 |
+
def NBestEncodeAsIds(self, input, nbest_size=None, **kwargs):
|
| 665 |
+
return self.NBestEncode(input=input, nbest_size=nbest_size,
|
| 666 |
+
out_type=int, **kwargs)
|
| 667 |
+
|
| 668 |
+
|
| 669 |
+
def NBestEncodeAsSerializedProto(self, input, nbest_size=None, **kwargs):
|
| 670 |
+
return self.NBestEncode(input=input, nbest_size=nbest_size,
|
| 671 |
+
out_type='serialized_proto', **kwargs)
|
| 672 |
+
|
| 673 |
+
|
| 674 |
+
def NBestEncodeAsImmutableProto(self, input, nbest_size=None, **kwargs):
|
| 675 |
+
return self.NBestEncode(input=input, nbest_size=nbest_size,
|
| 676 |
+
out_type='immutable_proto', **kwargs)
|
| 677 |
+
|
| 678 |
+
|
| 679 |
+
def SampleEncodeAndScore(self,
|
| 680 |
+
input,
|
| 681 |
+
out_type=None,
|
| 682 |
+
add_bos=None,
|
| 683 |
+
add_eos=None,
|
| 684 |
+
reverse=None,
|
| 685 |
+
emit_unk_piece=None,
|
| 686 |
+
num_samples=None,
|
| 687 |
+
alpha=None,
|
| 688 |
+
wor=None,
|
| 689 |
+
include_best=None):
|
| 690 |
+
"""SampleEncodeAndScore text input to segmented ids or tokens.
|
| 691 |
+
|
| 692 |
+
Args:
|
| 693 |
+
input: input string. accepsts list of string.
|
| 694 |
+
out_type: output type. int or str or 'serialized_proto' or 'immutable_proto'
|
| 695 |
+
add_bos: Add <s> to the result (Default = false)
|
| 696 |
+
add_eos: Add </s> to the result (Default = false) <s>/</s> is added after reversing (if enabled).
|
| 697 |
+
reverse: Reverses the tokenized sequence (Default = false)
|
| 698 |
+
emit_unk_piece: Emits the unk literal string (Default = false)
|
| 699 |
+
num_samples: How many samples to return (Default = 1)
|
| 700 |
+
alpha: inverse temperature for sampling
|
| 701 |
+
wor: whether to sample without replacement (Default = false)
|
| 702 |
+
include_best: whether to include the best tokenization, requires wor=True (Default = false)
|
| 703 |
+
"""
|
| 704 |
+
|
| 705 |
+
if out_type is None:
|
| 706 |
+
out_type = self._out_type
|
| 707 |
+
if add_bos is None:
|
| 708 |
+
add_bos = self._add_bos
|
| 709 |
+
if add_eos is None:
|
| 710 |
+
add_eos = self._add_eos
|
| 711 |
+
if reverse is None:
|
| 712 |
+
reverse = self._reverse
|
| 713 |
+
if emit_unk_piece is None:
|
| 714 |
+
emit_unk_piece = self._emit_unk_piece
|
| 715 |
+
if num_samples is None:
|
| 716 |
+
num_samples = 1
|
| 717 |
+
if alpha is None:
|
| 718 |
+
alpha = 1.
|
| 719 |
+
if wor is None:
|
| 720 |
+
wor = False
|
| 721 |
+
if include_best is None:
|
| 722 |
+
include_best = False
|
| 723 |
+
|
| 724 |
+
if num_samples <= 0:
|
| 725 |
+
raise RuntimeError('num_examples must be positive')
|
| 726 |
+
|
| 727 |
+
if include_best and not wor:
|
| 728 |
+
raise RuntimeError('When include_best is True, We must specify "wor = True".')
|
| 729 |
+
|
| 730 |
+
|
| 731 |
+
def _encode(text):
|
| 732 |
+
if out_type is int:
|
| 733 |
+
return self._SampleEncodeAndScoreAsIds(text, num_samples, alpha, wor, include_best,
|
| 734 |
+
add_bos, add_eos, reverse, emit_unk_piece)
|
| 735 |
+
if out_type is str:
|
| 736 |
+
return self._SampleEncodeAndScoreAsPieces(text, num_samples, alpha, wor, include_best,
|
| 737 |
+
add_bos, add_eos, reverse, emit_unk_piece)
|
| 738 |
+
|
| 739 |
+
if out_type == 'serialized_proto' or out_type == 'proto':
|
| 740 |
+
return self._SampleEncodeAndScoreAsSerializedProto(text, num_samples, alpha, wor, include_best,
|
| 741 |
+
add_bos, add_eos, reverse, emit_unk_piece)
|
| 742 |
+
|
| 743 |
+
if out_type == 'immutable_proto':
|
| 744 |
+
return self._SampleEncodeAndScoreAsImmutableProto(text, num_samples, alpha, wor, include_best,
|
| 745 |
+
add_bos, add_eos, reverse, emit_unk_piece)
|
| 746 |
+
|
| 747 |
+
raise RuntimeError('unknown output type')
|
| 748 |
+
|
| 749 |
+
|
| 750 |
+
if type(input) is list:
|
| 751 |
+
return [_encode(n) for n in input]
|
| 752 |
+
|
| 753 |
+
return _encode(input)
|
| 754 |
+
|
| 755 |
+
|
| 756 |
+
def SampleEncodeAndScoreAsPieces(self, input, num_samples=None, alpha=None, **kwargs):
|
| 757 |
+
return self.SampleEncodeAndScore(input=input, num_samples=num_samples, alpha=alpha,
|
| 758 |
+
out_type=str, **kwargs)
|
| 759 |
+
|
| 760 |
+
|
| 761 |
+
def SampleEncodeAndScoreAsIds(self, input, num_samples=None, alpha=None, **kwargs):
|
| 762 |
+
return self.SampleEncodeAndScore(input=input, num_samples=num_samples, alpha=alpha,
|
| 763 |
+
out_type=int, **kwargs)
|
| 764 |
+
|
| 765 |
+
|
| 766 |
+
def SampleEncodeAndScoreAsSerializedProto(self, input, num_samples=None, alpha=None, **kwargs):
|
| 767 |
+
return self.SampleEncodeAndScore(input=input, num_samples=num_samples, alpha=alpha,
|
| 768 |
+
out_type='serialized_proto', **kwargs)
|
| 769 |
+
|
| 770 |
+
|
| 771 |
+
def SampleEncodeAndScoreAsImmutableProto(self, input, num_samples=None, alpha=None, **kwargs):
|
| 772 |
+
return self.SampleEncodeAndScore(input=input, num_samples=num_samples, alpha=alpha,
|
| 773 |
+
out_type='immutable_proto', **kwargs)
|
| 774 |
+
|
| 775 |
+
|
| 776 |
+
def Decode(self, input, out_type=str, num_threads=None):
|
| 777 |
+
"""Decode processed id or token sequences.
|
| 778 |
+
|
| 779 |
+
Args:
|
| 780 |
+
out_type: output type. str, bytes or 'serialized_proto' or 'immutable_proto' (Default = str)
|
| 781 |
+
num_threads: the number of threads used in the batch processing (Default = -1).
|
| 782 |
+
"""
|
| 783 |
+
|
| 784 |
+
if num_threads is None:
|
| 785 |
+
num_threads = self._num_threads
|
| 786 |
+
|
| 787 |
+
if num_threads is None or type(num_threads) is not int:
|
| 788 |
+
raise RuntimeError('num_threads must be int')
|
| 789 |
+
|
| 790 |
+
if not input:
|
| 791 |
+
return ''
|
| 792 |
+
|
| 793 |
+
if out_type is str:
|
| 794 |
+
if type(input) is int:
|
| 795 |
+
return self._DecodeIds([input])
|
| 796 |
+
if type(input) is str:
|
| 797 |
+
return self._DecodePieces([input])
|
| 798 |
+
|
| 799 |
+
if type(input) is list:
|
| 800 |
+
if len(input) == 0 or type(input[0]) is int:
|
| 801 |
+
return self._DecodeIds(input)
|
| 802 |
+
if type(input[0]) is str:
|
| 803 |
+
return self._DecodePieces(input)
|
| 804 |
+
|
| 805 |
+
if type(input[0]) is list:
|
| 806 |
+
if len(input[0]) == 0 or type(input[0][0]) is int:
|
| 807 |
+
return self._DecodeIdsBatch(input, num_threads)
|
| 808 |
+
if type(input[0][0]) is str:
|
| 809 |
+
return self._DecodePiecesBatch(input, num_threads)
|
| 810 |
+
|
| 811 |
+
if out_type is bytes:
|
| 812 |
+
if type(input) is int:
|
| 813 |
+
return self._DecodeIdsAsBytes([input])
|
| 814 |
+
if type(input) is str:
|
| 815 |
+
return self._DecodePieces([input])
|
| 816 |
+
|
| 817 |
+
if type(input) is list:
|
| 818 |
+
if len(input) == 0 or type(input[0]) is int:
|
| 819 |
+
return self._DecodeIdsAsBytes(input)
|
| 820 |
+
if type(input[0]) is str:
|
| 821 |
+
return self._DecodePieces(input)
|
| 822 |
+
|
| 823 |
+
if type(input[0]) is list:
|
| 824 |
+
if len(input[0]) == 0 or type(input[0][0]) is int:
|
| 825 |
+
return self._DecodeIdsAsBytesBatch(input, num_threads)
|
| 826 |
+
if type(input[0][0]) is str:
|
| 827 |
+
return self._DecodePiecesBatch(input, num_threads)
|
| 828 |
+
|
| 829 |
+
if out_type == 'serialized_proto':
|
| 830 |
+
if type(input) is int:
|
| 831 |
+
return self._DecodeIdsAsSerializedProto([input])
|
| 832 |
+
if type(input) is str:
|
| 833 |
+
return self._DecodePiecesAsSerializedProto([input])
|
| 834 |
+
|
| 835 |
+
if type(input) is list:
|
| 836 |
+
if len(input) == 0 or type(input[0]) is int:
|
| 837 |
+
return self._DecodeIdsAsSerializedProto(input)
|
| 838 |
+
if type(input[0]) is str:
|
| 839 |
+
return self._DecodePiecesAsSerializedProto(input)
|
| 840 |
+
|
| 841 |
+
if type(input[0]) is list:
|
| 842 |
+
if len(input[0]) == 0 or type(input[0][0]) is int:
|
| 843 |
+
return self._DecodeIdsAsSerializedProtoBatch(input, num_threads)
|
| 844 |
+
if type(input[0][0]) is str:
|
| 845 |
+
return self._DecodePiecesAsSerializedProtoBatch(input, num_threads)
|
| 846 |
+
|
| 847 |
+
|
| 848 |
+
if out_type == 'immutable_proto':
|
| 849 |
+
if type(input) is int:
|
| 850 |
+
return self._DecodeIdsAsImmutableProto([input])
|
| 851 |
+
if type(input) is str:
|
| 852 |
+
return self._DecodePiecesAsImmutableProto([input])
|
| 853 |
+
|
| 854 |
+
if type(input) is list:
|
| 855 |
+
if len(input) == 0 or type(input[0]) is int:
|
| 856 |
+
return self._DecodeIdsAsImmutableProto(input)
|
| 857 |
+
if type(input[0]) is str:
|
| 858 |
+
return self._DecodePiecesAsImmutableProto(input)
|
| 859 |
+
|
| 860 |
+
if type(input[0]) is list:
|
| 861 |
+
if len(input[0]) == 0 or type(input[0][0]) is int:
|
| 862 |
+
return self._DecodeIdsAsImmutableProtoBatch(input, num_threads)
|
| 863 |
+
if type(input[0][0]) is str:
|
| 864 |
+
return self._DecodePiecesAsImmutableProtoBatch(input, num_threads)
|
| 865 |
+
|
| 866 |
+
|
| 867 |
+
raise RuntimeError('unknown output or input type')
|
| 868 |
+
return None
|
| 869 |
+
|
| 870 |
+
|
| 871 |
+
def DecodePieces(self, input, out_type=str, **kwargs):
|
| 872 |
+
return self.Decode(input=input, out_type=out_type, **kwargs)
|
| 873 |
+
|
| 874 |
+
|
| 875 |
+
def DecodeIds(self, input, out_type=str, **kwargs):
|
| 876 |
+
return self.Decode(input=input, out_type=out_type, **kwargs)
|
| 877 |
+
|
| 878 |
+
|
| 879 |
+
def DecodePiecesAsSerializedProto(self, input, out_type='serialized_proto', **kwargs):
|
| 880 |
+
return self.Decode(input=input, out_type=out_type, **kwargs)
|
| 881 |
+
|
| 882 |
+
|
| 883 |
+
def DecodeIdsAsSerializedProto(self, input, out_type='serialized_proto', **kwargs):
|
| 884 |
+
return self.Decode(input=input, out_type=out_type, **kwargs)
|
| 885 |
+
|
| 886 |
+
|
| 887 |
+
def DecodePiecesAsImmutableProto(self, input, out_type='immutable_proto', **kwargs):
|
| 888 |
+
return self.Decode(input=input, out_type=out_type, **kwargs)
|
| 889 |
+
|
| 890 |
+
|
| 891 |
+
def DecodeIdsAsImmutableProto(self, input, out_type='immutable_proto', **kwargs):
|
| 892 |
+
return self.Decode(input=input, out_type=out_type, **kwargs)
|
| 893 |
+
|
| 894 |
+
|
| 895 |
+
def CalculateEntropy(self, input, alpha, num_threads=None):
|
| 896 |
+
"""Calculate sentence entropy"""
|
| 897 |
+
if type(input) is list:
|
| 898 |
+
if num_threads is None:
|
| 899 |
+
num_threads = self._num_threads
|
| 900 |
+
if num_threads is None or type(num_threads) is not int:
|
| 901 |
+
raise RuntimeError('num_threads must be int')
|
| 902 |
+
return self._CalculateEntropyBatch(input, alpha, num_threads)
|
| 903 |
+
|
| 904 |
+
return self._CalculateEntropy(input, alpha)
|
| 905 |
+
|
| 906 |
+
|
| 907 |
+
def Normalize(self, input, with_offsets=None):
|
| 908 |
+
def _normalize(text):
|
| 909 |
+
if with_offsets:
|
| 910 |
+
return self._NormalizeWithOffsets(text)
|
| 911 |
+
return self._Normalize(text)
|
| 912 |
+
|
| 913 |
+
if type(input) is list:
|
| 914 |
+
return [_normalize(x) for x in input]
|
| 915 |
+
return _normalize(input)
|
| 916 |
+
|
| 917 |
+
def OverrideNormalizerSpec(self, **kwargs):
|
| 918 |
+
new_kwargs = {}
|
| 919 |
+
for key, value in kwargs.items():
|
| 920 |
+
new_kwargs[key] = str(value)
|
| 921 |
+
return self._OverrideNormalizerSpec(new_kwargs)
|
| 922 |
+
|
| 923 |
+
|
| 924 |
+
def piece_size(self):
|
| 925 |
+
return self.GetPieceSize()
|
| 926 |
+
|
| 927 |
+
|
| 928 |
+
def vocab_size(self):
|
| 929 |
+
return self.GetPieceSize()
|
| 930 |
+
|
| 931 |
+
|
| 932 |
+
def __getstate__(self):
|
| 933 |
+
return self.serialized_model_proto()
|
| 934 |
+
|
| 935 |
+
|
| 936 |
+
def __setstate__(self, serialized_model_proto):
|
| 937 |
+
self.__init__()
|
| 938 |
+
self.LoadFromSerializedProto(serialized_model_proto)
|
| 939 |
+
|
| 940 |
+
|
| 941 |
+
def __len__(self):
|
| 942 |
+
return self.GetPieceSize()
|
| 943 |
+
|
| 944 |
+
|
| 945 |
+
def __getitem__(self, piece):
|
| 946 |
+
return self.PieceToId(piece)
|
| 947 |
+
|
| 948 |
+
|
| 949 |
+
def Load(self, model_file=None, model_proto=None):
|
| 950 |
+
"""Overwride SentencePieceProcessor.Load to support both model_file and model_proto.
|
| 951 |
+
|
| 952 |
+
Args:
|
| 953 |
+
model_file: The sentencepiece model file path.
|
| 954 |
+
model_proto: The sentencepiece model serialized proto. Either `model_file`
|
| 955 |
+
or `model_proto` must be set.
|
| 956 |
+
"""
|
| 957 |
+
if model_file and model_proto:
|
| 958 |
+
raise RuntimeError('model_file and model_proto must be exclusive.')
|
| 959 |
+
if model_proto:
|
| 960 |
+
return self.LoadFromSerializedProto(model_proto)
|
| 961 |
+
return self.LoadFromFile(model_file)
|
| 962 |
+
|
| 963 |
+
|
| 964 |
+
# Register SentencePieceProcessor in _sentencepiece:
|
| 965 |
+
_sentencepiece.SentencePieceProcessor_swigregister(SentencePieceProcessor)
|
| 966 |
+
|
| 967 |
+
def SetRandomGeneratorSeed(seed):
|
| 968 |
+
return _sentencepiece.SetRandomGeneratorSeed(seed)
|
| 969 |
+
|
| 970 |
+
def SetMinLogLevel(v):
|
| 971 |
+
return _sentencepiece.SetMinLogLevel(v)
|
| 972 |
+
class SentencePieceTrainer(object):
|
| 973 |
+
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
| 974 |
+
|
| 975 |
+
def __init__(self, *args, **kwargs):
|
| 976 |
+
raise AttributeError("No constructor defined")
|
| 977 |
+
__repr__ = _swig_repr
|
| 978 |
+
|
| 979 |
+
@staticmethod
|
| 980 |
+
def _TrainFromString(arg):
|
| 981 |
+
return _sentencepiece.SentencePieceTrainer__TrainFromString(arg)
|
| 982 |
+
|
| 983 |
+
@staticmethod
|
| 984 |
+
def _TrainFromMap(args):
|
| 985 |
+
return _sentencepiece.SentencePieceTrainer__TrainFromMap(args)
|
| 986 |
+
|
| 987 |
+
@staticmethod
|
| 988 |
+
def _TrainFromMap2(args, iter):
|
| 989 |
+
return _sentencepiece.SentencePieceTrainer__TrainFromMap2(args, iter)
|
| 990 |
+
|
| 991 |
+
@staticmethod
|
| 992 |
+
def _TrainFromMap3(args):
|
| 993 |
+
return _sentencepiece.SentencePieceTrainer__TrainFromMap3(args)
|
| 994 |
+
|
| 995 |
+
@staticmethod
|
| 996 |
+
def _TrainFromMap4(args, iter):
|
| 997 |
+
return _sentencepiece.SentencePieceTrainer__TrainFromMap4(args, iter)
|
| 998 |
+
|
| 999 |
+
@staticmethod
|
| 1000 |
+
def _Train(arg=None, **kwargs):
|
| 1001 |
+
"""Train Sentencepiece model. Accept both kwargs and legacy string arg."""
|
| 1002 |
+
if arg is not None and type(arg) is str:
|
| 1003 |
+
return SentencePieceTrainer._TrainFromString(arg)
|
| 1004 |
+
|
| 1005 |
+
def _encode(value):
|
| 1006 |
+
"""Encode value to CSV.."""
|
| 1007 |
+
if type(value) is list:
|
| 1008 |
+
if sys.version_info[0] == 3:
|
| 1009 |
+
f = StringIO()
|
| 1010 |
+
else:
|
| 1011 |
+
f = BytesIO()
|
| 1012 |
+
writer = csv.writer(f, lineterminator='')
|
| 1013 |
+
writer.writerow([str(v) for v in value])
|
| 1014 |
+
return f.getvalue()
|
| 1015 |
+
else:
|
| 1016 |
+
return str(value)
|
| 1017 |
+
|
| 1018 |
+
sentence_iterator = None
|
| 1019 |
+
model_writer = None
|
| 1020 |
+
new_kwargs = {}
|
| 1021 |
+
for key, value in kwargs.items():
|
| 1022 |
+
if key in ['sentence_iterator', 'sentence_reader']:
|
| 1023 |
+
sentence_iterator = value
|
| 1024 |
+
elif key in ['model_writer']:
|
| 1025 |
+
model_writer = value
|
| 1026 |
+
else:
|
| 1027 |
+
new_kwargs[key] = _encode(value)
|
| 1028 |
+
|
| 1029 |
+
if model_writer:
|
| 1030 |
+
if sentence_iterator:
|
| 1031 |
+
model_proto = SentencePieceTrainer._TrainFromMap4(new_kwargs,
|
| 1032 |
+
sentence_iterator)
|
| 1033 |
+
else:
|
| 1034 |
+
model_proto = SentencePieceTrainer._TrainFromMap3(new_kwargs)
|
| 1035 |
+
model_writer.write(model_proto)
|
| 1036 |
+
else:
|
| 1037 |
+
if sentence_iterator:
|
| 1038 |
+
return SentencePieceTrainer._TrainFromMap2(new_kwargs, sentence_iterator)
|
| 1039 |
+
else:
|
| 1040 |
+
return SentencePieceTrainer._TrainFromMap(new_kwargs)
|
| 1041 |
+
|
| 1042 |
+
return None
|
| 1043 |
+
|
| 1044 |
+
@staticmethod
|
| 1045 |
+
def Train(arg=None, logstream=None, **kwargs):
|
| 1046 |
+
with _LogStream(ostream=logstream):
|
| 1047 |
+
SentencePieceTrainer._Train(arg=arg, **kwargs)
|
| 1048 |
+
|
| 1049 |
+
|
| 1050 |
+
# Register SentencePieceTrainer in _sentencepiece:
|
| 1051 |
+
_sentencepiece.SentencePieceTrainer_swigregister(SentencePieceTrainer)
|
| 1052 |
+
class SentencePieceNormalizer(object):
|
| 1053 |
+
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
| 1054 |
+
__repr__ = _swig_repr
|
| 1055 |
+
|
| 1056 |
+
def __init__(self):
|
| 1057 |
+
_sentencepiece.SentencePieceNormalizer_swiginit(self, _sentencepiece.new_SentencePieceNormalizer())
|
| 1058 |
+
__swig_destroy__ = _sentencepiece.delete_SentencePieceNormalizer
|
| 1059 |
+
|
| 1060 |
+
def LoadFromSerializedProto(self, serialized):
|
| 1061 |
+
return _sentencepiece.SentencePieceNormalizer_LoadFromSerializedProto(self, serialized)
|
| 1062 |
+
|
| 1063 |
+
def LoadFromRuleTSV(self, filename):
|
| 1064 |
+
return _sentencepiece.SentencePieceNormalizer_LoadFromRuleTSV(self, filename)
|
| 1065 |
+
|
| 1066 |
+
def LoadFromRuleName(self, name):
|
| 1067 |
+
return _sentencepiece.SentencePieceNormalizer_LoadFromRuleName(self, name)
|
| 1068 |
+
|
| 1069 |
+
def serialized_model_proto(self):
|
| 1070 |
+
return _sentencepiece.SentencePieceNormalizer_serialized_model_proto(self)
|
| 1071 |
+
|
| 1072 |
+
def LoadFromFile(self, arg):
|
| 1073 |
+
return _sentencepiece.SentencePieceNormalizer_LoadFromFile(self, arg)
|
| 1074 |
+
|
| 1075 |
+
def _Normalize(self, text):
|
| 1076 |
+
return _sentencepiece.SentencePieceNormalizer__Normalize(self, text)
|
| 1077 |
+
|
| 1078 |
+
def _NormalizeWithOffsets(self, text):
|
| 1079 |
+
return _sentencepiece.SentencePieceNormalizer__NormalizeWithOffsets(self, text)
|
| 1080 |
+
|
| 1081 |
+
def _SetProtoField(self, name, value):
|
| 1082 |
+
return _sentencepiece.SentencePieceNormalizer__SetProtoField(self, name, value)
|
| 1083 |
+
|
| 1084 |
+
def Init(self,
|
| 1085 |
+
model_file=None,
|
| 1086 |
+
model_proto=None,
|
| 1087 |
+
rule_tsv=None,
|
| 1088 |
+
rule_name=None,
|
| 1089 |
+
add_dummy_prefix=False,
|
| 1090 |
+
escape_whitespaces=False,
|
| 1091 |
+
remove_extra_whitespaces=False):
|
| 1092 |
+
"""Initialzie sentencePieceNormalizer.
|
| 1093 |
+
|
| 1094 |
+
Args:
|
| 1095 |
+
model_file: The sentencepiece model file path.
|
| 1096 |
+
model_proto: The sentencepiece model serialized proto.
|
| 1097 |
+
rule_tsv: The normalization rule file in TSV format.
|
| 1098 |
+
rule_name: Pre-defined normalization name.
|
| 1099 |
+
add_dummy_prefix: add dummy prefix.
|
| 1100 |
+
escape_whitespaces: escape whitespaces.
|
| 1101 |
+
remove_extra_whitespaces: remove extra whitespaces.
|
| 1102 |
+
"""
|
| 1103 |
+
|
| 1104 |
+
_sentencepiece_normalizer_init_native(self)
|
| 1105 |
+
|
| 1106 |
+
if model_file:
|
| 1107 |
+
status = self.LoadFromFile(model_file)
|
| 1108 |
+
elif model_proto:
|
| 1109 |
+
status = self.LoadFromSerializedProto(model_proto)
|
| 1110 |
+
elif rule_tsv:
|
| 1111 |
+
status = self.LoadFromRuleTSV(rule_tsv)
|
| 1112 |
+
elif rule_name:
|
| 1113 |
+
status = self.LoadFromRuleName(rule_name)
|
| 1114 |
+
else:
|
| 1115 |
+
raise RuntimeError('no model is specified')
|
| 1116 |
+
|
| 1117 |
+
if status:
|
| 1118 |
+
self._SetProtoField('add_dummy_prefix', add_dummy_prefix)
|
| 1119 |
+
self._SetProtoField('escape_whitespaces', escape_whitespaces)
|
| 1120 |
+
self._SetProtoField('remove_extra_whitespaces', remove_extra_whitespaces)
|
| 1121 |
+
|
| 1122 |
+
def Normalize(self, input, with_offsets=None):
|
| 1123 |
+
def _normalize(text):
|
| 1124 |
+
if with_offsets:
|
| 1125 |
+
return self._NormalizeWithOffsets(text)
|
| 1126 |
+
return self._Normalize(text)
|
| 1127 |
+
|
| 1128 |
+
if type(input) is list:
|
| 1129 |
+
return [_normalize(x) for x in input]
|
| 1130 |
+
return _normalize(input)
|
| 1131 |
+
|
| 1132 |
+
|
| 1133 |
+
def __getstate__(self):
|
| 1134 |
+
return self.serialized_model_proto()
|
| 1135 |
+
|
| 1136 |
+
|
| 1137 |
+
def __setstate__(self, serialized_model_proto):
|
| 1138 |
+
self.__init__()
|
| 1139 |
+
self.LoadFromSerializedProto(serialized_model_proto)
|
| 1140 |
+
|
| 1141 |
+
|
| 1142 |
+
# Register SentencePieceNormalizer in _sentencepiece:
|
| 1143 |
+
_sentencepiece.SentencePieceNormalizer_swigregister(SentencePieceNormalizer)
|
| 1144 |
+
|
| 1145 |
+
|
| 1146 |
+
import re
|
| 1147 |
+
import csv
|
| 1148 |
+
import sys
|
| 1149 |
+
import os
|
| 1150 |
+
from io import StringIO
|
| 1151 |
+
from io import BytesIO
|
| 1152 |
+
|
| 1153 |
+
|
| 1154 |
+
def _add_snake_case(classname):
|
| 1155 |
+
"""Added snake_cased method from CammelCased method."""
|
| 1156 |
+
|
| 1157 |
+
snake_map = {}
|
| 1158 |
+
for k, v in classname.__dict__.items():
|
| 1159 |
+
if re.match(r'^[A-Z]+', k):
|
| 1160 |
+
snake = re.sub(r'(?<!^)(?=[A-Z])', '_',
|
| 1161 |
+
k).lower().replace('n_best', 'nbest')
|
| 1162 |
+
snake_map[snake] = v
|
| 1163 |
+
for k, v in snake_map.items():
|
| 1164 |
+
setattr(classname, k, v)
|
| 1165 |
+
|
| 1166 |
+
|
| 1167 |
+
def _batchnize(classname, name):
|
| 1168 |
+
"""Enables batch request for the method classname.name."""
|
| 1169 |
+
func = getattr(classname, name, None)
|
| 1170 |
+
def _func(v, n):
|
| 1171 |
+
if type(n) is int and (n < 0 or n >= v.piece_size()):
|
| 1172 |
+
raise IndexError('piece id is out of range.')
|
| 1173 |
+
return func(v, n)
|
| 1174 |
+
|
| 1175 |
+
def _batched_func(self, arg):
|
| 1176 |
+
if type(arg) is list:
|
| 1177 |
+
return [_func(self, n) for n in arg]
|
| 1178 |
+
else:
|
| 1179 |
+
return _func(self, arg)
|
| 1180 |
+
|
| 1181 |
+
setattr(classname, name, _batched_func)
|
| 1182 |
+
|
| 1183 |
+
|
| 1184 |
+
_sentencepiece_processor_init_native = SentencePieceProcessor.__init__
|
| 1185 |
+
_sentencepiece_normalizer_init_native = SentencePieceNormalizer.__init__
|
| 1186 |
+
setattr(SentencePieceProcessor, '__init__', SentencePieceProcessor.Init)
|
| 1187 |
+
setattr(SentencePieceNormalizer, '__init__', SentencePieceNormalizer.Init)
|
| 1188 |
+
|
| 1189 |
+
SentencePieceProcessor.Tokenize = SentencePieceProcessor.Encode
|
| 1190 |
+
SentencePieceProcessor.Detokenize = SentencePieceProcessor.Decode
|
| 1191 |
+
|
| 1192 |
+
for m in [
|
| 1193 |
+
'PieceToId', 'IdToPiece', 'GetScore', 'IsUnknown', 'IsControl', 'IsUnused',
|
| 1194 |
+
'IsByte'
|
| 1195 |
+
]:
|
| 1196 |
+
_batchnize(SentencePieceProcessor, m)
|
| 1197 |
+
|
| 1198 |
+
_add_snake_case(SentencePieceProcessor)
|
| 1199 |
+
_add_snake_case(SentencePieceTrainer)
|
| 1200 |
+
_add_snake_case(SentencePieceNormalizer)
|
| 1201 |
+
set_random_generator_seed = SetRandomGeneratorSeed
|
| 1202 |
+
set_min_log_level = SetMinLogLevel
|
| 1203 |
+
|
| 1204 |
+
from ._version import __version__
|
| 1205 |
+
|
| 1206 |
+
class _LogStream(object):
|
| 1207 |
+
def __init__(self, ostream=None):
|
| 1208 |
+
self.ostream = ostream
|
| 1209 |
+
if self.ostream is not None:
|
| 1210 |
+
self.orig_stream_fileno = sys.stderr.fileno()
|
| 1211 |
+
|
| 1212 |
+
def __enter__(self):
|
| 1213 |
+
if self.ostream is not None:
|
| 1214 |
+
self.orig_stream_dup = os.dup(self.orig_stream_fileno)
|
| 1215 |
+
os.dup2(self.ostream.fileno(), self.orig_stream_fileno)
|
| 1216 |
+
|
| 1217 |
+
def __exit__(self, type, value, traceback):
|
| 1218 |
+
if self.ostream is not None:
|
| 1219 |
+
os.close(self.orig_stream_fileno)
|
| 1220 |
+
os.dup2(self.orig_stream_dup, self.orig_stream_fileno)
|
| 1221 |
+
os.close(self.orig_stream_dup)
|
| 1222 |
+
self.ostream.close()
|
| 1223 |
+
|
| 1224 |
+
|
.venv/lib/python3.11/site-packages/sentencepiece/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (79.8 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/sentencepiece/__pycache__/_version.cpython-311.pyc
ADDED
|
Binary file (206 Bytes). View file
|
|
|