Skip to main content

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:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

en_dtypes-0.0.4.tar.gz (733.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

en_dtypes-0.0.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

en_dtypes-0.0.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

en_dtypes-0.0.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

en_dtypes-0.0.4-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

en_dtypes-0.0.4-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

en_dtypes-0.0.4-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

File details

Details for the file en_dtypes-0.0.4.tar.gz.

File metadata

  • Download URL: en_dtypes-0.0.4.tar.gz
  • Upload date:
  • Size: 733.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for en_dtypes-0.0.4.tar.gz
Algorithm Hash digest
SHA256 3d00d55a97f232d171a41aab374a58f8376f75e84e75f21e24201a6d037f656e
MD5 c0abf6ffa8f5f3ae699c0fd30c233081
BLAKE2b-256 dac6fd7e2b5419b4cb2d8abd54f99a33b4ed1ce4e6255abe5b789d04904ca7ab

See more details on using hashes here.

File details

Details for the file en_dtypes-0.0.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for en_dtypes-0.0.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 0be4ffb7088e9ff6ad949583b0a9cbad9c9b5cdced55e573bd87630c9b06a737
MD5 7c85f82a767e947713acdb577a01033d
BLAKE2b-256 ed00ae9585f89225e1def3378e5108c6d65ef2363a5177ec3fd31784b5c32f10

See more details on using hashes here.

File details

Details for the file en_dtypes-0.0.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for en_dtypes-0.0.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 ea5ef06c1ad75a546601288350ef50e9408579aa2b7d43ab8804d8e58664205d
MD5 ef7394acf59077fb17abc42ce4622dcb
BLAKE2b-256 3d518842c8464773b1a486a1d033b97b97536544bcf722dd0817d4fba3dfb08c

See more details on using hashes here.

File details

Details for the file en_dtypes-0.0.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for en_dtypes-0.0.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 8e0d4b80a3da0f31e418146c60fceee78677888b5d1c3199d55f059e0c3b804e
MD5 1af46f5ad42dd2a41500c60a5d4eaaa8
BLAKE2b-256 ab25967a50e7064861ca66270c602c1b717bd2213b911b0e658818e08e4d6b93

See more details on using hashes here.

File details

Details for the file en_dtypes-0.0.4-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for en_dtypes-0.0.4-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 2d9dabad12ef0c5582a450870404cdd4df55522dc06c024b5c72a0f73c0c340d
MD5 41c1f6dce7014657b5bdb609da67769d
BLAKE2b-256 f9eb04cf38980d5c00aa734ef2376146697a186faabc1ae9683fc5a61b6c8cfb

See more details on using hashes here.

File details

Details for the file en_dtypes-0.0.4-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for en_dtypes-0.0.4-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 8e241d81e3c8b5cbaa6cfbc0d3e949a79ce66f42008836092f642a1bfb5560d6
MD5 edf3c0a7f1d1419410d0464e3bcca0ee
BLAKE2b-256 0b7f4ca19df8786080a899174d01bd47be8bef189f3ccfdd7b2c65e218266b1f

See more details on using hashes here.

File details

Details for the file en_dtypes-0.0.4-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for en_dtypes-0.0.4-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 25468d6d60be9c2e75323cd87074dbd178ac2708e256d8f26893324e47cff167
MD5 b32fa3ff9087b30bf869ceed5128937d
BLAKE2b-256 1da66b9c65f9849331b80d6dfe4c020c453b824a86b08cc9e70fccf562a1825e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page