-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b597d47
commit 100291a
Showing
15 changed files
with
330 additions
and
189 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,7 @@ | |
Manifest.toml | ||
build | ||
.vscode | ||
benchmarks*.json | ||
results*.json | ||
*.tmp | ||
|
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 |
---|---|---|
|
@@ -4,17 +4,23 @@ authors = ["Mike J Innes <[email protected]>"] | |
version = "0.4.12" | ||
|
||
[deps] | ||
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" | ||
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
|
||
[compat] | ||
Documenter = "1" | ||
Compat = "4.16" | ||
ConstructionBase = "1.4" | ||
Measurements = "2" | ||
OrderedCollections = "1.6" | ||
julia = "1.6" | ||
|
||
[extras] | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7" | ||
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" | ||
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" | ||
|
||
[targets] | ||
test = ["Test", "Documenter", "StaticArrays", "Zygote"] | ||
test = ["Test", "OrderedCollections", "StaticArrays", "Zygote", "Measurements"] |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[deps] | ||
AirspeedVelocity = "1c8270ee-6884-45cc-9545-60fa71ec23e4" | ||
BenchmarkPlots = "ab8c0f59-4072-4e0d-8f91-a91e1495eb26" | ||
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" | ||
ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471" | ||
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" | ||
Functors = "d9f16b24-f501-4c13-a1f2-28368ffc5196" | ||
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | ||
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd" |
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,57 @@ | ||
# We run the benchmarks using AirspeedVelocity.jl | ||
|
||
# To run benchmarks locally, first install AirspeedVelocity.jl: | ||
# julia> using Pkg; Pkg.add("AirspeedVelocity"); Pkg.build("AirspeedVelocity") | ||
# and make sure .julia/bin is in your PATH. | ||
|
||
# Then commit the changes and run: | ||
# $ benchpkg Functors --rev=mybranch,master --bench-on=mybranch | ||
|
||
|
||
using BenchmarkTools: BenchmarkTools, BenchmarkGroup, @benchmarkable, @btime, @benchmark, judge | ||
using ConcreteStructs: @concrete | ||
using Flux: Dense, Chain | ||
using LinearAlgebra: BLAS | ||
using Functors | ||
using Statistics: median | ||
|
||
const SUITE = BenchmarkGroup() | ||
const BENCHMARK_CPU_THREADS = Threads.nthreads() | ||
BLAS.set_num_threads(BENCHMARK_CPU_THREADS) | ||
|
||
|
||
@concrete struct A | ||
w | ||
b | ||
σ | ||
end | ||
|
||
struct B | ||
w | ||
b | ||
σ | ||
end | ||
|
||
function setup_fmap_bench!(suite) | ||
a = A(rand(5,5), rand(5), tanh) | ||
suite["fmap"]["concrete struct"] = @benchmarkable fmap(identity, $a) | ||
|
||
a = B(rand(5,5), rand(5), tanh) | ||
suite["fmap"]["non-concrete struct"] = @benchmarkable fmap(identity, $a) | ||
|
||
a = Dense(5, 5, tanh) | ||
suite["fmap"]["flux dense"] = @benchmarkable fmap(identity, $a) | ||
|
||
a = Chain(Dense(5, 5, tanh), Dense(5, 5, tanh)) | ||
suite["fmap"]["flux dense chain"] = @benchmarkable fmap(identity, $a) | ||
|
||
nt = (layers=(w= rand(5,5), b=rand(5), σ=tanh),) | ||
suite["fmap"]["named tuple"] = @benchmarkable fmap(identity, $nt) | ||
|
||
return suite | ||
end | ||
|
||
setup_fmap_bench!(SUITE) | ||
|
||
## AirspeedVelocity.jl will automatically run the benchmarks and save the results | ||
# results = BenchmarkTools.run(SUITE; verbose=true) |
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.