Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/ai2_olmo_core-2.4.0.dist-info/licenses/LICENSE +201 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/examples/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/examples/__pycache__/basic_example.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/__init__.py +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/aot_autograd/__init__.py +8 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/aot_autograd/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/eager_transforms/__init__.py +7 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/eager_transforms/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/make_functional/__init__.py +4 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/make_functional/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/vmap/__init__.py +16 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/vmap/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/compile/__init__.py +30 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/compile/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__init__.py +177 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/batch_tensor.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/delayed_mul_tensor.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/dim.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/magic_trace.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/op_properties.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/reference.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/tree_map.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/wrap_type.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/batch_tensor.py +26 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/delayed_mul_tensor.py +76 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/dim.py +120 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/magic_trace.py +42 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/op_properties.py +312 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/reference.py +645 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/tree_map.py +15 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/wrap_type.py +72 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/einops/__init__.py +4 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/einops/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/einops/__pycache__/_parsing.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/einops/__pycache__/rearrange.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/einops/_parsing.py +308 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/einops/rearrange.py +211 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/experimental/__init__.py +5 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/experimental/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/experimental/__pycache__/control_flow.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/experimental/__pycache__/ops.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/experimental/control_flow.py +6 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/experimental/ops.py +1 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/olmes_docker-0.1.0.dist-info/licenses/LICENSE +201 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/olmo_core/__pycache__/__init__.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/olmo_core/__pycache__/aliases.cpython-310.pyc +0 -0
- data/tefig/envs/olmes-eval/lib/python3.10/site-packages/olmo_core/__pycache__/config.cpython-310.pyc +0 -0
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/ai2_olmo_core-2.4.0.dist-info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
https://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 |
+
https://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.
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/examples/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (182 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/examples/__pycache__/basic_example.cpython-310.pyc
ADDED
|
Binary file (2.18 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (693 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/__init__.py
ADDED
|
File without changes
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (188 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/aot_autograd/__init__.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file has moved to under torch/_functorch. It is not public API.
|
| 2 |
+
# If you are not a PyTorch developer and you are relying on the following
|
| 3 |
+
# imports, please file an issue.
|
| 4 |
+
from torch._functorch.aot_autograd import (
|
| 5 |
+
aot_autograd_decompositions,
|
| 6 |
+
KNOWN_TYPES,
|
| 7 |
+
PytreeThunk,
|
| 8 |
+
)
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/aot_autograd/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (326 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/eager_transforms/__init__.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file has moved to under torch/_functorch. It is not public API.
|
| 2 |
+
# If you are not a PyTorch developer and you are relying on the following
|
| 3 |
+
# imports, please file an issue.
|
| 4 |
+
from torch._functorch.eager_transforms import (
|
| 5 |
+
_assert_wrapped_functional,
|
| 6 |
+
_unwrap_functional_tensor,
|
| 7 |
+
)
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/eager_transforms/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (325 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/make_functional/__init__.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file has moved to under torch/_functorch. It is not public API.
|
| 2 |
+
# If you are not a PyTorch developer and you are relying on the following
|
| 3 |
+
# imports, please file an issue.
|
| 4 |
+
from torch._functorch.make_functional import _swap_state
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/make_functional/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (272 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/vmap/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file has moved to under torch/_functorch. It is not public API.
|
| 2 |
+
# If you are not a PyTorch developer and you are relying on the following
|
| 3 |
+
# imports, please file an issue.
|
| 4 |
+
from torch._functorch.vmap import (
|
| 5 |
+
_add_batch_dim,
|
| 6 |
+
_broadcast_to_and_flatten,
|
| 7 |
+
_create_batched_inputs,
|
| 8 |
+
_get_name,
|
| 9 |
+
_process_batched_inputs,
|
| 10 |
+
_remove_batch_dim,
|
| 11 |
+
_unwrap_batched,
|
| 12 |
+
_validate_and_get_batch_size,
|
| 13 |
+
Tensor,
|
| 14 |
+
tree_flatten,
|
| 15 |
+
tree_unflatten,
|
| 16 |
+
)
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/_src/vmap/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (534 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/compile/__init__.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from torch._functorch import config
|
| 2 |
+
from torch._functorch.aot_autograd import (
|
| 3 |
+
aot_function,
|
| 4 |
+
aot_module,
|
| 5 |
+
aot_module_simplified,
|
| 6 |
+
compiled_function,
|
| 7 |
+
compiled_module,
|
| 8 |
+
get_aot_compilation_context,
|
| 9 |
+
get_aot_graph_name,
|
| 10 |
+
get_graph_being_compiled,
|
| 11 |
+
make_boxed_compiler,
|
| 12 |
+
make_boxed_func,
|
| 13 |
+
)
|
| 14 |
+
from torch._functorch.compilers import (
|
| 15 |
+
debug_compile,
|
| 16 |
+
default_decompositions,
|
| 17 |
+
draw_graph_compile,
|
| 18 |
+
memory_efficient_fusion,
|
| 19 |
+
nnc_jit,
|
| 20 |
+
nop,
|
| 21 |
+
print_compile,
|
| 22 |
+
ts_compile,
|
| 23 |
+
)
|
| 24 |
+
from torch._functorch.fx_minifier import minifier
|
| 25 |
+
from torch._functorch.partitioners import (
|
| 26 |
+
default_partition,
|
| 27 |
+
draw_graph,
|
| 28 |
+
min_cut_rematerialization_partition,
|
| 29 |
+
)
|
| 30 |
+
from torch._functorch.python_key import pythonkey_decompose
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/compile/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (1.08 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__init__.py
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import functorch._C
|
| 2 |
+
import torch
|
| 3 |
+
from functorch._C import dim as _C
|
| 4 |
+
|
| 5 |
+
from .tree_map import tree_flatten, tree_map
|
| 6 |
+
from .wrap_type import wrap_type
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
_C._patch_tensor_class()
|
| 10 |
+
dims, DimList, dimlists = _C.dims, _C.DimList, _C.dimlists
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class DimensionMismatchError(Exception):
|
| 14 |
+
pass
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class DimensionBindError(Exception):
|
| 18 |
+
pass
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
from . import op_properties
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
# use dict to avoid writing C++ bindings for set
|
| 25 |
+
pointwise = dict.fromkeys(op_properties.pointwise, True)
|
| 26 |
+
|
| 27 |
+
use_c = True
|
| 28 |
+
if not use_c:
|
| 29 |
+
from . import reference
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
class _Tensor:
|
| 33 |
+
# fast path around slow wrapping/unwrapping logic for simply queries used
|
| 34 |
+
# by the implementation...
|
| 35 |
+
|
| 36 |
+
@property
|
| 37 |
+
def dims(self):
|
| 38 |
+
return tuple(d for d in self._levels if isinstance(d, Dim))
|
| 39 |
+
|
| 40 |
+
def dim(self):
|
| 41 |
+
return self.ndim
|
| 42 |
+
|
| 43 |
+
if use_c:
|
| 44 |
+
__torch_function__ = classmethod(_C.__torch_function__)
|
| 45 |
+
expand = _C._instancemethod(_C.expand)
|
| 46 |
+
else:
|
| 47 |
+
__torch_function__ = reference.__torch_function__
|
| 48 |
+
expand = reference.expand
|
| 49 |
+
|
| 50 |
+
index = _C._instancemethod(_C.index)
|
| 51 |
+
|
| 52 |
+
def __repr__(self):
|
| 53 |
+
tensor, levels, ndim = self._tensor, self._levels, self.ndim
|
| 54 |
+
return f"{tensor}\nwith dims={tuple(l + ndim if isinstance(l, int) else l for l in levels)} sizes={tuple(tensor.size())}"
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
TensorLike = (_Tensor, torch.Tensor)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
class Dim(_C.Dim, _Tensor):
|
| 61 |
+
# note that _C.Dim comes before tensor because we want the Dim API for things like size to take precedence.
|
| 62 |
+
# Tensor defines format, but we want to print Dims with special formatting
|
| 63 |
+
__format__ = object.__format__
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
class Tensor(_Tensor, _C.Tensor):
|
| 67 |
+
if not use_c:
|
| 68 |
+
from_batched = staticmethod(_C.Tensor_from_batched)
|
| 69 |
+
from_positional = staticmethod(_C.Tensor_from_positional)
|
| 70 |
+
sum = _C._instancemethod(_C.Tensor_sum)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def cat(tensors, dim, new_dim):
|
| 74 |
+
n = dims()
|
| 75 |
+
return stack(tensors, n, dim).index([n, dim], new_dim)
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
if use_c:
|
| 79 |
+
_wrap = _C._wrap
|
| 80 |
+
|
| 81 |
+
def _def(name, *args, **kwargs):
|
| 82 |
+
orig = getattr(torch.Tensor, name)
|
| 83 |
+
setattr(_Tensor, name, _C._instancemethod(_wrap(orig, *args, **kwargs)))
|
| 84 |
+
|
| 85 |
+
t__getitem__ = _C._instancemethod(_C.__getitem__)
|
| 86 |
+
stack = _C.stack
|
| 87 |
+
split = _C._instancemethod(_C.split)
|
| 88 |
+
else:
|
| 89 |
+
_wrap, _def = reference._wrap, reference._def
|
| 90 |
+
t__getitem__ = reference.t__getitem__
|
| 91 |
+
stack = reference.stack
|
| 92 |
+
split = reference.split
|
| 93 |
+
|
| 94 |
+
# note: there is no python reference
|
| 95 |
+
t__setitem__ = _C._instancemethod(_C.__setitem__)
|
| 96 |
+
# this is patched in the C API because otherwise torch.Tensor will
|
| 97 |
+
# no longer be considered a sequence and things will break
|
| 98 |
+
# torch.Tensor.__getitem__ = t__getitem__
|
| 99 |
+
|
| 100 |
+
_Tensor.__getitem__ = t__getitem__
|
| 101 |
+
# torch.Tensor.__setitem__ = t__setitem__
|
| 102 |
+
_Tensor.__setitem__ = t__setitem__
|
| 103 |
+
|
| 104 |
+
torch.Tensor.split = split
|
| 105 |
+
_Tensor.split = split
|
| 106 |
+
torch.Tensor.expand = _C._instancemethod(_C.expand)
|
| 107 |
+
torch.Tensor.index = _C._instancemethod(_C.index)
|
| 108 |
+
wrap_type(use_c, _Tensor, torch.Tensor, _Tensor.__torch_function__)
|
| 109 |
+
del _Tensor.ndim
|
| 110 |
+
|
| 111 |
+
if use_c:
|
| 112 |
+
_Tensor.order = _C._instancemethod(_C.order)
|
| 113 |
+
else:
|
| 114 |
+
_Tensor.order = reference.positional
|
| 115 |
+
|
| 116 |
+
_def("mean")
|
| 117 |
+
_def("sum")
|
| 118 |
+
_def("all")
|
| 119 |
+
_def("amax")
|
| 120 |
+
_def("amin")
|
| 121 |
+
_def("aminmax")
|
| 122 |
+
_def("any")
|
| 123 |
+
_def("count_nonzero")
|
| 124 |
+
_def("logsumexp")
|
| 125 |
+
_def("nanmean")
|
| 126 |
+
_def("nansum")
|
| 127 |
+
_def("prod")
|
| 128 |
+
_def("std", keepdim_offset=2)
|
| 129 |
+
_def("var", keepdim_offset=2)
|
| 130 |
+
_def("max", single_dim=True)
|
| 131 |
+
_def("min", single_dim=True)
|
| 132 |
+
_def("argmax", single_dim=True)
|
| 133 |
+
_def("argmin", single_dim=True)
|
| 134 |
+
_def("kthvalue", single_dim=True)
|
| 135 |
+
_def("median", single_dim=True)
|
| 136 |
+
_def("nanmedian", single_dim=True)
|
| 137 |
+
_def("mode", single_dim=True)
|
| 138 |
+
_def("sort", reduce=False)
|
| 139 |
+
_def("argsort", reduce=False)
|
| 140 |
+
_def("unbind", single_dim=True)
|
| 141 |
+
_def("chunk", dim_offset=1, reduce=False)
|
| 142 |
+
_def("cummax", single_dim=True, reduce=False)
|
| 143 |
+
_def("cummin", single_dim=True, reduce=False)
|
| 144 |
+
_def("cumprod", single_dim=True, reduce=False)
|
| 145 |
+
_def("cumprod_", single_dim=True, reduce=False)
|
| 146 |
+
_def("cumsum", single_dim=True, reduce=False)
|
| 147 |
+
_def("cumsum_", single_dim=True, reduce=False)
|
| 148 |
+
_def("logcumsumexp", single_dim=True, reduce=False)
|
| 149 |
+
_def("renorm", dim_offset=1, single_dim=True, reduce=False)
|
| 150 |
+
_def("softmax", single_dim=True, reduce=False)
|
| 151 |
+
softmax = _wrap(torch.nn.functional.softmax, single_dim=True, reduce=False)
|
| 152 |
+
|
| 153 |
+
# stuff to handle in the future, because they require special
|
| 154 |
+
# binding logic for dims
|
| 155 |
+
# cross
|
| 156 |
+
# diag_embed
|
| 157 |
+
# diagonal
|
| 158 |
+
# diagonal_scatter
|
| 159 |
+
# diff
|
| 160 |
+
# nanquantile
|
| 161 |
+
# quantile
|
| 162 |
+
# roll
|
| 163 |
+
# rot90
|
| 164 |
+
# topk (new dimes on output)
|
| 165 |
+
# should these all be subsumed by inplace indexing?
|
| 166 |
+
# index_add_
|
| 167 |
+
# index_add
|
| 168 |
+
# index_copy
|
| 169 |
+
# index_copy_
|
| 170 |
+
# index_fill
|
| 171 |
+
# index_fill_
|
| 172 |
+
# index_select
|
| 173 |
+
# scatter
|
| 174 |
+
# scatter_
|
| 175 |
+
# scatter_add
|
| 176 |
+
# scatter_add_
|
| 177 |
+
# scatter_reduce
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (4.11 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/batch_tensor.cpython-310.pyc
ADDED
|
Binary file (795 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/delayed_mul_tensor.cpython-310.pyc
ADDED
|
Binary file (3.05 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/dim.cpython-310.pyc
ADDED
|
Binary file (4.13 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/magic_trace.cpython-310.pyc
ADDED
|
Binary file (1.21 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/op_properties.cpython-310.pyc
ADDED
|
Binary file (5.64 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/reference.cpython-310.pyc
ADDED
|
Binary file (16.1 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/tree_map.cpython-310.pyc
ADDED
|
Binary file (549 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/__pycache__/wrap_type.cpython-310.pyc
ADDED
|
Binary file (1.51 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/batch_tensor.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
# All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This source code is licensed under the BSD-style license found in the
|
| 5 |
+
# LICENSE file in the root directory of this source tree.
|
| 6 |
+
from contextlib import contextmanager
|
| 7 |
+
|
| 8 |
+
from torch._C._functorch import _vmap_add_layers, _vmap_remove_layers
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
_enabled = False
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
@contextmanager
|
| 15 |
+
def _enable_layers(dims):
|
| 16 |
+
global _enabled
|
| 17 |
+
assert not _enabled
|
| 18 |
+
input = sorted((d._level, d.size) for d in dims if not isinstance(d, int))
|
| 19 |
+
n = len(input)
|
| 20 |
+
try:
|
| 21 |
+
_vmap_add_layers(input)
|
| 22 |
+
_enabled = True
|
| 23 |
+
yield
|
| 24 |
+
finally:
|
| 25 |
+
_enabled = False
|
| 26 |
+
_vmap_remove_layers(n)
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/delayed_mul_tensor.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
# All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This source code is licensed under the BSD-style license found in the
|
| 5 |
+
# LICENSE file in the root directory of this source tree.
|
| 6 |
+
import torch
|
| 7 |
+
|
| 8 |
+
from . import _Tensor, Tensor
|
| 9 |
+
from .reference import _dims, _enable_layers, llist, ltuple
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class DelayedMulTensor(_Tensor):
|
| 13 |
+
def __init__(self, lhs, rhs):
|
| 14 |
+
self._lhs, self._rhs = lhs, rhs
|
| 15 |
+
self._data = None
|
| 16 |
+
self._levels_data = None
|
| 17 |
+
self._has_device = lhs._has_device or rhs._has_device
|
| 18 |
+
self._batchtensor_data = None
|
| 19 |
+
self._tensor_data = None
|
| 20 |
+
|
| 21 |
+
@property
|
| 22 |
+
def _levels(self):
|
| 23 |
+
if self._levels_data is None:
|
| 24 |
+
levels = llist(self._lhs._levels)
|
| 25 |
+
for l in self._rhs._levels:
|
| 26 |
+
if l not in levels:
|
| 27 |
+
levels.append(l)
|
| 28 |
+
self._levels_data = ltuple(levels)
|
| 29 |
+
return self._levels_data
|
| 30 |
+
|
| 31 |
+
@property
|
| 32 |
+
def _batchtensor(self):
|
| 33 |
+
if self._batchtensor_data is None:
|
| 34 |
+
with _enable_layers(self._levels):
|
| 35 |
+
print("bt multiply fallback")
|
| 36 |
+
self._batchtensor_data = self._lhs._batchtensor * self._rhs._batchtensor
|
| 37 |
+
return self._batchtensor_data
|
| 38 |
+
|
| 39 |
+
@property
|
| 40 |
+
def _tensor(self):
|
| 41 |
+
if self._tensor_data is None:
|
| 42 |
+
self._tensor_data = Tensor.from_batched(
|
| 43 |
+
self._batchtensor, self._has_device
|
| 44 |
+
)._tensor
|
| 45 |
+
return self._tensor_data
|
| 46 |
+
|
| 47 |
+
@property
|
| 48 |
+
def ndim(self):
|
| 49 |
+
return self._batchtensor.ndim
|
| 50 |
+
|
| 51 |
+
@property
|
| 52 |
+
def dims(self):
|
| 53 |
+
return ltuple(super().dims)
|
| 54 |
+
|
| 55 |
+
def sum(self, dim):
|
| 56 |
+
dims = _dims(dim, 0, False, False)
|
| 57 |
+
n = ord("a")
|
| 58 |
+
all_levels = self._levels
|
| 59 |
+
|
| 60 |
+
def to_char(d):
|
| 61 |
+
return chr(n + all_levels.index(d))
|
| 62 |
+
|
| 63 |
+
plhs, levelslhs = self._lhs._tensor, self._lhs._levels
|
| 64 |
+
prhs, levelsrhs = self._rhs._tensor, self._rhs._levels
|
| 65 |
+
new_levels = [l for l in self._levels if l not in dims]
|
| 66 |
+
fmt = "".join(
|
| 67 |
+
[
|
| 68 |
+
*(to_char(d) for d in levelslhs),
|
| 69 |
+
",",
|
| 70 |
+
*(to_char(d) for d in levelsrhs),
|
| 71 |
+
"->",
|
| 72 |
+
*(to_char(d) for d in new_levels),
|
| 73 |
+
]
|
| 74 |
+
)
|
| 75 |
+
result_data = torch.einsum(fmt, (plhs, prhs))
|
| 76 |
+
return Tensor.from_positional(result_data, new_levels, True)
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/dim.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
# All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This source code is licensed under the BSD-style license found in the
|
| 5 |
+
# LICENSE file in the root directory of this source tree.
|
| 6 |
+
import dis
|
| 7 |
+
import inspect
|
| 8 |
+
from dataclasses import dataclass
|
| 9 |
+
from typing import Union
|
| 10 |
+
|
| 11 |
+
from . import DimList
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
_vmap_levels = []
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
@dataclass
|
| 18 |
+
class LevelInfo:
|
| 19 |
+
level: int
|
| 20 |
+
alive: bool = True
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class Dim:
|
| 24 |
+
def __init__(self, name: str, size: Union[None, int] = None):
|
| 25 |
+
self.name = name
|
| 26 |
+
self._size = None
|
| 27 |
+
self._vmap_level = None
|
| 28 |
+
if size is not None:
|
| 29 |
+
self.size = size
|
| 30 |
+
|
| 31 |
+
def __del__(self):
|
| 32 |
+
if self._vmap_level is not None:
|
| 33 |
+
_vmap_active_levels[self._vmap_stack].alive = False # noqa: F821
|
| 34 |
+
while (
|
| 35 |
+
not _vmap_levels[-1].alive and current_level() == _vmap_levels[-1].level # noqa: F821
|
| 36 |
+
):
|
| 37 |
+
_vmap_decrement_nesting() # noqa: F821
|
| 38 |
+
_vmap_levels.pop()
|
| 39 |
+
|
| 40 |
+
@property
|
| 41 |
+
def size(self):
|
| 42 |
+
assert self.is_bound
|
| 43 |
+
return self._size
|
| 44 |
+
|
| 45 |
+
@size.setter
|
| 46 |
+
def size(self, size: int):
|
| 47 |
+
from . import DimensionBindError
|
| 48 |
+
|
| 49 |
+
if self._size is None:
|
| 50 |
+
self._size = size
|
| 51 |
+
self._vmap_level = _vmap_increment_nesting(size, "same") # noqa: F821
|
| 52 |
+
self._vmap_stack = len(_vmap_levels)
|
| 53 |
+
_vmap_levels.append(LevelInfo(self._vmap_level))
|
| 54 |
+
|
| 55 |
+
elif self._size != size:
|
| 56 |
+
raise DimensionBindError(
|
| 57 |
+
f"Dim '{self}' previously bound to a dimension of size {self._size} cannot bind to a dimension of size {size}"
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
@property
|
| 61 |
+
def is_bound(self):
|
| 62 |
+
return self._size is not None
|
| 63 |
+
|
| 64 |
+
def __repr__(self):
|
| 65 |
+
return self.name
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def extract_name(inst):
|
| 69 |
+
assert inst.opname == "STORE_FAST" or inst.opname == "STORE_NAME"
|
| 70 |
+
return inst.argval
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
_cache = {}
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def dims(lists=0):
|
| 77 |
+
frame = inspect.currentframe()
|
| 78 |
+
assert frame is not None
|
| 79 |
+
calling_frame = frame.f_back
|
| 80 |
+
assert calling_frame is not None
|
| 81 |
+
code, lasti = calling_frame.f_code, calling_frame.f_lasti
|
| 82 |
+
key = (code, lasti)
|
| 83 |
+
if key not in _cache:
|
| 84 |
+
first = lasti // 2 + 1
|
| 85 |
+
instructions = list(dis.get_instructions(calling_frame.f_code))
|
| 86 |
+
unpack = instructions[first]
|
| 87 |
+
|
| 88 |
+
if unpack.opname == "STORE_FAST" or unpack.opname == "STORE_NAME":
|
| 89 |
+
# just a single dim, not a list
|
| 90 |
+
name = unpack.argval
|
| 91 |
+
ctor = Dim if lists == 0 else DimList
|
| 92 |
+
_cache[key] = lambda: ctor(name=name)
|
| 93 |
+
else:
|
| 94 |
+
assert unpack.opname == "UNPACK_SEQUENCE"
|
| 95 |
+
ndims = unpack.argval
|
| 96 |
+
names = tuple(
|
| 97 |
+
extract_name(instructions[first + 1 + i]) for i in range(ndims)
|
| 98 |
+
)
|
| 99 |
+
first_list = len(names) - lists
|
| 100 |
+
_cache[key] = lambda: tuple(
|
| 101 |
+
Dim(n) if i < first_list else DimList(name=n)
|
| 102 |
+
for i, n in enumerate(names)
|
| 103 |
+
)
|
| 104 |
+
return _cache[key]()
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def _dim_set(positional, arg):
|
| 108 |
+
def convert(a):
|
| 109 |
+
if isinstance(a, Dim):
|
| 110 |
+
return a
|
| 111 |
+
else:
|
| 112 |
+
assert isinstance(a, int)
|
| 113 |
+
return positional[a]
|
| 114 |
+
|
| 115 |
+
if arg is None:
|
| 116 |
+
return positional
|
| 117 |
+
elif not isinstance(arg, (Dim, int)):
|
| 118 |
+
return tuple(convert(a) for a in arg)
|
| 119 |
+
else:
|
| 120 |
+
return (convert(arg),)
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/magic_trace.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
# All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This source code is licensed under the BSD-style license found in the
|
| 5 |
+
# LICENSE file in the root directory of this source tree.
|
| 6 |
+
import os
|
| 7 |
+
import signal
|
| 8 |
+
import subprocess
|
| 9 |
+
from contextlib import contextmanager
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@contextmanager
|
| 13 |
+
def magic_trace(output="trace.fxt", magic_trace_cache="/tmp/magic-trace"):
|
| 14 |
+
pid = os.getpid()
|
| 15 |
+
if not os.path.exists(magic_trace_cache):
|
| 16 |
+
print(f"Downloading magic_trace to: {magic_trace_cache}")
|
| 17 |
+
subprocess.run(
|
| 18 |
+
[
|
| 19 |
+
"wget",
|
| 20 |
+
"-O",
|
| 21 |
+
magic_trace_cache,
|
| 22 |
+
"-q",
|
| 23 |
+
"https://github.com/janestreet/magic-trace/releases/download/v1.0.2/magic-trace",
|
| 24 |
+
]
|
| 25 |
+
)
|
| 26 |
+
subprocess.run(["chmod", "+x", magic_trace_cache])
|
| 27 |
+
args = [magic_trace_cache, "attach", "-pid", str(pid), "-o", output]
|
| 28 |
+
p = subprocess.Popen(args, stderr=subprocess.PIPE, encoding="utf-8")
|
| 29 |
+
while True:
|
| 30 |
+
x = p.stderr.readline()
|
| 31 |
+
print(x)
|
| 32 |
+
if "Attached" in x:
|
| 33 |
+
break
|
| 34 |
+
try:
|
| 35 |
+
yield
|
| 36 |
+
finally:
|
| 37 |
+
p.send_signal(signal.SIGINT)
|
| 38 |
+
r = p.wait()
|
| 39 |
+
print(p.stderr.read())
|
| 40 |
+
p.stderr.close()
|
| 41 |
+
if r != 0:
|
| 42 |
+
raise ValueError(f"magic_trace exited abnormally: {r}")
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/op_properties.py
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
# All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This source code is licensed under the BSD-style license found in the
|
| 5 |
+
# LICENSE file in the root directory of this source tree.
|
| 6 |
+
import torch
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
# pointwise operators can go through a faster pathway
|
| 10 |
+
|
| 11 |
+
tensor_magic_methods = ["add", ""]
|
| 12 |
+
pointwise_magic_methods_with_reverse = (
|
| 13 |
+
"add",
|
| 14 |
+
"sub",
|
| 15 |
+
"mul",
|
| 16 |
+
"floordiv",
|
| 17 |
+
"div",
|
| 18 |
+
"truediv",
|
| 19 |
+
"mod",
|
| 20 |
+
"pow",
|
| 21 |
+
"lshift",
|
| 22 |
+
"rshift",
|
| 23 |
+
"and",
|
| 24 |
+
"or",
|
| 25 |
+
"xor",
|
| 26 |
+
)
|
| 27 |
+
pointwise_magic_methods = (
|
| 28 |
+
*(x for m in pointwise_magic_methods_with_reverse for x in (m, "r" + m)),
|
| 29 |
+
"eq",
|
| 30 |
+
"gt",
|
| 31 |
+
"le",
|
| 32 |
+
"lt",
|
| 33 |
+
"ge",
|
| 34 |
+
"gt",
|
| 35 |
+
"ne",
|
| 36 |
+
"neg",
|
| 37 |
+
"pos",
|
| 38 |
+
"abs",
|
| 39 |
+
"invert",
|
| 40 |
+
"iadd",
|
| 41 |
+
"isub",
|
| 42 |
+
"imul",
|
| 43 |
+
"ifloordiv",
|
| 44 |
+
"idiv",
|
| 45 |
+
"itruediv",
|
| 46 |
+
"imod",
|
| 47 |
+
"ipow",
|
| 48 |
+
"ilshift",
|
| 49 |
+
"irshift",
|
| 50 |
+
"iand",
|
| 51 |
+
"ior",
|
| 52 |
+
"ixor",
|
| 53 |
+
"int",
|
| 54 |
+
"long",
|
| 55 |
+
"float",
|
| 56 |
+
"complex",
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
pointwise_methods = (*(f"__{m}__" for m in pointwise_magic_methods),)
|
| 60 |
+
|
| 61 |
+
pointwise = (
|
| 62 |
+
*(getattr(torch.Tensor, m) for m in pointwise_methods),
|
| 63 |
+
torch.nn.functional.dropout,
|
| 64 |
+
torch.where,
|
| 65 |
+
torch.Tensor.abs,
|
| 66 |
+
torch.abs,
|
| 67 |
+
torch.Tensor.acos,
|
| 68 |
+
torch.acos,
|
| 69 |
+
torch.Tensor.acosh,
|
| 70 |
+
torch.acosh,
|
| 71 |
+
torch.Tensor.add,
|
| 72 |
+
torch.add,
|
| 73 |
+
torch.Tensor.addcdiv,
|
| 74 |
+
torch.addcdiv,
|
| 75 |
+
torch.Tensor.addcmul,
|
| 76 |
+
torch.addcmul,
|
| 77 |
+
torch.Tensor.addr,
|
| 78 |
+
torch.addr,
|
| 79 |
+
torch.Tensor.angle,
|
| 80 |
+
torch.angle,
|
| 81 |
+
torch.Tensor.asin,
|
| 82 |
+
torch.asin,
|
| 83 |
+
torch.Tensor.asinh,
|
| 84 |
+
torch.asinh,
|
| 85 |
+
torch.Tensor.atan,
|
| 86 |
+
torch.atan,
|
| 87 |
+
torch.Tensor.atan2,
|
| 88 |
+
torch.atan2,
|
| 89 |
+
torch.Tensor.atanh,
|
| 90 |
+
torch.atanh,
|
| 91 |
+
torch.Tensor.bitwise_and,
|
| 92 |
+
torch.bitwise_and,
|
| 93 |
+
torch.Tensor.bitwise_left_shift,
|
| 94 |
+
torch.bitwise_left_shift,
|
| 95 |
+
torch.Tensor.bitwise_not,
|
| 96 |
+
torch.bitwise_not,
|
| 97 |
+
torch.Tensor.bitwise_or,
|
| 98 |
+
torch.bitwise_or,
|
| 99 |
+
torch.Tensor.bitwise_right_shift,
|
| 100 |
+
torch.bitwise_right_shift,
|
| 101 |
+
torch.Tensor.bitwise_xor,
|
| 102 |
+
torch.bitwise_xor,
|
| 103 |
+
torch.Tensor.ceil,
|
| 104 |
+
torch.ceil,
|
| 105 |
+
torch.celu,
|
| 106 |
+
torch.nn.functional.celu,
|
| 107 |
+
torch.Tensor.clamp,
|
| 108 |
+
torch.clamp,
|
| 109 |
+
torch.Tensor.clamp_max,
|
| 110 |
+
torch.clamp_max,
|
| 111 |
+
torch.Tensor.clamp_min,
|
| 112 |
+
torch.clamp_min,
|
| 113 |
+
torch.Tensor.copysign,
|
| 114 |
+
torch.copysign,
|
| 115 |
+
torch.Tensor.cos,
|
| 116 |
+
torch.cos,
|
| 117 |
+
torch.Tensor.cosh,
|
| 118 |
+
torch.cosh,
|
| 119 |
+
torch.Tensor.deg2rad,
|
| 120 |
+
torch.deg2rad,
|
| 121 |
+
torch.Tensor.digamma,
|
| 122 |
+
torch.digamma,
|
| 123 |
+
torch.Tensor.div,
|
| 124 |
+
torch.div,
|
| 125 |
+
torch.dropout,
|
| 126 |
+
torch.nn.functional.dropout,
|
| 127 |
+
torch.nn.functional.elu,
|
| 128 |
+
torch.Tensor.eq,
|
| 129 |
+
torch.eq,
|
| 130 |
+
torch.Tensor.erf,
|
| 131 |
+
torch.erf,
|
| 132 |
+
torch.Tensor.erfc,
|
| 133 |
+
torch.erfc,
|
| 134 |
+
torch.Tensor.erfinv,
|
| 135 |
+
torch.erfinv,
|
| 136 |
+
torch.Tensor.exp,
|
| 137 |
+
torch.exp,
|
| 138 |
+
torch.Tensor.exp2,
|
| 139 |
+
torch.exp2,
|
| 140 |
+
torch.Tensor.expm1,
|
| 141 |
+
torch.expm1,
|
| 142 |
+
torch.feature_dropout,
|
| 143 |
+
torch.Tensor.float_power,
|
| 144 |
+
torch.float_power,
|
| 145 |
+
torch.Tensor.floor,
|
| 146 |
+
torch.floor,
|
| 147 |
+
torch.Tensor.floor_divide,
|
| 148 |
+
torch.floor_divide,
|
| 149 |
+
torch.Tensor.fmod,
|
| 150 |
+
torch.fmod,
|
| 151 |
+
torch.Tensor.frac,
|
| 152 |
+
torch.frac,
|
| 153 |
+
torch.Tensor.frexp,
|
| 154 |
+
torch.frexp,
|
| 155 |
+
torch.Tensor.gcd,
|
| 156 |
+
torch.gcd,
|
| 157 |
+
torch.Tensor.ge,
|
| 158 |
+
torch.ge,
|
| 159 |
+
torch.nn.functional.gelu,
|
| 160 |
+
torch.nn.functional.glu,
|
| 161 |
+
torch.Tensor.gt,
|
| 162 |
+
torch.gt,
|
| 163 |
+
torch.Tensor.hardshrink,
|
| 164 |
+
torch.hardshrink,
|
| 165 |
+
torch.nn.functional.hardshrink,
|
| 166 |
+
torch.nn.functional.hardsigmoid,
|
| 167 |
+
torch.nn.functional.hardswish,
|
| 168 |
+
torch.nn.functional.hardtanh,
|
| 169 |
+
torch.Tensor.heaviside,
|
| 170 |
+
torch.heaviside,
|
| 171 |
+
torch.Tensor.hypot,
|
| 172 |
+
torch.hypot,
|
| 173 |
+
torch.Tensor.i0,
|
| 174 |
+
torch.i0,
|
| 175 |
+
torch.Tensor.igamma,
|
| 176 |
+
torch.igamma,
|
| 177 |
+
torch.Tensor.igammac,
|
| 178 |
+
torch.igammac,
|
| 179 |
+
torch.Tensor.isclose,
|
| 180 |
+
torch.isclose,
|
| 181 |
+
torch.Tensor.isfinite,
|
| 182 |
+
torch.isfinite,
|
| 183 |
+
torch.Tensor.isinf,
|
| 184 |
+
torch.isinf,
|
| 185 |
+
torch.Tensor.isnan,
|
| 186 |
+
torch.isnan,
|
| 187 |
+
torch.Tensor.isneginf,
|
| 188 |
+
torch.isneginf,
|
| 189 |
+
torch.Tensor.isposinf,
|
| 190 |
+
torch.isposinf,
|
| 191 |
+
torch.Tensor.isreal,
|
| 192 |
+
torch.isreal,
|
| 193 |
+
torch.Tensor.kron,
|
| 194 |
+
torch.kron,
|
| 195 |
+
torch.Tensor.lcm,
|
| 196 |
+
torch.lcm,
|
| 197 |
+
torch.Tensor.ldexp,
|
| 198 |
+
torch.ldexp,
|
| 199 |
+
torch.Tensor.le,
|
| 200 |
+
torch.le,
|
| 201 |
+
torch.nn.functional.leaky_relu,
|
| 202 |
+
torch.Tensor.lerp,
|
| 203 |
+
torch.lerp,
|
| 204 |
+
torch.Tensor.lgamma,
|
| 205 |
+
torch.lgamma,
|
| 206 |
+
torch.Tensor.log,
|
| 207 |
+
torch.log,
|
| 208 |
+
torch.Tensor.log10,
|
| 209 |
+
torch.log10,
|
| 210 |
+
torch.Tensor.log1p,
|
| 211 |
+
torch.log1p,
|
| 212 |
+
torch.Tensor.log2,
|
| 213 |
+
torch.log2,
|
| 214 |
+
torch.nn.functional.logsigmoid,
|
| 215 |
+
torch.Tensor.logical_and,
|
| 216 |
+
torch.logical_and,
|
| 217 |
+
torch.Tensor.logical_not,
|
| 218 |
+
torch.logical_not,
|
| 219 |
+
torch.Tensor.logical_or,
|
| 220 |
+
torch.logical_or,
|
| 221 |
+
torch.Tensor.logical_xor,
|
| 222 |
+
torch.logical_xor,
|
| 223 |
+
torch.Tensor.logit,
|
| 224 |
+
torch.logit,
|
| 225 |
+
torch.Tensor.lt,
|
| 226 |
+
torch.lt,
|
| 227 |
+
torch.Tensor.maximum,
|
| 228 |
+
torch.maximum,
|
| 229 |
+
torch.Tensor.minimum,
|
| 230 |
+
torch.minimum,
|
| 231 |
+
torch.nn.functional.mish,
|
| 232 |
+
torch.Tensor.mvlgamma,
|
| 233 |
+
torch.mvlgamma,
|
| 234 |
+
torch.Tensor.nan_to_num,
|
| 235 |
+
torch.nan_to_num,
|
| 236 |
+
torch.Tensor.ne,
|
| 237 |
+
torch.ne,
|
| 238 |
+
torch.Tensor.neg,
|
| 239 |
+
torch.neg,
|
| 240 |
+
torch.Tensor.nextafter,
|
| 241 |
+
torch.nextafter,
|
| 242 |
+
torch.Tensor.outer,
|
| 243 |
+
torch.outer,
|
| 244 |
+
torch.polar,
|
| 245 |
+
torch.Tensor.polygamma,
|
| 246 |
+
torch.polygamma,
|
| 247 |
+
torch.Tensor.positive,
|
| 248 |
+
torch.positive,
|
| 249 |
+
torch.Tensor.pow,
|
| 250 |
+
torch.pow,
|
| 251 |
+
torch.Tensor.prelu,
|
| 252 |
+
torch.prelu,
|
| 253 |
+
torch.nn.functional.prelu,
|
| 254 |
+
torch.Tensor.rad2deg,
|
| 255 |
+
torch.rad2deg,
|
| 256 |
+
torch.Tensor.reciprocal,
|
| 257 |
+
torch.reciprocal,
|
| 258 |
+
torch.Tensor.relu,
|
| 259 |
+
torch.relu,
|
| 260 |
+
torch.nn.functional.relu,
|
| 261 |
+
torch.nn.functional.relu6,
|
| 262 |
+
torch.Tensor.remainder,
|
| 263 |
+
torch.remainder,
|
| 264 |
+
torch.Tensor.round,
|
| 265 |
+
torch.round,
|
| 266 |
+
torch.rrelu,
|
| 267 |
+
torch.nn.functional.rrelu,
|
| 268 |
+
torch.Tensor.rsqrt,
|
| 269 |
+
torch.rsqrt,
|
| 270 |
+
torch.rsub,
|
| 271 |
+
torch.selu,
|
| 272 |
+
torch.nn.functional.selu,
|
| 273 |
+
torch.Tensor.sgn,
|
| 274 |
+
torch.sgn,
|
| 275 |
+
torch.Tensor.sigmoid,
|
| 276 |
+
torch.sigmoid,
|
| 277 |
+
torch.nn.functional.sigmoid,
|
| 278 |
+
torch.Tensor.sign,
|
| 279 |
+
torch.sign,
|
| 280 |
+
torch.Tensor.signbit,
|
| 281 |
+
torch.signbit,
|
| 282 |
+
torch.nn.functional.silu,
|
| 283 |
+
torch.Tensor.sin,
|
| 284 |
+
torch.sin,
|
| 285 |
+
torch.Tensor.sinc,
|
| 286 |
+
torch.sinc,
|
| 287 |
+
torch.Tensor.sinh,
|
| 288 |
+
torch.sinh,
|
| 289 |
+
torch.nn.functional.softplus,
|
| 290 |
+
torch.nn.functional.softshrink,
|
| 291 |
+
torch.Tensor.sqrt,
|
| 292 |
+
torch.sqrt,
|
| 293 |
+
torch.Tensor.square,
|
| 294 |
+
torch.square,
|
| 295 |
+
torch.Tensor.sub,
|
| 296 |
+
torch.sub,
|
| 297 |
+
torch.Tensor.tan,
|
| 298 |
+
torch.tan,
|
| 299 |
+
torch.Tensor.tanh,
|
| 300 |
+
torch.tanh,
|
| 301 |
+
torch.nn.functional.tanh,
|
| 302 |
+
torch.threshold,
|
| 303 |
+
torch.nn.functional.threshold,
|
| 304 |
+
torch.trapz,
|
| 305 |
+
torch.Tensor.true_divide,
|
| 306 |
+
torch.true_divide,
|
| 307 |
+
torch.Tensor.trunc,
|
| 308 |
+
torch.trunc,
|
| 309 |
+
torch.Tensor.xlogy,
|
| 310 |
+
torch.xlogy,
|
| 311 |
+
torch.rand_like,
|
| 312 |
+
)
|
data/tefig/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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
# All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This source code is licensed under the BSD-style license found in the
|
| 5 |
+
# LICENSE file in the root directory of this source tree.
|
| 6 |
+
|
| 7 |
+
# reference python implementations for C ops
|
| 8 |
+
import torch
|
| 9 |
+
from functorch._C import dim as _C
|
| 10 |
+
|
| 11 |
+
from . import op_properties
|
| 12 |
+
from .batch_tensor import _enable_layers
|
| 13 |
+
from .tree_map import tree_flatten, tree_map
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
DimList = _C.DimList
|
| 17 |
+
import operator
|
| 18 |
+
from functools import reduce
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# use dict to avoid writing C++ bindings for set
|
| 22 |
+
pointwise = set(op_properties.pointwise)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def prod(x):
|
| 26 |
+
return reduce(operator.mul, x, 1)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def _wrap_dim(d, N, keepdim):
|
| 30 |
+
from . import Dim
|
| 31 |
+
|
| 32 |
+
if isinstance(d, Dim):
|
| 33 |
+
assert not keepdim, "cannot preserve first-class dimensions with keepdim=True"
|
| 34 |
+
return d
|
| 35 |
+
elif d >= 0:
|
| 36 |
+
return d - N
|
| 37 |
+
else:
|
| 38 |
+
return d
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def _dims(d, N, keepdim, single_dim):
|
| 42 |
+
from . import Dim
|
| 43 |
+
|
| 44 |
+
if isinstance(d, (Dim, int)):
|
| 45 |
+
return ltuple((_wrap_dim(d, N, keepdim),))
|
| 46 |
+
assert not single_dim, f"expected a single dimension or int but found: {d}"
|
| 47 |
+
return ltuple(_wrap_dim(x, N, keepdim) for x in d)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def _bind_dims_to_size(lhs_size, rhs, lhs_debug):
|
| 51 |
+
from . import DimensionMismatchError
|
| 52 |
+
|
| 53 |
+
not_bound = tuple((i, r) for i, r in enumerate(rhs) if not r.is_bound)
|
| 54 |
+
if len(not_bound) == 1:
|
| 55 |
+
idx, d = not_bound[0]
|
| 56 |
+
rhs_so_far = prod(r.size for r in rhs if r.is_bound)
|
| 57 |
+
if lhs_size % rhs_so_far != 0:
|
| 58 |
+
rhs_s = tuple("?" if not r.is_bound else str(r.size) for r in rhs)
|
| 59 |
+
raise DimensionMismatchError(
|
| 60 |
+
f"inferred dimension does not evenly fit into larger dimension: {lhs_size} vs {rhs_s}"
|
| 61 |
+
)
|
| 62 |
+
new_size = lhs_size // rhs_so_far
|
| 63 |
+
d.size = new_size
|
| 64 |
+
elif len(not_bound) > 1:
|
| 65 |
+
rhs_s = tuple("?" if not r.is_bound else str(r.size) for r in rhs)
|
| 66 |
+
raise DimensionMismatchError(
|
| 67 |
+
f"cannot infer the size of two dimensions at once: {rhs} with sizes {rhs_s}"
|
| 68 |
+
)
|
| 69 |
+
else:
|
| 70 |
+
rhs_size = prod(r.size for r in rhs)
|
| 71 |
+
if lhs_size != rhs_size:
|
| 72 |
+
raise DimensionMismatchError(
|
| 73 |
+
f"Dimension sizes to do not match ({lhs_size} != {rhs_size}) when matching {lhs_debug} to {rhs}"
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def _tensor_levels(inp):
|
| 78 |
+
from . import _Tensor
|
| 79 |
+
|
| 80 |
+
if isinstance(inp, _Tensor):
|
| 81 |
+
return inp._tensor, llist(inp._levels), inp._has_device
|
| 82 |
+
else:
|
| 83 |
+
return inp, llist(range(-inp.ndim, 0)), True
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def _match_levels(v, from_levels, to_levels):
|
| 87 |
+
view = []
|
| 88 |
+
permute = []
|
| 89 |
+
requires_view = False
|
| 90 |
+
size = v.size()
|
| 91 |
+
for t in to_levels:
|
| 92 |
+
try:
|
| 93 |
+
idx = from_levels.index(t)
|
| 94 |
+
permute.append(idx)
|
| 95 |
+
view.append(size[idx])
|
| 96 |
+
except ValueError:
|
| 97 |
+
view.append(1)
|
| 98 |
+
requires_view = True
|
| 99 |
+
if permute != list(range(len(permute))):
|
| 100 |
+
v = v.permute(*permute)
|
| 101 |
+
if requires_view:
|
| 102 |
+
v = v.view(*view)
|
| 103 |
+
return v
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
# make a single dimension positional but do not permute it,
|
| 107 |
+
# used to do multi-tensor operators where the dim being acted on
|
| 108 |
+
# should not physically move if possible
|
| 109 |
+
def _positional_no_permute(self, dim, expand_dim=False):
|
| 110 |
+
from . import Tensor
|
| 111 |
+
|
| 112 |
+
ptensor, levels = self._tensor, llist(self._levels)
|
| 113 |
+
try:
|
| 114 |
+
idx = levels.index(dim)
|
| 115 |
+
except ValueError:
|
| 116 |
+
if not expand_dim:
|
| 117 |
+
raise
|
| 118 |
+
idx = 0
|
| 119 |
+
ptensor = ptensor.expand(dim.size, *ptensor.size())
|
| 120 |
+
levels.insert(0, 0)
|
| 121 |
+
idx_batched = 0
|
| 122 |
+
for i in range(idx):
|
| 123 |
+
if isinstance(levels[i], int):
|
| 124 |
+
levels[i] -= 1
|
| 125 |
+
idx_batched += 1
|
| 126 |
+
levels[idx] = -idx_batched - 1
|
| 127 |
+
return Tensor.from_positional(ptensor, levels, self._has_device), idx_batched
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def seq(a, b):
|
| 131 |
+
from . import Dim
|
| 132 |
+
|
| 133 |
+
if isinstance(a, Dim) != isinstance(b, Dim):
|
| 134 |
+
return False
|
| 135 |
+
if isinstance(a, Dim):
|
| 136 |
+
return a is b
|
| 137 |
+
else:
|
| 138 |
+
return a == b
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
class isin:
|
| 142 |
+
__slots__ = ()
|
| 143 |
+
|
| 144 |
+
def __contains__(self, item):
|
| 145 |
+
for x in self:
|
| 146 |
+
if seq(item, x):
|
| 147 |
+
return True
|
| 148 |
+
return False
|
| 149 |
+
|
| 150 |
+
def index(self, item):
|
| 151 |
+
for i, x in enumerate(self):
|
| 152 |
+
if seq(item, x):
|
| 153 |
+
return i
|
| 154 |
+
raise ValueError
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
class llist(isin, list):
|
| 158 |
+
__slots__ = ()
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
class ltuple(isin, tuple):
|
| 162 |
+
__slots__ = ()
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
empty_dict = {}
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
@classmethod
|
| 169 |
+
def __torch_function__(self, orig, cls, args, kwargs=empty_dict):
|
| 170 |
+
from . import _Tensor, Tensor, TensorLike
|
| 171 |
+
from .delayed_mul_tensor import DelayedMulTensor
|
| 172 |
+
|
| 173 |
+
if orig is torch.Tensor.__mul__:
|
| 174 |
+
lhs, rhs = args
|
| 175 |
+
if (
|
| 176 |
+
isinstance(lhs, _Tensor)
|
| 177 |
+
and isinstance(rhs, _Tensor)
|
| 178 |
+
and lhs.ndim == 0
|
| 179 |
+
and rhs.ndim == 0
|
| 180 |
+
):
|
| 181 |
+
return DelayedMulTensor(lhs, rhs)
|
| 182 |
+
all_dims = llist()
|
| 183 |
+
flat_args, unflatten = tree_flatten((args, kwargs))
|
| 184 |
+
device_holding_tensor = None
|
| 185 |
+
for f in flat_args:
|
| 186 |
+
if isinstance(f, _Tensor):
|
| 187 |
+
if f._has_device:
|
| 188 |
+
device_holding_tensor = f._batchtensor
|
| 189 |
+
for d in f.dims:
|
| 190 |
+
if d not in all_dims:
|
| 191 |
+
all_dims.append(d)
|
| 192 |
+
|
| 193 |
+
def unwrap(t):
|
| 194 |
+
if isinstance(t, _Tensor):
|
| 195 |
+
r = t._batchtensor
|
| 196 |
+
if device_holding_tensor is not None and not t._has_device:
|
| 197 |
+
r = r.to(device=device_holding_tensor.device)
|
| 198 |
+
return r
|
| 199 |
+
return t
|
| 200 |
+
|
| 201 |
+
if orig in pointwise:
|
| 202 |
+
result_levels = llist()
|
| 203 |
+
to_expand = []
|
| 204 |
+
for i, f in enumerate(flat_args):
|
| 205 |
+
if isinstance(f, TensorLike):
|
| 206 |
+
ptensor, levels, _ = _tensor_levels(f)
|
| 207 |
+
if (
|
| 208 |
+
isinstance(f, _Tensor)
|
| 209 |
+
and not f._has_device
|
| 210 |
+
and device_holding_tensor is not None
|
| 211 |
+
):
|
| 212 |
+
ptensor = ptensor.to(device=device_holding_tensor.device)
|
| 213 |
+
flat_args[i] = ptensor
|
| 214 |
+
for l in levels:
|
| 215 |
+
if l not in result_levels:
|
| 216 |
+
result_levels.append(l)
|
| 217 |
+
to_expand.append((i, levels))
|
| 218 |
+
|
| 219 |
+
for i, levels in to_expand:
|
| 220 |
+
flat_args[i] = _match_levels(flat_args[i], levels, result_levels)
|
| 221 |
+
args, kwargs = unflatten(flat_args)
|
| 222 |
+
result = orig(*args, **kwargs)
|
| 223 |
+
|
| 224 |
+
def wrap(t):
|
| 225 |
+
if isinstance(t, TensorLike):
|
| 226 |
+
return Tensor.from_positional(
|
| 227 |
+
t, result_levels, device_holding_tensor is not None
|
| 228 |
+
)
|
| 229 |
+
return t
|
| 230 |
+
|
| 231 |
+
return tree_map(wrap, result)
|
| 232 |
+
else:
|
| 233 |
+
|
| 234 |
+
def wrap(t):
|
| 235 |
+
if isinstance(t, TensorLike):
|
| 236 |
+
return Tensor.from_batched(t, device_holding_tensor is not None)
|
| 237 |
+
return t
|
| 238 |
+
|
| 239 |
+
with _enable_layers(all_dims):
|
| 240 |
+
print(f"batch_tensor for {orig}")
|
| 241 |
+
args, kwargs = unflatten(unwrap(f) for f in flat_args)
|
| 242 |
+
result = orig(*args, **kwargs)
|
| 243 |
+
# print("END", orig)
|
| 244 |
+
return tree_map(wrap, result)
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
def positional(self, *dims):
|
| 248 |
+
from . import Dim, DimensionBindError, Tensor
|
| 249 |
+
|
| 250 |
+
ptensor, levels = self._tensor, llist(self._levels)
|
| 251 |
+
flat_dims = llist()
|
| 252 |
+
view = []
|
| 253 |
+
needs_view = False
|
| 254 |
+
ndim = self.ndim
|
| 255 |
+
for d in dims:
|
| 256 |
+
if isinstance(d, DimList):
|
| 257 |
+
flat_dims.extend(d)
|
| 258 |
+
view.extend(e.size for e in d)
|
| 259 |
+
elif isinstance(d, Dim):
|
| 260 |
+
flat_dims.append(d)
|
| 261 |
+
view.append(d.size)
|
| 262 |
+
elif isinstance(d, int):
|
| 263 |
+
d = _wrap_dim(d, ndim, False)
|
| 264 |
+
flat_dims.append(d)
|
| 265 |
+
view.append(ptensor.size(d))
|
| 266 |
+
else:
|
| 267 |
+
flat_dims.extend(d)
|
| 268 |
+
view.append(prod(e.size for e in d))
|
| 269 |
+
needs_view = True
|
| 270 |
+
|
| 271 |
+
permute = list(range(len(levels)))
|
| 272 |
+
for i, d in enumerate(flat_dims):
|
| 273 |
+
try:
|
| 274 |
+
idx = levels.index(d)
|
| 275 |
+
except ValueError as e:
|
| 276 |
+
raise DimensionBindError(
|
| 277 |
+
f"tensor of dimensions {self.dims} does not contain dim {d}"
|
| 278 |
+
) from e
|
| 279 |
+
p = permute[idx]
|
| 280 |
+
del levels[idx]
|
| 281 |
+
del permute[idx]
|
| 282 |
+
levels.insert(i, 0)
|
| 283 |
+
permute.insert(i, p)
|
| 284 |
+
ptensor = ptensor.permute(*permute)
|
| 285 |
+
seen = 0
|
| 286 |
+
for i in range(len(levels) - 1, -1, -1):
|
| 287 |
+
if isinstance(levels[i], int):
|
| 288 |
+
seen += 1
|
| 289 |
+
levels[i] = -seen
|
| 290 |
+
result = Tensor.from_positional(ptensor, levels, self._has_device)
|
| 291 |
+
if needs_view:
|
| 292 |
+
result = result.reshape(*view, *result.size()[len(flat_dims) :])
|
| 293 |
+
return result
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
def _contains_dim(input):
|
| 297 |
+
from . import Dim
|
| 298 |
+
|
| 299 |
+
for i in input:
|
| 300 |
+
if isinstance(i, Dim):
|
| 301 |
+
return True
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
def expand(self, *sizes):
|
| 305 |
+
if not _contains_dim(sizes):
|
| 306 |
+
return self.__torch_function__(torch.Tensor.expand, None, (self, *sizes))
|
| 307 |
+
dims = sizes
|
| 308 |
+
sizes = [d.size for d in dims] + [-1] * self.ndim
|
| 309 |
+
self = self.expand(*sizes)
|
| 310 |
+
return self[dims]
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
_not_present = object()
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
def _getarg(name, offset, args, kwargs, default):
|
| 317 |
+
if len(args) > offset:
|
| 318 |
+
return args[offset]
|
| 319 |
+
return kwargs.get(name, default)
|
| 320 |
+
|
| 321 |
+
|
| 322 |
+
def _patcharg(name, offset, args, kwargs, value):
|
| 323 |
+
if len(args) > offset:
|
| 324 |
+
args[offset] = value
|
| 325 |
+
else:
|
| 326 |
+
kwargs[name] = value
|
| 327 |
+
|
| 328 |
+
|
| 329 |
+
def _wrap(
|
| 330 |
+
orig, dim_offset=0, keepdim_offset=1, dim_name="dim", single_dim=False, reduce=True
|
| 331 |
+
):
|
| 332 |
+
from . import Dim, Tensor, TensorLike
|
| 333 |
+
|
| 334 |
+
def fn(self, *args, **kwargs):
|
| 335 |
+
dim = _getarg(dim_name, dim_offset, args, kwargs, _not_present)
|
| 336 |
+
if dim is _not_present or (single_dim and not isinstance(dim, Dim)):
|
| 337 |
+
with _enable_layers(self.dims):
|
| 338 |
+
print(f"dim fallback batch_tensor for {orig}")
|
| 339 |
+
return Tensor.from_batched(
|
| 340 |
+
orig(self._batchtensor, *args, **kwargs), self._has_device
|
| 341 |
+
)
|
| 342 |
+
keepdim = (
|
| 343 |
+
_getarg("keepdim", keepdim_offset, args, kwargs, False) if reduce else False
|
| 344 |
+
)
|
| 345 |
+
t, levels = self._tensor, llist(self._levels)
|
| 346 |
+
dims = _dims(dim, self._batchtensor.ndim, keepdim, single_dim)
|
| 347 |
+
dim_indices = tuple(levels.index(d) for d in dims)
|
| 348 |
+
if reduce and not keepdim:
|
| 349 |
+
new_levels = [l for i, l in enumerate(levels) if i not in dim_indices]
|
| 350 |
+
else:
|
| 351 |
+
new_levels = levels
|
| 352 |
+
|
| 353 |
+
if len(dim_indices) == 1:
|
| 354 |
+
dim_indices = dim_indices[
|
| 355 |
+
0
|
| 356 |
+
] # so that dims that really only take a single argument work...
|
| 357 |
+
args = list(args)
|
| 358 |
+
_patcharg(dim_name, dim_offset, args, kwargs, dim_indices)
|
| 359 |
+
|
| 360 |
+
def wrap(t):
|
| 361 |
+
if isinstance(t, TensorLike):
|
| 362 |
+
return Tensor.from_positional(t, new_levels, self._has_device)
|
| 363 |
+
return t
|
| 364 |
+
|
| 365 |
+
with _enable_layers(new_levels):
|
| 366 |
+
print(f"dim used batch_tensor for {orig}")
|
| 367 |
+
r = orig(t, *args, **kwargs)
|
| 368 |
+
return tree_map(wrap, r)
|
| 369 |
+
|
| 370 |
+
return fn
|
| 371 |
+
|
| 372 |
+
|
| 373 |
+
def _def(name, *args, **kwargs):
|
| 374 |
+
from . import _Tensor
|
| 375 |
+
|
| 376 |
+
orig = getattr(torch.Tensor, name)
|
| 377 |
+
setattr(_Tensor, name, _wrap(orig, *args, **kwargs))
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
no_slice = slice(None)
|
| 381 |
+
|
| 382 |
+
_orig_getitem = torch.Tensor.__getitem__
|
| 383 |
+
|
| 384 |
+
|
| 385 |
+
class dim_tracker:
|
| 386 |
+
def __init__(self) -> None:
|
| 387 |
+
self.dims = llist()
|
| 388 |
+
self.count = []
|
| 389 |
+
|
| 390 |
+
def record(self, d):
|
| 391 |
+
if d not in self.dims:
|
| 392 |
+
self.dims.append(d)
|
| 393 |
+
self.count.append(1)
|
| 394 |
+
|
| 395 |
+
def __getitem__(self, d):
|
| 396 |
+
return self.count[self.dims.index(d)]
|
| 397 |
+
|
| 398 |
+
|
| 399 |
+
def t__getitem__(self, input):
|
| 400 |
+
from . import _Tensor, Dim, DimensionBindError, DimList, Tensor, TensorLike
|
| 401 |
+
|
| 402 |
+
# * bail to original example if we have a single non-Dim tensor, or a non-tensor
|
| 403 |
+
# * locate ... or an unbound tensor list, and determine its size, bind dim list
|
| 404 |
+
# (remember that None does not count to the total dim count)
|
| 405 |
+
# * bind simple dims and dim-packs to their sizes, count the number of uses of each dim,
|
| 406 |
+
# produce the re-view if needed
|
| 407 |
+
# * for each single-use dim index, replace with no_slice and mark that it will be added
|
| 408 |
+
# (keep track of whether we have to call super)
|
| 409 |
+
# * call super if needed
|
| 410 |
+
# * if we have dims to bind, bind them (it will help if we eliminated ... and None before)
|
| 411 |
+
# this handles bool indexing handling, as well as some other simple cases.
|
| 412 |
+
|
| 413 |
+
is_simple = (
|
| 414 |
+
not isinstance(input, Dim)
|
| 415 |
+
and not isinstance(input, (tuple, list))
|
| 416 |
+
and
|
| 417 |
+
# WAR for functorch bug where zero time tensors in getitem are not handled correctly.
|
| 418 |
+
not (isinstance(input, TensorLike) and input.ndim == 0)
|
| 419 |
+
)
|
| 420 |
+
|
| 421 |
+
if is_simple:
|
| 422 |
+
if isinstance(self, _Tensor):
|
| 423 |
+
return _Tensor.__torch_function__(_orig_getitem, None, (self, input))
|
| 424 |
+
else:
|
| 425 |
+
return _orig_getitem(self, input)
|
| 426 |
+
|
| 427 |
+
# can further optimize this case
|
| 428 |
+
if not isinstance(input, tuple):
|
| 429 |
+
input = [input]
|
| 430 |
+
else:
|
| 431 |
+
input = list(input)
|
| 432 |
+
|
| 433 |
+
dims_indexed = 0
|
| 434 |
+
expanding_object = None
|
| 435 |
+
dimlists = []
|
| 436 |
+
for i, s in enumerate(input):
|
| 437 |
+
if s is ... or isinstance(s, DimList) and not s.is_bound:
|
| 438 |
+
if expanding_object is not None:
|
| 439 |
+
msg = (
|
| 440 |
+
"at most one ... or unbound dimension list can exist in indexing list but"
|
| 441 |
+
f" found 2 at offsets {i} and {expanding_object}"
|
| 442 |
+
)
|
| 443 |
+
raise DimensionBindError(msg)
|
| 444 |
+
expanding_object = i
|
| 445 |
+
|
| 446 |
+
if isinstance(s, DimList):
|
| 447 |
+
dims_indexed += len(s) if s.is_bound else 0
|
| 448 |
+
dimlists.append(i)
|
| 449 |
+
elif s is not None and s is not ...:
|
| 450 |
+
dims_indexed += 1
|
| 451 |
+
|
| 452 |
+
ndim = self.ndim
|
| 453 |
+
if dims_indexed > ndim:
|
| 454 |
+
raise IndexError(
|
| 455 |
+
f"at least {dims_indexed} indices were supplied but the tensor only has {ndim} dimensions."
|
| 456 |
+
)
|
| 457 |
+
if expanding_object is not None:
|
| 458 |
+
expanding_ndims = ndim - dims_indexed
|
| 459 |
+
obj = input[expanding_object]
|
| 460 |
+
if obj is ...:
|
| 461 |
+
input[expanding_object : expanding_object + 1] = [
|
| 462 |
+
no_slice
|
| 463 |
+
] * expanding_ndims
|
| 464 |
+
else:
|
| 465 |
+
obj.bind_len(expanding_ndims)
|
| 466 |
+
# flatten the dimslists into the indexing
|
| 467 |
+
for i in reversed(dimlists):
|
| 468 |
+
input[i : i + 1] = input[i]
|
| 469 |
+
dims_indexed = 0
|
| 470 |
+
requires_view = False
|
| 471 |
+
size = self.size()
|
| 472 |
+
view_sizes = []
|
| 473 |
+
dims_seen = dim_tracker()
|
| 474 |
+
|
| 475 |
+
def add_dims(t):
|
| 476 |
+
if not isinstance(t, _Tensor):
|
| 477 |
+
return
|
| 478 |
+
for d in t.dims:
|
| 479 |
+
dims_seen.record(d)
|
| 480 |
+
|
| 481 |
+
add_dims(self)
|
| 482 |
+
dim_packs = []
|
| 483 |
+
for i, idx in enumerate(input):
|
| 484 |
+
if idx is None:
|
| 485 |
+
input[i] = no_slice
|
| 486 |
+
view_sizes.append(1)
|
| 487 |
+
requires_view = True
|
| 488 |
+
else:
|
| 489 |
+
sz = size[dims_indexed]
|
| 490 |
+
if isinstance(idx, Dim):
|
| 491 |
+
idx.size = sz
|
| 492 |
+
dims_seen.record(idx)
|
| 493 |
+
view_sizes.append(sz)
|
| 494 |
+
elif isinstance(idx, (tuple, list)) and idx and isinstance(idx[0], Dim):
|
| 495 |
+
for d in idx:
|
| 496 |
+
dims_seen.record(idx)
|
| 497 |
+
_bind_dims_to_size(sz, idx, f"offset {i}")
|
| 498 |
+
view_sizes.extend(d.size for d in idx)
|
| 499 |
+
requires_view = True
|
| 500 |
+
dim_packs.append(i)
|
| 501 |
+
else:
|
| 502 |
+
add_dims(idx)
|
| 503 |
+
view_sizes.append(sz)
|
| 504 |
+
dims_indexed += 1
|
| 505 |
+
if requires_view:
|
| 506 |
+
self = self.view(*view_sizes)
|
| 507 |
+
for i in reversed(dim_packs):
|
| 508 |
+
input[i : i + 1] = input[i]
|
| 509 |
+
|
| 510 |
+
# currently:
|
| 511 |
+
# input is flat, containing either Dim, or Tensor, or something valid for standard indexing
|
| 512 |
+
# self may have first-class dims as well.
|
| 513 |
+
|
| 514 |
+
# to index:
|
| 515 |
+
# drop the first class dims from self, they just become direct indices of their positions
|
| 516 |
+
|
| 517 |
+
# figure out the dimensions of the indexing tensors: union of all the dims in the tensors in the index.
|
| 518 |
+
# these dimensions will appear and need to be bound at the first place tensor occurs
|
| 519 |
+
|
| 520 |
+
if isinstance(self, _Tensor):
|
| 521 |
+
ptensor_self, levels = self._tensor, list(self._levels)
|
| 522 |
+
# indices to ptensor rather than self which has first-class dimensions
|
| 523 |
+
input_it = iter(input)
|
| 524 |
+
flat_inputs = [next(input_it) if isinstance(l, int) else l for l in levels]
|
| 525 |
+
has_device = self._has_device
|
| 526 |
+
to_pad = 0
|
| 527 |
+
else:
|
| 528 |
+
ptensor_self, flat_inputs = self, input
|
| 529 |
+
to_pad = ptensor_self.ndim - len(flat_inputs)
|
| 530 |
+
has_device = True
|
| 531 |
+
|
| 532 |
+
result_levels = []
|
| 533 |
+
index_levels = []
|
| 534 |
+
tensor_insert_point = None
|
| 535 |
+
to_expand = {}
|
| 536 |
+
requires_getindex = False
|
| 537 |
+
for i, inp in enumerate(flat_inputs):
|
| 538 |
+
if isinstance(inp, Dim) and dims_seen[inp] == 1:
|
| 539 |
+
flat_inputs[i] = no_slice
|
| 540 |
+
result_levels.append(inp)
|
| 541 |
+
elif isinstance(inp, TensorLike):
|
| 542 |
+
requires_getindex = True
|
| 543 |
+
if tensor_insert_point is None:
|
| 544 |
+
tensor_insert_point = len(result_levels)
|
| 545 |
+
ptensor, levels, _ = _tensor_levels(inp)
|
| 546 |
+
to_expand[i] = levels
|
| 547 |
+
flat_inputs[i] = ptensor
|
| 548 |
+
for l in levels:
|
| 549 |
+
if l not in index_levels:
|
| 550 |
+
index_levels.append(l)
|
| 551 |
+
else:
|
| 552 |
+
requires_getindex = True
|
| 553 |
+
result_levels.append(0)
|
| 554 |
+
|
| 555 |
+
if tensor_insert_point is not None:
|
| 556 |
+
result_levels[tensor_insert_point:tensor_insert_point] = index_levels
|
| 557 |
+
|
| 558 |
+
for i, levels in to_expand.items():
|
| 559 |
+
flat_inputs[i] = _match_levels(flat_inputs[i], levels, index_levels)
|
| 560 |
+
|
| 561 |
+
if requires_getindex:
|
| 562 |
+
result = _orig_getitem(ptensor_self, flat_inputs)
|
| 563 |
+
else:
|
| 564 |
+
result = ptensor_self
|
| 565 |
+
|
| 566 |
+
next_positional = -1
|
| 567 |
+
if to_pad > 0:
|
| 568 |
+
result_levels.extend([0] * to_pad)
|
| 569 |
+
for i, r in enumerate(reversed(result_levels)):
|
| 570 |
+
if isinstance(r, int):
|
| 571 |
+
result_levels[-1 - i] = next_positional
|
| 572 |
+
next_positional -= 1
|
| 573 |
+
|
| 574 |
+
return Tensor.from_positional(result, result_levels, has_device)
|
| 575 |
+
|
| 576 |
+
|
| 577 |
+
# XXX - dim is optional and can be the outer-most dimension...
|
| 578 |
+
def stack(tensors, new_dim, dim=0, out=None):
|
| 579 |
+
if isinstance(dim, int):
|
| 580 |
+
return torch.stack(tensors, dim, out).index(dim, new_dim)
|
| 581 |
+
index = None
|
| 582 |
+
if out is not None:
|
| 583 |
+
out, index = _positional_no_permute(out, dim, expand_dim=True)
|
| 584 |
+
ptensors = []
|
| 585 |
+
for t in tensors:
|
| 586 |
+
pt, pi = _positional_no_permute(t, dim, expand_dim=True)
|
| 587 |
+
if index is not None and pi != index:
|
| 588 |
+
pt = pt.move_dim(pi, index)
|
| 589 |
+
else:
|
| 590 |
+
index = pi
|
| 591 |
+
ptensors.append(pt)
|
| 592 |
+
pr = torch.stack(ptensors, index, out=out)
|
| 593 |
+
return pr.index((index, index + 1), (new_dim, dim))
|
| 594 |
+
|
| 595 |
+
|
| 596 |
+
_orig_split = torch.Tensor.split
|
| 597 |
+
|
| 598 |
+
|
| 599 |
+
def split(self, split_size_or_sections, dim=0):
|
| 600 |
+
from . import _Tensor, Dim
|
| 601 |
+
|
| 602 |
+
if isinstance(split_size_or_sections, int) or any(
|
| 603 |
+
isinstance(t, int) for t in split_size_or_sections
|
| 604 |
+
):
|
| 605 |
+
if isinstance(dim, Dim):
|
| 606 |
+
raise ValueError(
|
| 607 |
+
"when dim is specified as a Dim object, split sizes must also be dimensions."
|
| 608 |
+
)
|
| 609 |
+
return _orig_split(self, split_size_or_sections, dim=dim)
|
| 610 |
+
|
| 611 |
+
if isinstance(dim, Dim):
|
| 612 |
+
assert isinstance(self, _Tensor), f"Tensor does not have dimension {dim}"
|
| 613 |
+
self, dim = _positional_no_permute(self, dim)
|
| 614 |
+
|
| 615 |
+
size = self.size(dim)
|
| 616 |
+
total_bound_size = 0
|
| 617 |
+
unbound = []
|
| 618 |
+
sizes = []
|
| 619 |
+
for i, d in enumerate(split_size_or_sections):
|
| 620 |
+
if d.is_bound:
|
| 621 |
+
sizes.append(d.size)
|
| 622 |
+
total_bound_size += d.size
|
| 623 |
+
else:
|
| 624 |
+
sizes.append(0)
|
| 625 |
+
unbound.append(i)
|
| 626 |
+
|
| 627 |
+
if unbound:
|
| 628 |
+
assert total_bound_size <= size, (
|
| 629 |
+
f"result dimensions are larger than original: {total_bound_size} vs {size} ({split_size_or_sections})"
|
| 630 |
+
)
|
| 631 |
+
remaining_size = size - total_bound_size
|
| 632 |
+
chunk_size = -(-remaining_size // len(unbound))
|
| 633 |
+
for u in unbound:
|
| 634 |
+
sz = min(chunk_size, remaining_size)
|
| 635 |
+
split_size_or_sections[u].size = sz
|
| 636 |
+
sizes[u] = sz
|
| 637 |
+
remaining_size -= sz
|
| 638 |
+
else:
|
| 639 |
+
assert total_bound_size == size, (
|
| 640 |
+
f"result dimensions do not match original: {total_bound_size} vs {size} ({split_size_or_sections})"
|
| 641 |
+
)
|
| 642 |
+
return tuple(
|
| 643 |
+
t.index(dim, d)
|
| 644 |
+
for d, t in zip(split_size_or_sections, _orig_split(self, sizes, dim=dim))
|
| 645 |
+
)
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/tree_map.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
# All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This source code is licensed under the BSD-style license found in the
|
| 5 |
+
# LICENSE file in the root directory of this source tree.
|
| 6 |
+
|
| 7 |
+
from functorch._C import dim
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
tree_flatten = dim.tree_flatten
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def tree_map(fn, tree):
|
| 14 |
+
vs, unflatten = tree_flatten(tree)
|
| 15 |
+
return unflatten(fn(v) for v in vs)
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/dim/wrap_type.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
| 2 |
+
# All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This source code is licensed under the BSD-style license found in the
|
| 5 |
+
# LICENSE file in the root directory of this source tree.
|
| 6 |
+
|
| 7 |
+
from types import (
|
| 8 |
+
BuiltinMethodType,
|
| 9 |
+
FunctionType,
|
| 10 |
+
GetSetDescriptorType,
|
| 11 |
+
MethodDescriptorType,
|
| 12 |
+
WrapperDescriptorType,
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
from functorch._C import dim as _C
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
_wrap_method = _C._wrap_method
|
| 19 |
+
|
| 20 |
+
FUNC_TYPES = (
|
| 21 |
+
FunctionType,
|
| 22 |
+
MethodDescriptorType,
|
| 23 |
+
BuiltinMethodType,
|
| 24 |
+
WrapperDescriptorType,
|
| 25 |
+
)
|
| 26 |
+
PROPERTY_TYPES = (GetSetDescriptorType, property)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def _py_wrap_method(orig, __torch_function__):
|
| 30 |
+
def impl(*args, **kwargs):
|
| 31 |
+
return __torch_function__(orig, None, args, kwargs)
|
| 32 |
+
|
| 33 |
+
return impl
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def wrap_type(use_c, to_patch, pattern, __torch_function__):
|
| 37 |
+
if use_c:
|
| 38 |
+
wrap_method = _wrap_method
|
| 39 |
+
else:
|
| 40 |
+
wrap_method = _py_wrap_method
|
| 41 |
+
|
| 42 |
+
all = {}
|
| 43 |
+
for t in reversed(pattern.mro()[:-1]): # skip object
|
| 44 |
+
all.update(t.__dict__)
|
| 45 |
+
|
| 46 |
+
def wrap_attr(orig):
|
| 47 |
+
return property(wrap_method(orig.__get__, __torch_function__))
|
| 48 |
+
|
| 49 |
+
for name, obj in all.items():
|
| 50 |
+
if name in (
|
| 51 |
+
"__dict__",
|
| 52 |
+
"__new__",
|
| 53 |
+
"__init__",
|
| 54 |
+
"__repr__",
|
| 55 |
+
"__weakref__",
|
| 56 |
+
"__doc__",
|
| 57 |
+
"__module__",
|
| 58 |
+
"__dir__",
|
| 59 |
+
):
|
| 60 |
+
continue
|
| 61 |
+
|
| 62 |
+
# skip things that have been overloaded
|
| 63 |
+
# things that come from object like `__eq__` still need to be patched, however.
|
| 64 |
+
if hasattr(to_patch, name) and getattr(to_patch, name) is not getattr(
|
| 65 |
+
object, name, None
|
| 66 |
+
):
|
| 67 |
+
continue
|
| 68 |
+
|
| 69 |
+
if isinstance(obj, FUNC_TYPES):
|
| 70 |
+
setattr(to_patch, name, wrap_method(obj, __torch_function__))
|
| 71 |
+
elif isinstance(obj, PROPERTY_TYPES):
|
| 72 |
+
setattr(to_patch, name, wrap_attr(obj))
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/einops/__init__.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .rearrange import rearrange
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
__all__ = ["rearrange"]
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/einops/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (244 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/einops/__pycache__/_parsing.cpython-310.pyc
ADDED
|
Binary file (9.96 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/einops/__pycache__/rearrange.cpython-310.pyc
ADDED
|
Binary file (7.23 kB). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/einops/_parsing.py
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Adapted from https://github.com/arogozhnikov/einops/blob/36c7bb16e57d6e57f8f3050f9e07abdf3f00469f/einops/parsing.py.
|
| 2 |
+
|
| 3 |
+
MIT License
|
| 4 |
+
|
| 5 |
+
Copyright (c) 2018 Alex Rogozhnikov
|
| 6 |
+
|
| 7 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 8 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 9 |
+
in the Software without restriction, including without limitation the rights
|
| 10 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 11 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 12 |
+
furnished to do so, subject to the following conditions:
|
| 13 |
+
|
| 14 |
+
The above copyright notice and this permission notice shall be included in all
|
| 15 |
+
copies or substantial portions of the Software.
|
| 16 |
+
|
| 17 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 18 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 19 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 20 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 21 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 22 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 23 |
+
SOFTWARE.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
from __future__ import annotations
|
| 27 |
+
|
| 28 |
+
import keyword
|
| 29 |
+
import warnings
|
| 30 |
+
from typing import Optional, TYPE_CHECKING, Union
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
if TYPE_CHECKING:
|
| 34 |
+
from collections.abc import Collection, Mapping
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
_ellipsis: str = "\u2026" # NB, this is a single unicode symbol. String is used as it is not a list, but can be iterated
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class AnonymousAxis:
|
| 41 |
+
"""Used by `ParsedExpression` to represent an axis with a size (> 1), but no associated identifier.
|
| 42 |
+
|
| 43 |
+
Note: Different instances of this class are not equal to each other, even if they have the same value.
|
| 44 |
+
"""
|
| 45 |
+
|
| 46 |
+
def __init__(self, value: str) -> None:
|
| 47 |
+
self.value = int(value)
|
| 48 |
+
if self.value < 1:
|
| 49 |
+
raise ValueError(
|
| 50 |
+
f"Anonymous axis should have positive length, not {self.value}"
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
def __repr__(self) -> str:
|
| 54 |
+
return f"{self.value}-axis"
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class ParsedExpression:
|
| 58 |
+
"""Structure containing information about one side of an `einops`-style pattern (e.g. 'b c (h w)')."""
|
| 59 |
+
|
| 60 |
+
def __init__(
|
| 61 |
+
self,
|
| 62 |
+
expression: str,
|
| 63 |
+
*,
|
| 64 |
+
allow_underscore: bool = False,
|
| 65 |
+
allow_duplicates: bool = False,
|
| 66 |
+
) -> None:
|
| 67 |
+
"""Parse the expression and store relevant metadata.
|
| 68 |
+
|
| 69 |
+
Args:
|
| 70 |
+
expression (str): the `einops`-pattern to parse
|
| 71 |
+
allow_underscore (bool): whether to allow axis identifier names to begin with an underscore
|
| 72 |
+
allow_duplicates (bool): whether to allow an identifier to appear more than once in the expression
|
| 73 |
+
"""
|
| 74 |
+
self.has_ellipsis: bool = False
|
| 75 |
+
self.has_ellipsis_parenthesized: Optional[bool] = None
|
| 76 |
+
self.identifiers: set[Union[str, AnonymousAxis]] = set()
|
| 77 |
+
# that's axes like 2, 3, 4 or 5. Axes with size 1 are exceptional and replaced with empty composition
|
| 78 |
+
self.has_non_unitary_anonymous_axes: bool = False
|
| 79 |
+
# composition keeps structure of composite axes, see how different corner cases are handled in tests
|
| 80 |
+
self.composition: list[Union[list[Union[str, AnonymousAxis]], str]] = []
|
| 81 |
+
if "." in expression:
|
| 82 |
+
if "..." not in expression:
|
| 83 |
+
raise ValueError(
|
| 84 |
+
"Expression may contain dots only inside ellipsis (...)"
|
| 85 |
+
)
|
| 86 |
+
if str.count(expression, "...") != 1 or str.count(expression, ".") != 3:
|
| 87 |
+
raise ValueError(
|
| 88 |
+
"Expression may contain dots only inside ellipsis (...); only one ellipsis for tensor "
|
| 89 |
+
)
|
| 90 |
+
expression = expression.replace("...", _ellipsis)
|
| 91 |
+
self.has_ellipsis = True
|
| 92 |
+
|
| 93 |
+
bracket_group: Optional[list[Union[str, AnonymousAxis]]] = None
|
| 94 |
+
|
| 95 |
+
def add_axis_name(x: str) -> None:
|
| 96 |
+
if x in self.identifiers:
|
| 97 |
+
if not (allow_underscore and x == "_") and not allow_duplicates:
|
| 98 |
+
raise ValueError(
|
| 99 |
+
f"Indexing expression contains duplicate dimension '{x}'"
|
| 100 |
+
)
|
| 101 |
+
if x == _ellipsis:
|
| 102 |
+
self.identifiers.add(_ellipsis)
|
| 103 |
+
if bracket_group is None:
|
| 104 |
+
self.composition.append(_ellipsis)
|
| 105 |
+
self.has_ellipsis_parenthesized = False
|
| 106 |
+
else:
|
| 107 |
+
bracket_group.append(_ellipsis)
|
| 108 |
+
self.has_ellipsis_parenthesized = True
|
| 109 |
+
else:
|
| 110 |
+
is_number = str.isdecimal(x)
|
| 111 |
+
if is_number and int(x) == 1:
|
| 112 |
+
# handling the case of anonymous axis of length 1
|
| 113 |
+
if bracket_group is None:
|
| 114 |
+
self.composition.append([])
|
| 115 |
+
else:
|
| 116 |
+
pass # no need to think about 1s inside parenthesis
|
| 117 |
+
return
|
| 118 |
+
is_axis_name, reason = self.check_axis_name_return_reason(
|
| 119 |
+
x, allow_underscore=allow_underscore
|
| 120 |
+
)
|
| 121 |
+
if not (is_number or is_axis_name):
|
| 122 |
+
raise ValueError(f"Invalid axis identifier: {x}\n{reason}")
|
| 123 |
+
axis_name: Union[str, AnonymousAxis] = (
|
| 124 |
+
AnonymousAxis(x) if is_number else x
|
| 125 |
+
)
|
| 126 |
+
self.identifiers.add(axis_name)
|
| 127 |
+
if is_number:
|
| 128 |
+
self.has_non_unitary_anonymous_axes = True
|
| 129 |
+
if bracket_group is None:
|
| 130 |
+
self.composition.append([axis_name])
|
| 131 |
+
else:
|
| 132 |
+
bracket_group.append(axis_name)
|
| 133 |
+
|
| 134 |
+
current_identifier = None
|
| 135 |
+
for char in expression:
|
| 136 |
+
if char in "() ":
|
| 137 |
+
if current_identifier is not None:
|
| 138 |
+
add_axis_name(current_identifier)
|
| 139 |
+
current_identifier = None
|
| 140 |
+
if char == "(":
|
| 141 |
+
if bracket_group is not None:
|
| 142 |
+
raise ValueError(
|
| 143 |
+
"Axis composition is one-level (brackets inside brackets not allowed)"
|
| 144 |
+
)
|
| 145 |
+
bracket_group = []
|
| 146 |
+
elif char == ")":
|
| 147 |
+
if bracket_group is None:
|
| 148 |
+
raise ValueError("Brackets are not balanced")
|
| 149 |
+
self.composition.append(bracket_group)
|
| 150 |
+
bracket_group = None
|
| 151 |
+
elif str.isalnum(char) or char in ["_", _ellipsis]:
|
| 152 |
+
if current_identifier is None:
|
| 153 |
+
current_identifier = char
|
| 154 |
+
else:
|
| 155 |
+
current_identifier += char
|
| 156 |
+
else:
|
| 157 |
+
raise ValueError(f"Unknown character '{char}'")
|
| 158 |
+
|
| 159 |
+
if bracket_group is not None:
|
| 160 |
+
raise ValueError(f"Imbalanced parentheses in expression: '{expression}'")
|
| 161 |
+
if current_identifier is not None:
|
| 162 |
+
add_axis_name(current_identifier)
|
| 163 |
+
|
| 164 |
+
@staticmethod
|
| 165 |
+
def check_axis_name_return_reason(
|
| 166 |
+
name: str, allow_underscore: bool = False
|
| 167 |
+
) -> tuple[bool, str]:
|
| 168 |
+
"""Check if the given axis name is valid, and a message explaining why if not.
|
| 169 |
+
|
| 170 |
+
Valid axes names are python identifiers except keywords, and should not start or end with an underscore.
|
| 171 |
+
|
| 172 |
+
Args:
|
| 173 |
+
name (str): the axis name to check
|
| 174 |
+
allow_underscore (bool): whether axis names are allowed to start with an underscore
|
| 175 |
+
|
| 176 |
+
Returns:
|
| 177 |
+
tuple[bool, str]: whether the axis name is valid, a message explaining why if not
|
| 178 |
+
"""
|
| 179 |
+
if not str.isidentifier(name):
|
| 180 |
+
return False, "not a valid python identifier"
|
| 181 |
+
elif name[0] == "_" or name[-1] == "_":
|
| 182 |
+
if name == "_" and allow_underscore:
|
| 183 |
+
return True, ""
|
| 184 |
+
return False, "axis name should should not start or end with underscore"
|
| 185 |
+
else:
|
| 186 |
+
if keyword.iskeyword(name):
|
| 187 |
+
warnings.warn(
|
| 188 |
+
f"It is discouraged to use axes names that are keywords: {name}",
|
| 189 |
+
RuntimeWarning,
|
| 190 |
+
)
|
| 191 |
+
if name in ["axis"]:
|
| 192 |
+
warnings.warn(
|
| 193 |
+
"It is discouraged to use 'axis' as an axis name and will raise an error in future",
|
| 194 |
+
FutureWarning,
|
| 195 |
+
)
|
| 196 |
+
return True, ""
|
| 197 |
+
|
| 198 |
+
@staticmethod
|
| 199 |
+
def check_axis_name(name: str) -> bool:
|
| 200 |
+
"""Check if the name is a valid axis name.
|
| 201 |
+
|
| 202 |
+
Args:
|
| 203 |
+
name (str): the axis name to check
|
| 204 |
+
|
| 205 |
+
Returns:
|
| 206 |
+
bool: whether the axis name is valid
|
| 207 |
+
"""
|
| 208 |
+
is_valid, _ = ParsedExpression.check_axis_name_return_reason(name)
|
| 209 |
+
return is_valid
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
def parse_pattern(
|
| 213 |
+
pattern: str, axes_lengths: Mapping[str, int]
|
| 214 |
+
) -> tuple[ParsedExpression, ParsedExpression]:
|
| 215 |
+
"""Parse an `einops`-style pattern into a left-hand side and right-hand side `ParsedExpression` object.
|
| 216 |
+
|
| 217 |
+
Args:
|
| 218 |
+
pattern (str): the `einops`-style rearrangement pattern
|
| 219 |
+
axes_lengths (Mapping[str, int]): any additional length specifications for dimensions
|
| 220 |
+
|
| 221 |
+
Returns:
|
| 222 |
+
tuple[ParsedExpression, ParsedExpression]: a tuple containing the left-hand side and right-hand side expressions
|
| 223 |
+
"""
|
| 224 |
+
# adapted from einops.einops._prepare_transformation_recipe
|
| 225 |
+
# https://github.com/arogozhnikov/einops/blob/230ac1526c1f42c9e1f7373912c7f8047496df11/einops/einops.py
|
| 226 |
+
try:
|
| 227 |
+
left_str, right_str = pattern.split("->")
|
| 228 |
+
except ValueError:
|
| 229 |
+
raise ValueError("Pattern must contain a single '->' separator") from None
|
| 230 |
+
|
| 231 |
+
if _ellipsis in axes_lengths:
|
| 232 |
+
raise ValueError(f"'{_ellipsis}' is not an allowed axis identifier")
|
| 233 |
+
|
| 234 |
+
left = ParsedExpression(left_str)
|
| 235 |
+
right = ParsedExpression(right_str)
|
| 236 |
+
|
| 237 |
+
if not left.has_ellipsis and right.has_ellipsis:
|
| 238 |
+
raise ValueError(
|
| 239 |
+
f"Ellipsis found in right side, but not left side of a pattern {pattern}"
|
| 240 |
+
)
|
| 241 |
+
if left.has_ellipsis and left.has_ellipsis_parenthesized:
|
| 242 |
+
raise ValueError(
|
| 243 |
+
f"Ellipsis is parenthesis in the left side is not allowed: {pattern}"
|
| 244 |
+
)
|
| 245 |
+
|
| 246 |
+
return left, right
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
def validate_rearrange_expressions(
|
| 250 |
+
left: ParsedExpression, right: ParsedExpression, axes_lengths: Mapping[str, int]
|
| 251 |
+
) -> None:
|
| 252 |
+
"""Perform expression validations that are specific to the `rearrange` operation.
|
| 253 |
+
|
| 254 |
+
Args:
|
| 255 |
+
left (ParsedExpression): left-hand side expression
|
| 256 |
+
right (ParsedExpression): right-hand side expression
|
| 257 |
+
axes_lengths (Mapping[str, int]): any additional length specifications for dimensions
|
| 258 |
+
"""
|
| 259 |
+
for length in axes_lengths.values():
|
| 260 |
+
if (length_type := type(length)) is not int:
|
| 261 |
+
raise TypeError(
|
| 262 |
+
f"rearrange axis lengths must be integers, got: {length_type}"
|
| 263 |
+
)
|
| 264 |
+
|
| 265 |
+
if left.has_non_unitary_anonymous_axes or right.has_non_unitary_anonymous_axes:
|
| 266 |
+
raise ValueError("rearrange only supports unnamed axes of size 1")
|
| 267 |
+
|
| 268 |
+
difference = set.symmetric_difference(left.identifiers, right.identifiers)
|
| 269 |
+
if len(difference) > 0:
|
| 270 |
+
raise ValueError(
|
| 271 |
+
f"Identifiers only on one side of rearrange expression (should be on both): {difference}"
|
| 272 |
+
)
|
| 273 |
+
|
| 274 |
+
unmatched_axes = axes_lengths.keys() - left.identifiers
|
| 275 |
+
if len(unmatched_axes) > 0:
|
| 276 |
+
raise ValueError(
|
| 277 |
+
f"Identifiers not found in rearrange expression: {unmatched_axes}"
|
| 278 |
+
)
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
def comma_separate(collection: Collection[Union[str, Collection[str]]]) -> str:
|
| 282 |
+
"""Convert a collection of strings representing first class dims into a comma-separated string.
|
| 283 |
+
|
| 284 |
+
Args:
|
| 285 |
+
collection (Collection[Union[str, Collection[str]]]): the collection of strings to convert
|
| 286 |
+
|
| 287 |
+
Returns:
|
| 288 |
+
str: the comma-separated string
|
| 289 |
+
|
| 290 |
+
Examples:
|
| 291 |
+
>>> comma_separate(("d0",))
|
| 292 |
+
'd0'
|
| 293 |
+
|
| 294 |
+
>>> comma_separate(("d0", "d1", "d2", "d3"))
|
| 295 |
+
'd0, d1, d2, d3'
|
| 296 |
+
|
| 297 |
+
>>> comma_separate([("d1", "d4")])
|
| 298 |
+
'(d1, d4)'
|
| 299 |
+
|
| 300 |
+
>>> comma_separate([("d0",), (), ("d1",), ("d2",), ("d3", "d4")])
|
| 301 |
+
'(d0,), (), (d1,), (d2,), (d3, d4)'
|
| 302 |
+
"""
|
| 303 |
+
return ", ".join(
|
| 304 |
+
item
|
| 305 |
+
if isinstance(item, str)
|
| 306 |
+
else f"({comma_separate(item)}{',' if len(item) == 1 else ''})"
|
| 307 |
+
for item in collection
|
| 308 |
+
)
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/einops/rearrange.py
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import functools
|
| 4 |
+
from typing import Callable, TYPE_CHECKING, Union
|
| 5 |
+
|
| 6 |
+
import torch
|
| 7 |
+
from functorch._C import dim as _C
|
| 8 |
+
|
| 9 |
+
from ._parsing import (
|
| 10 |
+
_ellipsis,
|
| 11 |
+
AnonymousAxis,
|
| 12 |
+
comma_separate,
|
| 13 |
+
parse_pattern,
|
| 14 |
+
validate_rearrange_expressions,
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
if TYPE_CHECKING:
|
| 19 |
+
from collections.abc import Sequence
|
| 20 |
+
|
| 21 |
+
__all__ = ["rearrange"]
|
| 22 |
+
|
| 23 |
+
dims = _C.dims
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
@functools.lru_cache(256)
|
| 27 |
+
def _create_rearrange_callable(
|
| 28 |
+
tensor_ndim: int, pattern: str, **axes_lengths: int
|
| 29 |
+
) -> Callable[[torch.Tensor], torch.Tensor]:
|
| 30 |
+
r"""Translate an `einops`-style pattern into a callable that performs the rearrange using first-class dimensions.
|
| 31 |
+
|
| 32 |
+
Since the an equivalent result is computed for tensors with the same number of dimensions, with the same pattern and
|
| 33 |
+
specified axes lengths, this function can be memoized.
|
| 34 |
+
|
| 35 |
+
Args:
|
| 36 |
+
tensor_ndim (int): the number of dimensions in the tensor to rearrange
|
| 37 |
+
pattern (str): the `einops`-style rearrangement pattern
|
| 38 |
+
axes_lengths (int): any additional length specifications for dimensions
|
| 39 |
+
|
| 40 |
+
Returns:
|
| 41 |
+
Callable[[torch.Tensor], torch.Tensor]: a callable that performs the rearrangement
|
| 42 |
+
"""
|
| 43 |
+
left, right = parse_pattern(pattern, axes_lengths)
|
| 44 |
+
validate_rearrange_expressions(left, right, axes_lengths)
|
| 45 |
+
|
| 46 |
+
n_anon_dims = sum(not dim for dim in left.composition)
|
| 47 |
+
if left.has_ellipsis:
|
| 48 |
+
n_ellipsis_dims = tensor_ndim - (len(left.composition) - 1)
|
| 49 |
+
n_named_dims = len(left.identifiers) - 1
|
| 50 |
+
|
| 51 |
+
if (pattern_ndim := n_anon_dims + n_named_dims) > tensor_ndim:
|
| 52 |
+
raise ValueError(
|
| 53 |
+
f"Number of dimensions in pattern ({pattern_ndim}) must be less than or equal to the number of "
|
| 54 |
+
f"dimensions in the tensor ({tensor_ndim})"
|
| 55 |
+
)
|
| 56 |
+
else:
|
| 57 |
+
n_ellipsis_dims = 0
|
| 58 |
+
n_named_dims = len(left.identifiers)
|
| 59 |
+
|
| 60 |
+
if (pattern_ndim := len(left.composition)) != tensor_ndim:
|
| 61 |
+
raise ValueError(
|
| 62 |
+
f"Number of dimensions in pattern ({pattern_ndim}) must be equal to the number of dimensions in "
|
| 63 |
+
f"the tensor ({tensor_ndim})"
|
| 64 |
+
)
|
| 65 |
+
n_dims = n_named_dims + n_ellipsis_dims + n_anon_dims
|
| 66 |
+
|
| 67 |
+
if n_dims == 0:
|
| 68 |
+
# an identity rearrangement on a 0-dimension tensor
|
| 69 |
+
return lambda tensor: tensor
|
| 70 |
+
|
| 71 |
+
first_class_dims: tuple[str, ...] = tuple(f"d{i}" for i in range(n_dims))
|
| 72 |
+
identifier_dim_map: dict[Union[str, AnonymousAxis], tuple[str, ...]] = {}
|
| 73 |
+
anon_axes: list[AnonymousAxis] = []
|
| 74 |
+
|
| 75 |
+
# map the left-hand side identifiers to strings representing first class dims
|
| 76 |
+
dims_i = 0
|
| 77 |
+
for dimension in left.composition:
|
| 78 |
+
if isinstance(dimension, list):
|
| 79 |
+
for identifier in dimension:
|
| 80 |
+
# non-unitary anon axes are not allowed in rearrange & unitary anon axes are represented as empty lists
|
| 81 |
+
assert isinstance(identifier, str)
|
| 82 |
+
identifier_dim_map[identifier] = (first_class_dims[dims_i],)
|
| 83 |
+
dims_i += 1
|
| 84 |
+
if not dimension:
|
| 85 |
+
# unitary anonymous axis
|
| 86 |
+
anon_axis = AnonymousAxis("1")
|
| 87 |
+
identifier_dim_map[anon_axis] = (first_class_dims[dims_i],)
|
| 88 |
+
anon_axes.append(anon_axis)
|
| 89 |
+
dimension.append(anon_axis)
|
| 90 |
+
dims_i += 1
|
| 91 |
+
elif dimension == _ellipsis:
|
| 92 |
+
identifier = _ellipsis
|
| 93 |
+
identifier_dim_map[identifier] = tuple(
|
| 94 |
+
first_class_dims[dims_i + j] for j in range(n_ellipsis_dims)
|
| 95 |
+
)
|
| 96 |
+
dims_i += n_ellipsis_dims
|
| 97 |
+
else:
|
| 98 |
+
raise ValueError(f"Unexpected dimension: {dimension}")
|
| 99 |
+
|
| 100 |
+
def composition_to_dims(
|
| 101 |
+
composition: Sequence[Union[list[Union[str, AnonymousAxis]], str]],
|
| 102 |
+
) -> list[Union[str, tuple[str, ...]]]:
|
| 103 |
+
"""Convert a `ParsedExpression.composition` into a `Tensor.__getitem__` index of strings representing first
|
| 104 |
+
class dims."""
|
| 105 |
+
dim_composition: list[Union[str, tuple[str, ...]]] = []
|
| 106 |
+
for dimension in composition:
|
| 107 |
+
if isinstance(dimension, list):
|
| 108 |
+
dim_composition.append(
|
| 109 |
+
tuple(
|
| 110 |
+
dim
|
| 111 |
+
for identifier in dimension
|
| 112 |
+
for dim in identifier_dim_map[identifier]
|
| 113 |
+
)
|
| 114 |
+
)
|
| 115 |
+
elif dimension == _ellipsis:
|
| 116 |
+
dim_composition.extend(identifier_dim_map[_ellipsis])
|
| 117 |
+
else:
|
| 118 |
+
raise ValueError(f"Unexpected dimension: {dimension}")
|
| 119 |
+
return dim_composition
|
| 120 |
+
|
| 121 |
+
left_dims = composition_to_dims(left.composition)
|
| 122 |
+
right_dims = composition_to_dims(right.composition)
|
| 123 |
+
anon_dims = tuple(identifier_dim_map[axis][0] for axis in anon_axes)
|
| 124 |
+
specified_lengths = tuple(
|
| 125 |
+
(identifier_dim_map[axis][0], length) for axis, length in axes_lengths.items()
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
custom_rearrange_callable_name = "do_rearrange"
|
| 129 |
+
custom_rearrange_callable_code = (
|
| 130 |
+
(
|
| 131 |
+
f"def {custom_rearrange_callable_name}(tensor):\n"
|
| 132 |
+
f" {comma_separate(first_class_dims)} = dims({n_dims})\n"
|
| 133 |
+
)
|
| 134 |
+
+ (
|
| 135 |
+
"".join(
|
| 136 |
+
f" {dim}.size = {length}\n" for (dim, length) in specified_lengths
|
| 137 |
+
)
|
| 138 |
+
if specified_lengths
|
| 139 |
+
else ""
|
| 140 |
+
)
|
| 141 |
+
+ f" tensor = tensor[{comma_separate(left_dims)}].order({comma_separate(right_dims)})\n"
|
| 142 |
+
+ (
|
| 143 |
+
f" return tensor.sum({comma_separate([anon_dims])}, keepdim=False)\n"
|
| 144 |
+
if anon_dims
|
| 145 |
+
else " return tensor\n"
|
| 146 |
+
)
|
| 147 |
+
)
|
| 148 |
+
|
| 149 |
+
exec(custom_rearrange_callable_code)
|
| 150 |
+
return locals()[custom_rearrange_callable_name]
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def rearrange(
|
| 154 |
+
tensor: Union[torch.Tensor, list[torch.Tensor], tuple[torch.Tensor, ...]],
|
| 155 |
+
pattern: str,
|
| 156 |
+
**axes_lengths: int,
|
| 157 |
+
) -> torch.Tensor:
|
| 158 |
+
r"""A native implementation of `einops.rearrange`, a reader-friendly smart element reordering for multidimensional
|
| 159 |
+
tensors. This operation includes functionality of transpose (axes permutation), reshape (view), squeeze, unsqueeze,
|
| 160 |
+
stack, concatenate and other operations.
|
| 161 |
+
|
| 162 |
+
See: https://einops.rocks/api/rearrange/
|
| 163 |
+
|
| 164 |
+
Args:
|
| 165 |
+
tensor (Tensor or sequence of Tensor): the tensor(s) to rearrange
|
| 166 |
+
pattern (str): the rearrangement pattern
|
| 167 |
+
axes_lengths (int): any additional length specifications for dimensions
|
| 168 |
+
|
| 169 |
+
Returns:
|
| 170 |
+
Tensor: the rearranged tensor
|
| 171 |
+
|
| 172 |
+
Examples:
|
| 173 |
+
>>> # suppose we have a set of 32 images in "h w c" format (height-width-channel)
|
| 174 |
+
>>> images = torch.randn((32, 30, 40, 3))
|
| 175 |
+
|
| 176 |
+
>>> # stack along first (batch) axis, output is a single array
|
| 177 |
+
>>> rearrange(images, "b h w c -> b h w c").shape
|
| 178 |
+
torch.Size([32, 30, 40, 3])
|
| 179 |
+
|
| 180 |
+
>>> # concatenate images along height (vertical axis), 960 = 32 * 30
|
| 181 |
+
>>> rearrange(images, "b h w c -> (b h) w c").shape
|
| 182 |
+
torch.Size([960, 40, 3])
|
| 183 |
+
|
| 184 |
+
>>> # concatenated images along horizontal axis, 1280 = 32 * 40
|
| 185 |
+
>>> rearrange(images, "b h w c -> h (b w) c").shape
|
| 186 |
+
torch.Size([30, 1280, 3])
|
| 187 |
+
|
| 188 |
+
>>> # reordered axes to "b c h w" format for deep learning
|
| 189 |
+
>>> rearrange(images, "b h w c -> b c h w").shape
|
| 190 |
+
torch.Size([32, 3, 30, 40])
|
| 191 |
+
|
| 192 |
+
>>> # flattened each image into a vector, 3600 = 30 * 40 * 3
|
| 193 |
+
>>> rearrange(images, "b h w c -> b (c h w)").shape
|
| 194 |
+
torch.Size([32, 3600])
|
| 195 |
+
|
| 196 |
+
>>> # split each image into 4 smaller (top-left, top-right, bottom-left, bottom-right), 128 = 32 * 2 * 2
|
| 197 |
+
>>> rearrange(images, "b (h1 h) (w1 w) c -> (b h1 w1) h w c", h1=2, w1=2).shape
|
| 198 |
+
torch.Size([128, 15, 20, 3])
|
| 199 |
+
|
| 200 |
+
>>> # space-to-depth operation
|
| 201 |
+
>>> rearrange(images, "b (h h1) (w w1) c -> b h w (c h1 w1)", h1=2, w1=2).shape
|
| 202 |
+
torch.Size([32, 15, 20, 12])
|
| 203 |
+
"""
|
| 204 |
+
if not isinstance(tensor, torch.Tensor):
|
| 205 |
+
tensor = torch.stack(tensor)
|
| 206 |
+
|
| 207 |
+
rearrange_callable = _create_rearrange_callable(
|
| 208 |
+
tensor.ndim, pattern, **axes_lengths
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
return rearrange_callable(tensor)
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/experimental/__init__.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PyTorch forward-mode is not mature yet
|
| 2 |
+
from functorch import functionalize
|
| 3 |
+
from torch._functorch.apis import chunk_vmap
|
| 4 |
+
from torch._functorch.batch_norm_replacement import replace_all_batch_norm_modules_
|
| 5 |
+
from torch._functorch.eager_transforms import hessian, jacfwd, jvp
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/experimental/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (490 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/experimental/__pycache__/control_flow.cpython-310.pyc
ADDED
|
Binary file (339 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/experimental/__pycache__/ops.cpython-310.pyc
ADDED
|
Binary file (245 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/experimental/control_flow.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from torch import cond # noqa: F401
|
| 2 |
+
from torch._higher_order_ops.map import ( # noqa: F401
|
| 3 |
+
_stack_pytree,
|
| 4 |
+
_unstack_pytree,
|
| 5 |
+
map,
|
| 6 |
+
)
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/functorch/experimental/ops.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from torch._ops import HigherOrderOperator # noqa: F401
|
data/tefig/envs/olmes-e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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/olmo_core/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (183 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/olmo_core/__pycache__/aliases.cpython-310.pyc
ADDED
|
Binary file (321 Bytes). View file
|
|
|
data/tefig/envs/olmes-eval/lib/python3.10/site-packages/olmo_core/__pycache__/config.cpython-310.pyc
ADDED
|
Binary file (12.4 kB). View file
|
|
|