This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from LuxDL/ap/fused_dense
Fused Operations
- Loading branch information
Showing
34 changed files
with
1,075 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
name = "LuxLib" | ||
uuid = "82251201-b29d-42c6-8e01-566dec8acb11" | ||
authors = ["Avik Pal <[email protected]> and contributors"] | ||
version = "0.3.14" | ||
version = "0.3.15" | ||
|
||
[deps] | ||
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" | ||
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" | ||
FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898" | ||
FastClosures = "9aa1b823-49e4-5ca5-8b0f-3971ec8bab6a" | ||
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" | ||
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
LuxCore = "bb33d45b-7691-41d6-9220-0943567d0623" | ||
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a" | ||
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd" | ||
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
Reexport = "189a3867-3050-52da-a836-e630ba90ab69" | ||
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | ||
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67" | ||
|
||
[weakdeps] | ||
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" | ||
|
@@ -24,6 +29,7 @@ Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" | |
cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" | ||
|
||
[extensions] | ||
LuxLibAMDGPUExt = "AMDGPU" | ||
LuxLibForwardDiffExt = "ForwardDiff" | ||
LuxLibReverseDiffExt = "ReverseDiff" | ||
LuxLibTrackerAMDGPUExt = ["AMDGPU", "Tracker"] | ||
|
@@ -34,13 +40,17 @@ LuxLibcuDNNExt = ["CUDA", "cuDNN"] | |
[compat] | ||
AMDGPU = "0.8.4" | ||
Aqua = "0.8.7" | ||
ArrayInterface = "7.9" | ||
CUDA = "5.2" | ||
ChainRulesCore = "1.23" | ||
ComponentArrays = "0.15.8" | ||
ExplicitImports = "1.4.1" | ||
FastBroadcast = "0.2.8" | ||
FastClosures = "0.3.2" | ||
ForwardDiff = "0.10.36" | ||
GPUArraysCore = "0.1.6" | ||
KernelAbstractions = "0.9.15" | ||
LinearAlgebra = "1.10" | ||
LuxAMDGPU = "0.2.1" | ||
LuxCUDA = "0.3.1" | ||
LuxCore = "0.1.13" | ||
|
@@ -49,11 +59,12 @@ Markdown = "1.10" | |
NNlib = "0.9.10" | ||
PrecompileTools = "1.2" | ||
Random = "1.10" | ||
ReTestItems = "1" | ||
ReTestItems = "1.23.1" | ||
Reexport = "1" | ||
ReverseDiff = "1.15" | ||
StableRNGs = "1" | ||
Statistics = "1.10" | ||
Strided = "2" | ||
Test = "1.10" | ||
Tracker = "0.2.34" | ||
Zygote = "0.6.69" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module LuxLibAMDGPUExt | ||
|
||
using LuxLib: LuxLib | ||
using NNlib: NNlib | ||
using AMDGPU: AMDGPU, ROCArray | ||
|
||
const MIOPENFloat = Union{Float16, Float32} | ||
|
||
# NNlib incorrectly defines some of the broadcasting rules. Probably this should be | ||
# upstreamed to NNlib | ||
@static if AMDGPU.functional(:MIOpen) | ||
# Just define for dims = 6 , 7, 8 and hope no one uses it beyond that | ||
for f in [NNlib.relu, NNlib.relu6, NNlib.softplus, NNlib.σ, Base.tanh], N in (6, 7, 8) | ||
@eval function Base.materialize(bc::Broadcast.Broadcasted{ | ||
<:Any, <:Any, typeof($f), <:Tuple{ROCArray{<:MIOPENFloat, $N}}}) | ||
return copy(bc) | ||
end | ||
end | ||
end | ||
|
||
@inline function LuxLib.fused_conv_bias_activation( | ||
σ::F, weight::ROCArray{Float64, N}, x::ROCArray{Float64, N}, | ||
b::ROCArray{Float64, N}, cdims::NNlib.ConvDims) where {F, N} | ||
@warn "MIOpen doesn't support Float64 convolutions, type-casting everything to Float32 \ | ||
to avoid runtime errors" maxlog=1 | ||
return LuxLib._oftype_array(Float64, | ||
LuxLib.fused_conv_bias_activation( | ||
σ, LuxLib._oftype_array(Float32, weight), LuxLib._oftype_array(Float32, x), | ||
LuxLib._oftype_array(Float32, b), cdims)) | ||
end | ||
|
||
@inline function LuxLib.fused_conv_bias_activation( | ||
σ::F, weight::ROCArray{Float64, N}, x::ROCArray{Float64, N}, | ||
b::Nothing, cdims::NNlib.ConvDims) where {F, N} | ||
@warn "MIOpen doesn't support Float64 convolutions, type-casting everything to Float32 \ | ||
to avoid runtime errors" maxlog=1 | ||
return LuxLib._oftype_array(Float64, | ||
LuxLib.fused_conv_bias_activation(σ, LuxLib._oftype_array(Float32, weight), | ||
LuxLib._oftype_array(Float32, x), b, cdims)) | ||
end | ||
|
||
@inline function LuxLib.__generic_conv_bias_activation( | ||
act::F, weight::ROCArray{Float64, N}, x::ROCArray{Float64, N}, | ||
bias::ROCArray{Float64, N}, cdims::NNlib.ConvDims) where {N, F} | ||
return LuxLib._oftype_array(Float64, | ||
LuxLib.__generic_conv_bias_activation( | ||
act, LuxLib._oftype_array(Float32, weight), LuxLib._oftype_array(Float32, x), | ||
LuxLib._oftype_array(Float32, bias), cdims)) | ||
end | ||
|
||
@inline function LuxLib.__generic_conv_bias_activation( | ||
act::F, weight::ROCArray{Float64, N}, x::ROCArray{Float64, N}, | ||
bias::Nothing, cdims::NNlib.ConvDims) where {N, F} | ||
return LuxLib._oftype_array(Float64, | ||
LuxLib.__generic_conv_bias_activation(act, LuxLib._oftype_array(Float32, weight), | ||
LuxLib._oftype_array(Float32, x), bias, cdims)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
3d41215
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
3d41215
There was a problem hiding this comment.
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/105553
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.
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: