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_e5m2

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.0.4.tar.gz (684.9 kB view hashes)

Uploaded Source

Built Distributions

ml_dtypes-0.0.4-cp311-cp311-win_amd64.whl (98.3 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

ml_dtypes-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (154.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

ml_dtypes-0.0.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (157.3 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

ml_dtypes-0.0.4-cp311-cp311-macosx_10_9_universal2.whl (226.2 kB view hashes)

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

ml_dtypes-0.0.4-cp310-cp310-win_amd64.whl (98.1 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

ml_dtypes-0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (154.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

ml_dtypes-0.0.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (157.3 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

ml_dtypes-0.0.4-cp310-cp310-macosx_10_9_universal2.whl (226.2 kB view hashes)

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

ml_dtypes-0.0.4-cp39-cp39-win_amd64.whl (98.0 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

ml_dtypes-0.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (154.9 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

ml_dtypes-0.0.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (157.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

ml_dtypes-0.0.4-cp39-cp39-macosx_10_9_universal2.whl (226.2 kB view hashes)

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

ml_dtypes-0.0.4-cp38-cp38-win_amd64.whl (98.0 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

ml_dtypes-0.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (155.0 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

ml_dtypes-0.0.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (157.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

ml_dtypes-0.0.4-cp38-cp38-macosx_10_9_universal2.whl (226.2 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