Experimental numpy dtypes
Project description
en_dtypes
en_dtypes
is a stand-alone implementation of several Experimental NumPy dtype Extensions used in machine learning libraries, including:
- Microscaling (MX)-compliant data formats:
float4_e2m1
float4_e1m2
float6_e2m3
float6_e3m2
float8_e8m0
- Ascend HiFloat8:
hifloat8
See below for specifications of these number formats.
Installation
The en_dtypes
package is tested with Python versions 3.7-3.12, and can be installed with the following command:
pip3 install en-dtypes
To build from source, clone the repository and run:
git submodule init
git submodule update
pip3 install .
Example Usage
>>> from en_dtypes import float4_e2m1, hifloat8
>>> import numpy as np
>>> np.zeros(4, dtype=float4_e2m1)
array([0, 0, 0, 0], dtype=float4_e2m1)
>>> np.zeros(4, dtype=hifloat8)
array([0, 0, 0, 0], dtype=hifloat8)
Microscaling (MX)-compliant data formats
float4_e2m1
Exponent: 2, Mantissa: 1, bias: 1.
Extended range: no inf, no NaN.
Microscaling format, 4 bits (encoding: 0bSEEM
) using byte storage (higher 4 bits are unused). NaN representation is undefined.
Possible absolute values: [0
, 0.5
, 1
, 1.5
, 2
, 3
, 4
, 6
]
float4_e1m2
Exponent: 1, Mantissa: 2, bias: 1.
Extended range: no inf, no NaN.
Microscaling format, 4 bits (encoding: 0bSEMM
) using byte storage (higher 4 bits are unused). NaN representation is undefined.
Possible absolute values: [0
, 0.25
, 0.5
, 0.75
, 1
, 1.25
, 1.5
, 1.75
]
float6_e2m3
Exponent: 2, Mantissa: 3, bias: 1.
Extended range: no inf, no NaN.
Microscaling format, 6 bits (encoding: 0bSEEMMM
) using byte storage (higher 2 bits are unused). NaN representation is undefined.
Possible values range: [-7.5
; 7.5
]
float6_e3m2
Exponent: 3, Mantissa: 2, bias: 3.
Extended range: no inf, no NaN.
Microscaling format, 4 bits (encoding: 0bSEEEMM
) using byte storage (higher 2 bits are unused). NaN representation is undefined.
Possible values range: [-28
; 28
]
float8_e8m0
scale format E8M0, which has the following properties:
- Unsigned format
- 8 exponent bits
- Exponent range from -127 to 127
- No zero and infinity
- Single NaN value (0xFF).
Ascend data formats
hifloat8
HiFloat8 is a 8-bit floating point format used in Ascend devices. It has the following properties:
- Sign field with 1 bit
- Dot field with 2 to 4 bits
- Exponent field with 0 to 4 bits implicated by dot field
- Mantissa field with 1 to 3 bits implicated by dot field
- Exponent bias only exist in sub-normal format as 23
- Zero is
0b0'0000'000
without negative zero - Infinity is
0bS'11'0111'1
- NaN is
0b1'0000'000
License
The en_dtypes
source code is licensed under the Apache 2.0 license (see LICENSE). Pre-compiled wheels are built with the EIGEN project, which is released under the MPL 2.0 license (see LICENSE.eigen). Implemention is drawn on the ml_dtypes project, which is released under the Apache 2.0 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file en_dtypes-0.0.3.tar.gz
.
File metadata
- Download URL: en_dtypes-0.0.3.tar.gz
- Upload date:
- Size: 724.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37b36f73c76acaa57fddaba1da4e76bda61590d69e3fffbbaff069d57da0f28a |
|
MD5 | 84626c2215254fa128d97ccb2bdf0132 |
|
BLAKE2b-256 | 8a275f6b5d11c86fa6c570fe5010334bd7c6bae9da14c2705fae28a6c47dbde7 |
File details
Details for the file en_dtypes-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: en_dtypes-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cde6e41947fd76840d08e39f45defceb8ba358b708abb326f3c2231ecb629e21 |
|
MD5 | b0a9bfea9ad4d50652818d542ab9b35e |
|
BLAKE2b-256 | b1dc3f517ae3467a8df5ab186c2df4f117de8cf69e7535776e02c6bd43ac744c |
File details
Details for the file en_dtypes-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: en_dtypes-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cd90aab21ac979e82e12e38c4a3addb0215d506615c072a0bbd40662e9b97ad |
|
MD5 | 3110a67e0d9159a6e18f38e353cff66e |
|
BLAKE2b-256 | 56225228973e750290db543abc0cda3f7138428d80dfff4ac6d973360785fc27 |
File details
Details for the file en_dtypes-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: en_dtypes-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 824ebf9e5ae4969518f7ef14b826377d5a5841669c63da3bb29e64e6ea960779 |
|
MD5 | a4a33f8a896d73f0af9a003f9b4da3b6 |
|
BLAKE2b-256 | 864ef0592ec92071af2529bd8cf9716e73cb8406c0c84b45604a9a95fc08e6b4 |
File details
Details for the file en_dtypes-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: en_dtypes-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12cce1037ee21a798bce1a1dc4d7b5179039400bbf79457cc22f66bc3ab11402 |
|
MD5 | 485d5dada94b84be3691ae58e5c2b7a4 |
|
BLAKE2b-256 | b0b7ab79018e6e124a6a7a39bb871d14f80a4a36696883f8aba8cde6d0201494 |
File details
Details for the file en_dtypes-0.0.3-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: en_dtypes-0.0.3-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca542687b9a6e1bd26a0e172b887748f4e887a28ed8300f09389cab695d9c38b |
|
MD5 | 946f5283e9b970933e05def38f3ee49c |
|
BLAKE2b-256 | da73a6a550699423471c58657b40d52dc6ce9327749041904c73c2a6ef8013a6 |
File details
Details for the file en_dtypes-0.0.3-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: en_dtypes-0.0.3-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2bb8d5a467db6723001dbb065ba700ed9af3ceeac4b1df3406ddcd2e42f6c46 |
|
MD5 | 3b7c7ae6ff41a58d9c31d17ddab2a1a2 |
|
BLAKE2b-256 | e6580cbe2d637965cfb02474c463e44e88aaf7c07cd7c8711e27adc097b150b4 |