haliax 1.4.dev408__tar.gz → 1.4.dev409__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {haliax-1.4.dev408 → haliax-1.4.dev409}/.agents/projects/api_parity.md +6 -6
- {haliax-1.4.dev408 → haliax-1.4.dev409}/PKG-INFO +1 -1
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/api.md +6 -0
- haliax-1.4.dev409/src/haliax/__about__.py +1 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/__init__.py +32 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/ops.py +38 -0
- haliax-1.4.dev409/tests/test_bitwise_ops.py +45 -0
- haliax-1.4.dev408/src/haliax/__about__.py +0 -1
- {haliax-1.4.dev408 → haliax-1.4.dev409}/.coveragerc +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/.flake8 +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/.github/workflows/publish_dev.yaml +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/.github/workflows/run_pre_commit.yaml +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/.github/workflows/run_quick_levanter_tests.yaml +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/.github/workflows/run_tests.yaml +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/.gitignore +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/.playbooks/add-types.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/.playbooks/wrap-non-named.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/.pre-commit-config.yaml +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/.readthedocs.yaml +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/AGENTS.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/CONTRIBUTING.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/LICENSE +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/README.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/broadcasting.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/cheatsheet.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/css/material.css +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/css/mkdocstrings.css +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/faq.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/figures/data_parallel_mesh.png +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/figures/data_parallel_mesh_replicated.png +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/figures/device_mesh_1d.png +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/figures/device_mesh_1d_zero.png +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/figures/device_mesh_2d.png +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/figures/device_mesh_2d_batch_partitioned.png +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/figures/device_mesh_2d_data_replicated.png +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/figures/device_mesh_2d_data_replicated_mlp_partitioned.png +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/figures/device_mesh_2d_intermediate_fully_partitioned.png +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/figures/device_mesh_2d_zero.png +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/fp8.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/index.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/indexing.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/matmul.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/nn.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/partitioning.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/primer.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/rearrange.ipynb +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/rearrange.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/requirements.txt +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/scan.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/state-dict.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/tutorial.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/typing.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/docs/vmap.md +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/mkdocs.yml +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/pyproject.toml +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/_src/__init__.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/_src/compile_utils.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/_src/dot.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/_src/einsum.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/_src/fp8.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/_src/parsing.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/_src/rearrange.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/_src/scan.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/_src/state_dict.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/_src/util.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/axis.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/core.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/debug.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/field.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/haxtyping.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/hof.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/jax_utils.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/nn/__init__.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/nn/activations.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/nn/attention.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/nn/conv.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/nn/dropout.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/nn/embedding.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/nn/linear.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/nn/loss.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/nn/mlp.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/nn/normalization.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/nn/pool.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/nn/scan.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/partitioning.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/quantization.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/random.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/specialized_fns.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/state_dict.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/tree_util.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/types.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/util.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/src/haliax/wrap.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/core_test.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_attention.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_axis.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_conv.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_debug.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_dot.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_dtype_typing.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_einsum.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_field.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_fp8.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_hof.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_int8.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_moe_linear.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_namedarray_typing.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_nan_reductions.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_nn.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_ops.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_parsing.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_partitioning.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_pool.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_random.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_rearrange.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_scan.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_scatter_gather.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_specialized_fns.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_state_dict.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_tree_util.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_utils.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/tests/test_visualize_sharding.py +0 -0
- {haliax-1.4.dev408 → haliax-1.4.dev409}/uv.lock +0 -0
|
@@ -18,10 +18,10 @@ APIs that don't translate well to named tensors are intentionally omitted here.
|
|
|
18
18
|
- [ ] `atan2`
|
|
19
19
|
- [ ] `average`
|
|
20
20
|
- [ ] `bartlett`
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
23
|
-
- [
|
|
24
|
-
- [
|
|
21
|
+
- [x] `bitwise_count`
|
|
22
|
+
- [x] `bitwise_invert`
|
|
23
|
+
- [x] `bitwise_left_shift`
|
|
24
|
+
- [x] `bitwise_right_shift`
|
|
25
25
|
- [ ] `blackman`
|
|
26
26
|
- [ ] `block`
|
|
27
27
|
- [ ] `broadcast_shapes`
|
|
@@ -109,7 +109,7 @@ APIs that don't translate well to named tensors are intentionally omitted here.
|
|
|
109
109
|
- [x] `nanvar`
|
|
110
110
|
- [ ] `nonzero`
|
|
111
111
|
- [ ] `ogrid`
|
|
112
|
-
- [
|
|
112
|
+
- [x] `packbits`
|
|
113
113
|
- [ ] `partition`
|
|
114
114
|
- [ ] `percentile`
|
|
115
115
|
- [ ] `permute_dims`
|
|
@@ -152,7 +152,7 @@ APIs that don't translate well to named tensors are intentionally omitted here.
|
|
|
152
152
|
- [ ] `triu_indices`
|
|
153
153
|
- [ ] `triu_indices_from`
|
|
154
154
|
- [ ] `union1d`
|
|
155
|
-
- [
|
|
155
|
+
- [x] `unpackbits`
|
|
156
156
|
- [ ] `unravel_index`
|
|
157
157
|
- [ ] `unstack`
|
|
158
158
|
- [ ] `unwrap`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: haliax
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.dev409
|
|
4
4
|
Summary: Named Tensors for Legible Deep Learning in JAX
|
|
5
5
|
Project-URL: Homepage, https://github.com/stanford-crfm/haliax
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/stanford-crfm/haliax/issues/
|
|
@@ -176,6 +176,8 @@ These are all more or less directly from JAX's NumPy API.
|
|
|
176
176
|
::: haliax.arctan
|
|
177
177
|
::: haliax.arctanh
|
|
178
178
|
::: haliax.around
|
|
179
|
+
::: haliax.bitwise_count
|
|
180
|
+
::: haliax.bitwise_invert
|
|
179
181
|
::: haliax.bitwise_not
|
|
180
182
|
::: haliax.cbrt
|
|
181
183
|
::: haliax.ceil
|
|
@@ -233,7 +235,9 @@ These are all more or less directly from JAX's NumPy API.
|
|
|
233
235
|
::: haliax.add
|
|
234
236
|
::: haliax.arctan2
|
|
235
237
|
::: haliax.bitwise_and
|
|
238
|
+
::: haliax.bitwise_left_shift
|
|
236
239
|
::: haliax.bitwise_or
|
|
240
|
+
::: haliax.bitwise_right_shift
|
|
237
241
|
::: haliax.bitwise_xor
|
|
238
242
|
::: haliax.divide
|
|
239
243
|
::: haliax.divmod
|
|
@@ -270,6 +274,8 @@ These are all more or less directly from JAX's NumPy API.
|
|
|
270
274
|
|
|
271
275
|
::: haliax.bincount
|
|
272
276
|
::: haliax.clip
|
|
277
|
+
::: haliax.packbits
|
|
278
|
+
::: haliax.unpackbits
|
|
273
279
|
::: haliax.isclose
|
|
274
280
|
::: haliax.allclose
|
|
275
281
|
::: haliax.array_equal
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.4.dev409"
|
|
@@ -83,6 +83,8 @@ from .ops import (
|
|
|
83
83
|
unique_counts,
|
|
84
84
|
unique_inverse,
|
|
85
85
|
unique_all,
|
|
86
|
+
packbits,
|
|
87
|
+
unpackbits,
|
|
86
88
|
searchsorted,
|
|
87
89
|
bincount,
|
|
88
90
|
where,
|
|
@@ -337,6 +339,14 @@ def around(a: A) -> A:
|
|
|
337
339
|
return wrap_elemwise_unary(jnp.around, a)
|
|
338
340
|
|
|
339
341
|
|
|
342
|
+
def bitwise_count(a: A) -> A:
|
|
343
|
+
return wrap_elemwise_unary(jnp.bitwise_count, a)
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
def bitwise_invert(a: A) -> A:
|
|
347
|
+
return wrap_elemwise_unary(jnp.bitwise_invert, a)
|
|
348
|
+
|
|
349
|
+
|
|
340
350
|
def bitwise_not(a: A) -> A:
|
|
341
351
|
return wrap_elemwise_unary(jnp.bitwise_not, a)
|
|
342
352
|
|
|
@@ -816,6 +826,14 @@ def bitwise_and(x1: NamedOrNumeric, x2: NamedOrNumeric, /) -> NamedOrNumeric:
|
|
|
816
826
|
return jnp.bitwise_and(x1, x2) # type: ignore
|
|
817
827
|
|
|
818
828
|
|
|
829
|
+
@wrap_elemwise_binary
|
|
830
|
+
def bitwise_left_shift(x1: NamedOrNumeric, x2: NamedOrNumeric, /) -> NamedOrNumeric:
|
|
831
|
+
"""
|
|
832
|
+
Named version of [jax.numpy.bitwise_left_shift](https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.bitwise_left_shift.html)
|
|
833
|
+
"""
|
|
834
|
+
return jnp.bitwise_left_shift(x1, x2) # type: ignore
|
|
835
|
+
|
|
836
|
+
|
|
819
837
|
@wrap_elemwise_binary
|
|
820
838
|
def bitwise_or(x1: NamedOrNumeric, x2: NamedOrNumeric, /) -> NamedOrNumeric:
|
|
821
839
|
"""
|
|
@@ -824,6 +842,14 @@ def bitwise_or(x1: NamedOrNumeric, x2: NamedOrNumeric, /) -> NamedOrNumeric:
|
|
|
824
842
|
return jnp.bitwise_or(x1, x2) # type: ignore
|
|
825
843
|
|
|
826
844
|
|
|
845
|
+
@wrap_elemwise_binary
|
|
846
|
+
def bitwise_right_shift(x1: NamedOrNumeric, x2: NamedOrNumeric, /) -> NamedOrNumeric:
|
|
847
|
+
"""
|
|
848
|
+
Named version of [jax.numpy.bitwise_right_shift](https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.bitwise_right_shift.html)
|
|
849
|
+
"""
|
|
850
|
+
return jnp.bitwise_right_shift(x1, x2) # type: ignore
|
|
851
|
+
|
|
852
|
+
|
|
827
853
|
@wrap_elemwise_binary
|
|
828
854
|
def bitwise_xor(x1: NamedOrNumeric, x2: NamedOrNumeric, /) -> NamedOrNumeric:
|
|
829
855
|
"""
|
|
@@ -1080,6 +1106,8 @@ __all__ = [
|
|
|
1080
1106
|
"arctan",
|
|
1081
1107
|
"arctanh",
|
|
1082
1108
|
"around",
|
|
1109
|
+
"bitwise_count",
|
|
1110
|
+
"bitwise_invert",
|
|
1083
1111
|
"bitwise_not",
|
|
1084
1112
|
"cbrt",
|
|
1085
1113
|
"ceil",
|
|
@@ -1171,6 +1199,8 @@ __all__ = [
|
|
|
1171
1199
|
"unique_counts",
|
|
1172
1200
|
"unique_inverse",
|
|
1173
1201
|
"unique_all",
|
|
1202
|
+
"packbits",
|
|
1203
|
+
"unpackbits",
|
|
1174
1204
|
"searchsorted",
|
|
1175
1205
|
"bincount",
|
|
1176
1206
|
"clip",
|
|
@@ -1179,7 +1209,9 @@ __all__ = [
|
|
|
1179
1209
|
"add",
|
|
1180
1210
|
"arctan2",
|
|
1181
1211
|
"bitwise_and",
|
|
1212
|
+
"bitwise_left_shift",
|
|
1182
1213
|
"bitwise_or",
|
|
1214
|
+
"bitwise_right_shift",
|
|
1183
1215
|
"bitwise_xor",
|
|
1184
1216
|
"divide",
|
|
1185
1217
|
"divmod",
|
|
@@ -508,6 +508,42 @@ def bincount(
|
|
|
508
508
|
return NamedArray(result, (Counts,))
|
|
509
509
|
|
|
510
510
|
|
|
511
|
+
def packbits(a: NamedArray, axis: AxisSelector, *, bitorder: str = "big") -> NamedArray:
|
|
512
|
+
"""Named version of `jax.numpy.packbits`."""
|
|
513
|
+
|
|
514
|
+
axis_index = a.axis_indices(axis)
|
|
515
|
+
if not isinstance(axis_index, int):
|
|
516
|
+
raise ValueError("packbits only supports a single existing axis")
|
|
517
|
+
|
|
518
|
+
result = jnp.packbits(a.array, axis=axis_index, bitorder=bitorder)
|
|
519
|
+
old_axis = a.axes[axis_index]
|
|
520
|
+
new_size = (old_axis.size + 7) // 8
|
|
521
|
+
new_axis = old_axis.resize(new_size)
|
|
522
|
+
new_axes = a.axes[:axis_index] + (new_axis,) + a.axes[axis_index + 1 :]
|
|
523
|
+
return NamedArray(result, new_axes)
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
def unpackbits(
|
|
527
|
+
a: NamedArray,
|
|
528
|
+
axis: AxisSelector,
|
|
529
|
+
*,
|
|
530
|
+
count: int | None = None,
|
|
531
|
+
bitorder: str = "big",
|
|
532
|
+
) -> NamedArray:
|
|
533
|
+
"""Named version of `jax.numpy.unpackbits`."""
|
|
534
|
+
|
|
535
|
+
axis_index = a.axis_indices(axis)
|
|
536
|
+
if not isinstance(axis_index, int):
|
|
537
|
+
raise ValueError("unpackbits only supports a single existing axis")
|
|
538
|
+
|
|
539
|
+
result = jnp.unpackbits(a.array, axis=axis_index, count=count, bitorder=bitorder)
|
|
540
|
+
old_axis = a.axes[axis_index]
|
|
541
|
+
new_size = count if count is not None else old_axis.size * 8
|
|
542
|
+
new_axis = old_axis.resize(new_size)
|
|
543
|
+
new_axes = a.axes[:axis_index] + (new_axis,) + a.axes[axis_index + 1 :]
|
|
544
|
+
return NamedArray(result, new_axes)
|
|
545
|
+
|
|
546
|
+
|
|
511
547
|
__all__ = [
|
|
512
548
|
"trace",
|
|
513
549
|
"where",
|
|
@@ -517,6 +553,8 @@ __all__ = [
|
|
|
517
553
|
"pad_left",
|
|
518
554
|
"pad",
|
|
519
555
|
"clip",
|
|
556
|
+
"packbits",
|
|
557
|
+
"unpackbits",
|
|
520
558
|
"unique",
|
|
521
559
|
"unique_values",
|
|
522
560
|
"unique_counts",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import jax.numpy as jnp
|
|
2
|
+
import haliax as hax
|
|
3
|
+
from haliax import Axis
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_bitwise_count_invert():
|
|
7
|
+
A = Axis("A", 4)
|
|
8
|
+
x = hax.named(jnp.array([0, 1, 2, 3], dtype=jnp.uint8), (A,))
|
|
9
|
+
|
|
10
|
+
inv = hax.bitwise_invert(x)
|
|
11
|
+
assert jnp.all(inv.array == jnp.bitwise_invert(x.array))
|
|
12
|
+
|
|
13
|
+
cnt = hax.bitwise_count(x)
|
|
14
|
+
assert jnp.all(cnt.array == jnp.bitwise_count(x.array))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_bitwise_shift():
|
|
18
|
+
A = Axis("A", 4)
|
|
19
|
+
x = hax.named(jnp.array([1, 2, 3, 4], dtype=jnp.int32), (A,))
|
|
20
|
+
shift = hax.named(jnp.array([1, 1, 1, 1], dtype=jnp.int32), (A,))
|
|
21
|
+
|
|
22
|
+
left = hax.bitwise_left_shift(x, shift)
|
|
23
|
+
assert jnp.all(left.array == jnp.bitwise_left_shift(x.array, shift.array))
|
|
24
|
+
|
|
25
|
+
right = hax.bitwise_right_shift(left, shift)
|
|
26
|
+
assert jnp.all(right.array == jnp.bitwise_right_shift(left.array, shift.array))
|
|
27
|
+
|
|
28
|
+
right_scalar = hax.bitwise_right_shift(x, 1)
|
|
29
|
+
assert jnp.all(right_scalar.array == jnp.bitwise_right_shift(x.array, 1))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_packbits_unpackbits():
|
|
33
|
+
B = Axis("B", 10)
|
|
34
|
+
data = hax.named(jnp.array([0, 1, 1, 0, 1, 0, 0, 1, 1, 0], dtype=jnp.uint8), (B,))
|
|
35
|
+
|
|
36
|
+
packed = hax.packbits(data, B)
|
|
37
|
+
expected_packed = jnp.packbits(data.array, axis=0)
|
|
38
|
+
assert jnp.all(packed.array == expected_packed)
|
|
39
|
+
assert packed.axes[0].name == B.name
|
|
40
|
+
assert packed.axes[0].size == 2
|
|
41
|
+
|
|
42
|
+
unpacked = hax.unpackbits(packed, "B", count=B.size)
|
|
43
|
+
expected_unpacked = jnp.unpackbits(packed.array, axis=0, count=B.size)
|
|
44
|
+
assert jnp.all(unpacked.array == expected_unpacked)
|
|
45
|
+
assert unpacked.axes[0].size == B.size
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.4.dev408"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|