Skip to content

Commit

Permalink
Add support for BFloat16 (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloferz authored Dec 30, 2024

Unverified

No user is associated with the committer email.
2 parents 8559429 + 0ebb684 commit 36d4c55
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ jobs:
matrix:
version:
- '1.6'
- '1.10'
- '1'
- 'nightly'
os:
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name = "DLPack"
uuid = "53c2dc0f-f7d5-43fd-8906-6c0220547083"
authors = ["Pablo Zubieta"]
version = "0.3.0"
version = "0.3.1"

[deps]
BFloat16s = "ab4f0b2a-ad5b-11e8-123f-65d77653426b"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

[weakdeps]
@@ -18,6 +19,7 @@ PythonCallExt = "PythonCall"

[compat]
Aqua = "0.8"
BFloat16s = "≥ 0.4"
CUDA = "≥ 1.3"
PyCall = "1.92"
PythonCall = "≥ 0.7"
3 changes: 3 additions & 0 deletions src/DLPack.jl
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ module DLPack

## Dependencies ##

using BFloat16s: BFloat16
using Requires


@@ -318,6 +319,7 @@ jltypes_to_dtypes() = Dict(
UInt16 => DLDataType(kDLUInt, 16, 1),
UInt32 => DLDataType(kDLUInt, 32, 1),
UInt64 => DLDataType(kDLUInt, 64, 1),
BFloat16 => DLDataType(kDLBfloat, 16, 1),
Float16 => DLDataType(kDLFloat, 16, 1),
Float32 => DLDataType(kDLFloat, 32, 1),
Float64 => DLDataType(kDLFloat, 64, 1),
@@ -340,6 +342,7 @@ dtypes_to_jltypes() = Dict(
DLDataType(kDLUInt, 16, 1) => UInt16,
DLDataType(kDLUInt, 32, 1) => UInt32,
DLDataType(kDLUInt, 64, 1) => UInt64,
DLDataType(kDLBfloat, 16, 1) => BFloat16,
DLDataType(kDLFloat, 16, 1) => Float16,
DLDataType(kDLFloat, 32, 1) => Float32,
DLDataType(kDLFloat, 64, 1) => Float64,
4 changes: 2 additions & 2 deletions test/setup_python_env.jl
Original file line number Diff line number Diff line change
@@ -8,10 +8,10 @@ python_deps = if VERSION == v"1.6.7"
]
else
[
"jax",
"jax<0.4",
]
end
push!(python_deps, "pytorch", "setuptools<70")
push!(python_deps, "numpy<2.1", "pytorch", "setuptools<70")

CondaPkg.add(CondaPkg.PkgREPL.parse_pkg.(python_deps))

2 comments on commit 36d4c55

@pabloferz
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/122236

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.1 -m "<description of version>" 36d4c5541ef8b42970b8dfff1e2c2148eb10512d
git push origin v0.3.1

Please sign in to comment.