Skip to content

update 2 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 88 commits into
base: lv-ext2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
8da76bd
Fix grad conv im2col (#539)
wsmoses Sep 27, 2023
d0a03f2
unbreak gpu conv test (#541)
CarloLucibello Sep 27, 2023
aea063c
Add EnzymeRule for conv!/gather!/scatter!/dropout!/pool! (#536)
wsmoses Sep 28, 2023
6d98fe7
Update Project.toml
CarloLucibello Sep 30, 2023
af0aa2c
Don't run CPU tests on AMDGPU CI machines (#542)
pxl-th Sep 30, 2023
607de4b
Allow non-Int64 indices in scatter (#543)
pxl-th Oct 4, 2023
2f2ae84
Update AMDGPU compat to 0.7 (#545)
pxl-th Oct 24, 2023
00fccc7
CompatHelper: add new compat entry for Statistics at version 1, (keep…
github-actions[bot] Oct 29, 2023
8598c08
make gather/scatter work with views (#546)
CarloLucibello Nov 6, 2023
3f9e45d
Update Project.toml
CarloLucibello Nov 6, 2023
b276338
Set compatibilities for standard packages (#550)
bicycle1885 Nov 21, 2023
7f70079
Bump AMDGPU compat to 0.8 (#551)
pxl-th Dec 4, 2023
e3903e2
Bump version
ToucheSir Dec 19, 2023
f9c3002
CompatHelper: bump compat for Adapt to 4, (keep existing compat) (#554)
github-actions[bot] Dec 21, 2023
f3cc467
Fixes #555 (#556)
Dec 28, 2023
0da50d6
Update Project.toml
CarloLucibello Dec 30, 2023
ad0a3ce
Add rrule for `oftf` (#559)
ToucheSir Jan 11, 2024
1096ddc
Use julia-actions/cache (#560)
ToucheSir Jan 17, 2024
b61b0b8
Add image rotation (#553)
roflmaostc Jan 29, 2024
935bf3d
bump version
ToucheSir Jan 30, 2024
e3f22c6
CUDA: Fix compilation failure. (#566)
maleadt Feb 15, 2024
97410d7
Update Project.toml
CarloLucibello Feb 15, 2024
9c31d9d
replace unsafe_convert with pointer (#564)
mcabbott Feb 20, 2024
050b835
Fix typo in dot product attention error message (#567)
johannes-fischer Feb 23, 2024
1af2535
Update softmax.jl (#569)
mcabbott Mar 23, 2024
a5cd730
Bump EnzymeCore compat (#571)
wsmoses Mar 27, 2024
0783363
Update Project.toml
CarloLucibello Mar 27, 2024
d85402a
Add export for imrotate gradient (#574)
roflmaostc Apr 12, 2024
e8e7572
Fix batchnorm in testmode without track stats (#576)
paulnovo Apr 23, 2024
2f0b555
Update Project.toml
CarloLucibello Apr 23, 2024
6d168b4
Documenter.jl update to 1.4.0 (#578)
dom-linkevicius Apr 27, 2024
01e127e
Update the activation inplace for cudnn
avik-pal Apr 28, 2024
d0da256
Merge pull request #579 from avik-pal/patch-1
darsnack May 1, 2024
c8cbf76
Enzyme: add derivatives for ∇conv_filter and ∇conv_data (#582)
wsmoses May 11, 2024
47725a3
Update Project.toml
CarloLucibello May 11, 2024
4206e26
Enzyme: broaden tests (#583)
wsmoses May 12, 2024
8f89322
Type stabilize logsoftmax (#584)
wsmoses May 12, 2024
f2a2674
Update Project.toml
CarloLucibello May 12, 2024
03a1e09
Add support for AMDGPU 0.9
pxl-th May 18, 2024
ca600b1
Merge pull request #585 from FluxML/pxl-th/amdgpu-0.9
darsnack May 19, 2024
7369244
Update Project.toml
darsnack May 19, 2024
381a41f
Transition to `LinearAlgebra.BLAS.libblastrampoline` instead of `Base…
staticfloat Jun 12, 2024
627374c
fix typos in the doc for batched_mul! (#590)
lanceXwq Jun 15, 2024
425cc59
Use GPU-friendly rounding (#591)
pxl-th Jun 19, 2024
85b17cf
Fix padding causing device to host copies (#593)
pxl-th Jun 19, 2024
d423576
Support `conv_direct!` on custom datatypes (#592)
adrhill Jun 19, 2024
62f6074
Bump to 0.9.18
pxl-th Jun 19, 2024
4159154
Implement Short-time Fourier transform and its inverse (#587)
pxl-th Jul 4, 2024
f87cf6e
Update Project.toml
CarloLucibello Jul 4, 2024
9e95671
Fix non-symmetric padding (#595)
pxl-th Jul 12, 2024
52f22f9
Update Project.toml
CarloLucibello Jul 12, 2024
a4111c1
Use KernelAbstractions for fold/unfold (#596)
pxl-th Jul 14, 2024
1ede301
fix: remove inlining of sigmoid_fast pre 1.11- (#597)
avik-pal Jul 16, 2024
ddfe49b
ci: update downstream testing (#598)
avik-pal Jul 17, 2024
86473fc
fix: MIOpen only supports till dimension 5 (#601)
avik-pal Jul 18, 2024
9385356
chore: bump patch version
avik-pal Jul 21, 2024
e68e6ee
CompatHelper: bump compat for AMDGPU in [weakdeps] to 1, (keep existi…
github-actions[bot] Aug 9, 2024
013aa51
Bump to 0.9.22
pxl-th Aug 9, 2024
4cea75c
fix: remove uses of NNPACK
avik-pal Aug 29, 2024
4e957ad
refactor: move ForwardDiff to an ext
avik-pal Aug 29, 2024
36e3b96
fix: remove uses of Requires
avik-pal Aug 29, 2024
393e830
fix: remove usage of Pkg
avik-pal Aug 29, 2024
f76a38d
Merge pull request #603 from LuxDL/ap/load_times
avik-pal Aug 29, 2024
6c8e717
chore: bump version for release
avik-pal Sep 3, 2024
11ee324
Prepare for pending Enzyme breaking change (#605)
wsmoses Sep 16, 2024
44a6b04
Bump patch version to release new Enzyme support (#606)
wsmoses Sep 18, 2024
ba29c90
Update method docstrings (#607)
abhro Sep 30, 2024
0213868
fix test (#611)
CarloLucibello Oct 26, 2024
2ae295b
Bump deps (#613)
pxl-th Nov 19, 2024
25735a4
Bump to 0.9.25
pxl-th Nov 25, 2024
0b51bc2
Update Project.toml (#615)
christiangnrd Nov 26, 2024
81e6cd1
Update Project.toml
CarloLucibello Nov 26, 2024
be9c1c8
Fix `NaN` gradient in spectrogram (#617)
pxl-th Dec 22, 2024
5732b97
Update bias_act.jl (#618)
mcabbott Jan 4, 2025
b56ff50
Add unthunk in conv.jl (#620)
mcabbott Jan 9, 2025
491e6da
Add Grid Sampling for 3D images. (#627)
gRox167 Jan 30, 2025
307d402
Update Project.toml
CarloLucibello Jan 30, 2025
7484f95
Adds full gelu without approximation (#629)
se-schmitt Feb 28, 2025
a5201fb
bump to v0.9.29
ToucheSir Feb 28, 2025
2edc2c0
revert version bump
ToucheSir Feb 28, 2025
3125822
CompatHelper: add new compat entry for SpecialFunctions in [weakdeps]…
Mar 1, 2025
cf5a07f
Merge pull request #630 from FluxML/compathelper/new_version/2025-03-…
ToucheSir Mar 1, 2025
0a9a709
Add type alias for gelu -> gelu_tanh
ToucheSir Mar 3, 2025
ec337e6
Merge pull request #632 from FluxML/bc/gelu-type-alias
ToucheSir Mar 13, 2025
85d80d1
Don't spawn if: only one iteration or no threads or threading disable…
IanButterworth Mar 18, 2025
f2327bd
CompatHelper: bump compat for ForwardDiff in [weakdeps] to 1, (keep e…
github-actions[bot] Mar 27, 2025
0018789
use the correct `nthreads` (#636)
IanButterworth Mar 31, 2025
1468582
version 0.9.30
mcabbott Apr 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
steps:
- label: ":julia: Julia {{matrix.julia}} + CUDA GPU"
command:
- echo 'CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"' >> test/Project.toml
plugins:
- JuliaCI/julia#v1:
version: "{{matrix.julia}}"
Expand All @@ -14,15 +16,16 @@ steps:
queue: "juliagpu"
cuda: "*"
env:
JULIA_NUM_THREADS: 4
NNLIB_TEST_CUDA: "true"
NNLIB_TEST_CPU: "false"
NNLIB_TEST_CPU: "true" # Could be useful to uncover multithreading related issues
# Buildkite workers have more threads.
if: build.message !~ /\[skip tests\]/
timeout_in_minutes: 180
matrix:
setup:
julia:
# - "1.9" # uncomment when 1.10 is out
- "1"
- "1.10"
- "nightly"
adjustments:
- with:
Expand All @@ -32,8 +35,9 @@ steps:
- label: ":julia: Julia 1 + AMD GPU"
plugins:
- JuliaCI/julia#v1:
version: "1"
version: "1.10"
- JuliaCI/julia-test#v1:
test_args: "--quickfail"
- JuliaCI/julia-coverage#v1:
codecov: true
dirs:
Expand All @@ -49,8 +53,7 @@ steps:
JULIA_AMDGPU_HIP_MUST_LOAD: "1"
JULIA_AMDGPU_DISABLE_ARTIFACTS: "1"
NNLIB_TEST_AMDGPU: "true"
NNLIB_TEST_CPU: "true" # Could be useful to uncover multithreading related issues
# Buildkite workers have more threads.
NNLIB_TEST_CPU: "false"
JULIA_NUM_THREADS: 4

- label: "Benchmarks"
Expand Down
23 changes: 11 additions & 12 deletions .github/workflows/Downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
tags: [v*]
pull_request:

# needed to allow julia-actions/cache to delete old caches that it has created
permissions:
actions: write
contents: read

jobs:
test:
name: ${{ matrix.package.repo }}/${{ matrix.package.group }}
Expand All @@ -19,24 +24,14 @@ jobs:
package:
- {user: FluxML, repo: Flux.jl, group: All}
- {user: FluxML, repo: Tracker.jl, group: All}
- {user: denizyuret, repo: Knet.jl, group: All}
- {user: dfdx, repo: Avalon.jl, group: All}
- {user: JuliaOptimalTransport, repo: OptimalTransport.jl, group: All}
- {user: avik-pal, repo: Lux.jl, group: All}
- {user: LuxDL, repo: Lux.jl, group: All}
steps:
- uses: actions/checkout@v3
# for OptimalTransport.jl
- name: Install python
uses: actions/setup-python@v4
with:
python-version: '3.9'
architecture: ${{ matrix.arch }}
# for OptimalTransport.jl
- run: python -m pip install pot
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
arch: x64
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@latest
- name: Clone Downstream
uses: actions/checkout@v3
Expand All @@ -60,3 +55,7 @@ jobs:
@info "Not compatible with this release. No problem." exception=err
exit(0) # Exit immediately, as a success
end
env:
RETESTITEMS_NWORKERS: 4
BACKEND_GROUP: CPU # for Lux.jl

32 changes: 11 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
tags: '*'
pull_request:

# needed to allow julia-actions/cache to delete old caches that it has created
permissions:
actions: write
contents: read

defaults:
run:
shell: bash
Expand All @@ -24,8 +29,9 @@ jobs:
matrix:
version:
# - '1.9' # uncomment when julia 1.10 is out
- 'lts'
- '1' # automatically expands to the latest stable 1.x release of Julia
- 'nightly'
- 'pre'
os:
- ubuntu-latest
# - macOS-latest
Expand All @@ -51,20 +57,11 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v3
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1

- name: "Run test without coverage"
Expand All @@ -88,22 +85,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: '1.9'
- uses: julia-actions/cache@v1
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- run: |
julia --color=yes --project=docs/ -e '
using NNlib
# using Pkg; Pkg.activate("docs")
using Documenter
using Documenter: doctest
DocMeta.setdocmeta!(NNlib, :DocTestSetup, :(using NNlib); recursive=true)
doctest(NNlib)'
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
58 changes: 26 additions & 32 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "NNlib"
uuid = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
version = "0.9.6"
version = "0.9.30"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand All @@ -9,49 +9,43 @@ ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
ScopedValues = "7e506255-f358-4e82-b7e4-beb19740aa63"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[weakdeps]
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd"

[extensions]
NNlibAMDGPUExt = "AMDGPU"
NNlibCUDAExt = "CUDA"
NNlibCUDACUDNNExt = ["CUDA", "cuDNN"]
NNlibCUDAExt = "CUDA"
NNlibEnzymeCoreExt = "EnzymeCore"
NNlibFFTWExt = "FFTW"
NNlibForwardDiffExt = "ForwardDiff"
NNlibSpecialFunctionsExt = "SpecialFunctions"

[compat]
AMDGPU = "0.5, 0.6"
Adapt = "3.2"
Atomix = "0.1"
ChainRulesCore = "1.13"
AMDGPU = "1"
Adapt = "3.2, 4"
Atomix = "0.1, 1"
CUDA = "4, 5"
cuDNN = "1"
GPUArraysCore = "0.1"
ChainRulesCore = "1.25"
EnzymeCore = "0.5, 0.6, 0.7, 0.8"
FFTW = "1.8.0"
ForwardDiff = "0.10.36, 1"
GPUArraysCore = "0.1, 0.2"
KernelAbstractions = "0.9.2"
Requires = "1.0"
LinearAlgebra = "<0.0.1, 1"
Random = "<0.0.1, 1"
ScopedValues = "1.3.0"
SpecialFunctions = "2"
Statistics = "1"
cuDNN = "1"
julia = "1.9"

[extras]
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd"

[targets]
test = ["AMDGPU", "CUDA", "ChainRulesTestUtils", "Documenter",
"FiniteDifferences", "ForwardDiff", "Logging", "ReverseDiff",
"StableRNGs", "Test", "UnicodePlots", "Zygote", "cuDNN"]
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ for CUDA support, or
using NNlib, AMDGPU
```
for AMDGPU support.

15 changes: 0 additions & 15 deletions benchmark/perf_report.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ for rank in (2,),
(NNlib.depthwiseconv_im2col!, NNlib.∇depthwiseconv_data_im2col!, NNlib.∇depthwiseconv_filter_im2col!, DepthwiseConvDims, "im2col"),
]

if NNlib.is_nnpack_available()
push!(benchmark_items, (NNlib.conv_nnpack!, NNlib.∇conv_data_nnpack!, NNlib.∇conv_filter_nnpack!, DenseConvDims, "nnpack"))
end

for (conv!, ∇conv_data!, ∇conv_filter!, cT, backend) in benchmark_items

x = zeros(Float32, repeat([N], rank)..., C_in, 1)
Expand Down Expand Up @@ -105,15 +101,4 @@ for rank in (2,),
@show(pdims)
@save "results.jld2" results
end

if NNlib.is_nnpack_available()
if NNlib.nnpack_supported_operation(pdims)
t_fwd = @benchmark NNlib.maxpool_nnpack!($y, $x, $pdims)

add_result(t_fwd, "maxpool2d", "nnpack", pdims)

@show(pdims)
@save "results.jld2" results
end
end
end
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/
site/
Manifest.toml
10 changes: 7 additions & 3 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

[compat]
Documenter = "0.27"
FLAC = "abae9e3b-a9a0-4778-b5c6-ca109b507d99"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
25 changes: 14 additions & 11 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
using Documenter, NNlib

DocMeta.setdocmeta!(NNlib, :DocTestSetup, :(using NNlib); recursive = true)
DocMeta.setdocmeta!(NNlib, :DocTestSetup,
:(using FFTW, NNlib, UnicodePlots); recursive = true)

makedocs(modules = [NNlib],
sitename = "NNlib.jl",
doctest = false,
pages = ["Home" => "index.md",
"Reference" => "reference.md"],
format = Documenter.HTML(
canonical = "https://fluxml.ai/NNlib.jl/stable/",
# analytics = "UA-36890222-9",
assets = ["assets/flux.css"],
prettyurls = get(ENV, "CI", nothing) == "true"),
)
sitename = "NNlib.jl",
doctest = true,
pages = ["Home" => "index.md",
"Reference" => "reference.md",
"Audio" => "audio.md"],
format = Documenter.HTML(
canonical = "https://fluxml.ai/NNlib.jl/stable/",
# analytics = "UA-36890222-9",
assets = ["assets/flux.css"],
prettyurls = get(ENV, "CI", nothing) == "true"),
warnonly=[:missing_docs,]
)

deploydocs(repo = "github.com/FluxML/NNlib.jl.git",
target = "build",
Expand Down
Binary file added docs/src/assets/jfk.flac
Binary file not shown.
61 changes: 61 additions & 0 deletions docs/src/audio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Reference

!!! note
Spectral functions require importing `FFTW` package to enable them.

## Window functions

```@docs
hann_window
hamming_window
```

## Spectral

```@docs
stft
istft
NNlib.power_to_db
NNlib.db_to_power
```

## Spectrogram

```@docs
melscale_filterbanks
spectrogram
```

Example:

```@example 1
using FFTW # <- required for STFT support.
using NNlib
using FileIO
using Makie, CairoMakie
CairoMakie.activate!()

waveform, sampling_rate = load("./assets/jfk.flac")
fig = lines(reshape(waveform, :))
save("waveform.png", fig)

# Spectrogram.

n_fft = 1024
spec = spectrogram(waveform; n_fft, hop_length=n_fft ÷ 4, window=hann_window(n_fft))
fig = heatmap(transpose(NNlib.power_to_db(spec)[:, :, 1]))
save("spectrogram.png", fig)

# Mel-scale spectrogram.

n_freqs = n_fft ÷ 2 + 1
fb = melscale_filterbanks(; n_freqs, n_mels=128, sample_rate=Int(sampling_rate))
mel_spec = permutedims(spec, (2, 1, 3)) ⊠ fb # (time, n_mels)
fig = heatmap(NNlib.power_to_db(mel_spec)[:, :, 1])
save("mel-spectrogram.png", fig)
nothing # hide
```

|Waveform|Spectrogram|Mel Spectrogram|
|:---:|:---:|:---:|
|![](waveform.png)|![](spectrogram.png)|![](mel-spectrogram.png)|
Loading