Skip to content

Commit 43f759a

Browse files
author
Avik Pal
committed
Add performance tests
1 parent 220c442 commit 43f759a

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/NNlib.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ to = TimerOutput()
2626

2727
if Sys.islinux()
2828
include("nnpack/NNPACK.jl")
29+
else
30+
is_nnpack_available() = false
2931
end
3032

3133
end # module NNlib

src/nnpack/NNPACK.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ include(depsjl_path)
1111
const nnlib_interface_path = joinpath(dirname(@__FILE__), "interface.jl")
1212
const shared_threadpool = Ref(C_NULL)
1313

14+
function is_nnpack_available()
15+
check_deps()
16+
status = nnp_initialize()
17+
if status == nnp_status_unsupported_hardware
18+
return false
19+
else
20+
return true
21+
end
22+
end
23+
1424
@init begin
1525
check_deps()
1626
status = nnp_initialize()

test/perf/perf_report.jl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,18 @@ for rank in (2,),
2828
dilation in (1,),
2929
padding in (0, 2)
3030

31-
for (conv!, ∇conv_data!, ∇conv_filter!, cT, backend) in (
31+
benchmark_items = [
3232
(NNlib.conv_direct!, NNlib.∇conv_data_direct!, NNlib.∇conv_filter_direct!, DenseConvDims, "direct"),
3333
(NNlib.conv_im2col!, NNlib.∇conv_data_im2col!, NNlib.∇conv_filter_im2col!, DenseConvDims, "im2col"),
3434
(NNlib.depthwiseconv_direct!, NNlib.∇depthwiseconv_data_direct!, NNlib.∇depthwiseconv_filter_direct!, DepthwiseConvDims, "direct"),
3535
(NNlib.depthwiseconv_im2col!, NNlib.∇depthwiseconv_data_im2col!, NNlib.∇depthwiseconv_filter_im2col!, DepthwiseConvDims, "im2col"),
36-
)
36+
]
37+
38+
if NNlib.is_nnpack_available()
39+
push!(benchmark_items, (NNlib.conv_nnpack!, NNlib.∇conv_data_nnpack!, NNlib.∇conv_filter_nnpack!, DenseConvDims, "nnpack"))
40+
end
41+
42+
for (conv!, ∇conv_data!, ∇conv_filter!, cT, backend) in benchmark_items
3743

3844
x = zeros(Float32, repeat([N], rank)..., C_in, 1)
3945
if cT == DenseConvDims
@@ -96,4 +102,13 @@ for rank in (2,),
96102
@show(pdims)
97103
@save "results.jld2" results
98104
end
105+
106+
if NNlib.is_nnpack_available()
107+
t_fwd = @benchmark NNlib.maxpool_nnpack!($y, $x, $pdims)
108+
109+
add_result(t_fwd, "maxpool2d", "nnpack", pdims)
110+
111+
@show(pdims)
112+
@save "results.jld2" results
113+
end
99114
end

0 commit comments

Comments
 (0)