Skip to main content

No project description provided

Project description

ml_dtypes

Unittests Wheel Build PyPI version

This is not an officially supported Google product.

ml_dtypes is a stand-alone implementation of several NumPy dtype extensions used in machine learning libraries, including:

  • bfloat16: an alternative to the standard float16 format
  • float8_*: several experimental 8-bit floating point representations including:
    • float8_e4m3b11
    • float8_e4m3fn
    • float8_e4m3fnuz
    • float8_e5m2
    • float8_e5m2fnuz

Installation

The ml_dtypes package is tested with Python versions 3.8-3.11, and can be installed with the following command:

pip install ml_dtypes

To test your installation, you can run the following:

pip install absl-py pytest
pytest --pyargs ml_dtypes

To build from source, clone the repository and run:

git submodule init
git submodule update
pip install .

Example Usage

>>> from ml_dtypes import bfloat16
>>> import numpy as np
>>> np.zeros(4, dtype=bfloat16)
array([0, 0, 0, 0], dtype=bfloat16)

Importing ml_dtypes also registers the data types with numpy, so that they may be referred to by their string name:

>>> np.dtype('bfloat16')
dtype(bfloat16)
>>> np.dtype('float8_e5m2')
dtype(float8_e5m2)

License

The ml_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).

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

ml_dtypes-0.1.0.tar.gz (686.9 kB view hashes)

Uploaded Source

Built Distributions

ml_dtypes-0.1.0-cp311-cp311-win_amd64.whl (120.7 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

ml_dtypes-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (190.6 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

ml_dtypes-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (189.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

ml_dtypes-0.1.0-cp311-cp311-macosx_10_9_universal2.whl (317.9 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)

ml_dtypes-0.1.0-cp310-cp310-win_amd64.whl (120.4 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

ml_dtypes-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (190.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

ml_dtypes-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (189.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

ml_dtypes-0.1.0-cp310-cp310-macosx_10_9_universal2.whl (317.9 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

ml_dtypes-0.1.0-cp39-cp39-win_amd64.whl (120.3 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

ml_dtypes-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (191.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

ml_dtypes-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (190.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

ml_dtypes-0.1.0-cp39-cp39-macosx_10_9_universal2.whl (317.9 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

ml_dtypes-0.1.0-cp38-cp38-win_amd64.whl (120.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

ml_dtypes-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (190.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

ml_dtypes-0.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (189.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

ml_dtypes-0.1.0-cp38-cp38-macosx_10_9_universal2.whl (317.8 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

Supported by

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