ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Convolution.cpp File Reference
#include <nonius/nonius.h++>
#include <arm_compute/core/Types.h>
#include <arm_compute/runtime/NEON/NEScheduler.h>
#include <arm_compute/runtime/NEON/NEFunctions.h>
#include <cstdint>
#include <cassert>
#include <stdexcept>

Go to the source code of this file.

Macros

#define NONIUS_LOCAL_BENCHMARK(name, ...)
 

Functions

 NONIUS_PARAM (BATCH, 1)
 
 NONIUS_PARAM (IFM_C, 3)
 
 NONIUS_PARAM (IFM_H, 244)
 
 NONIUS_PARAM (IFM_W, 244)
 
 NONIUS_PARAM (OFM_C, 3)
 
 NONIUS_PARAM (OFM_H, 244)
 
 NONIUS_PARAM (OFM_W, 244)
 
 NONIUS_PARAM (KER_H, 3)
 
 NONIUS_PARAM (KER_W, 3)
 
 NONIUS_PARAM (STRIDE_H, 1)
 
 NONIUS_PARAM (STRIDE_W, 1)
 
 NONIUS_LOCAL_BENCHMARK ("NEDirectConvolutionLayer_NCHW", [](nonius::chronometer meter) { NEDirectConvolutionLayer conv;Configuration p{meter};Tensor src_tensor{};Tensor dst_tensor{};Tensor ker_tensor{};Tensor bias_tensor{};src_tensor.allocator() ->init(p.src_info< NCHW >());dst_tensor.allocator() ->init(p.dst_info< NCHW >());ker_tensor.allocator() ->init(p.ker_info< NCHW >());bias_tensor.allocator() ->init(p.bias_info());try { check(conv.validate(src_tensor.info(), ker_tensor.info(), bias_tensor.info(), dst_tensor.info(), p.pad_stride_info()));} catch(...) { meter.measure([&](int) { volatile int x=0;return x;});return;} conv.configure(&src_tensor, &ker_tensor, &bias_tensor, &dst_tensor, p.pad_stride_info());src_tensor.allocator() ->allocate();ker_tensor.allocator() ->allocate();bias_tensor.allocator() ->allocate();dst_tensor.allocator() ->allocate();meter.measure([&](int) { conv.run();});}) NONIUS_LOCAL_BENCHMARK("NEDirectConvolutionLayer_NHWC"
 
src_tensor allocator () -> init(p.src_info< NHWC >())
 
 catch (...)
 
meter measure ([&](int) { conv.run();})
 
 NONIUS_LOCAL_BENCHMARK ("NEGEMMConvolutionLayer_NCHW", [](nonius::chronometer meter) { NEGEMMConvolutionLayer conv;Configuration p{meter};Tensor src_tensor{};Tensor dst_tensor{};Tensor ker_tensor{};Tensor bias_tensor{};src_tensor.allocator() ->init(p.src_info< NCHW >());dst_tensor.allocator() ->init(p.dst_info< NCHW >());ker_tensor.allocator() ->init(p.ker_info< NCHW >());bias_tensor.allocator() ->init(p.bias_info());try { check(conv.validate(src_tensor.info(), ker_tensor.info(), bias_tensor.info(), dst_tensor.info(), p.pad_stride_info()));} catch(...) { meter.measure([&](int) { volatile int x=0;return x;});return;} conv.configure(&src_tensor, &ker_tensor, &bias_tensor, &dst_tensor, p.pad_stride_info());src_tensor.allocator() ->allocate();ker_tensor.allocator() ->allocate();bias_tensor.allocator() ->allocate();dst_tensor.allocator() ->allocate();meter.measure([&](int) { conv.run();});}) NONIUS_LOCAL_BENCHMARK("NEGEMMConvolutionLayer_NHWC"
 
 NONIUS_LOCAL_BENCHMARK ("NEWinogradConvolutionLayer_NCHW", [](nonius::chronometer meter) { NEWinogradConvolutionLayer conv;Configuration p{meter};Tensor src_tensor{};Tensor dst_tensor{};Tensor ker_tensor{};Tensor bias_tensor{};src_tensor.allocator() ->init(p.src_info< NCHW >());dst_tensor.allocator() ->init(p.dst_info< NCHW >());ker_tensor.allocator() ->init(p.ker_info< NCHW >());bias_tensor.allocator() ->init(p.bias_info());try { check(conv.validate(src_tensor.info(), ker_tensor.info(), bias_tensor.info(), dst_tensor.info(), p.pad_stride_info()));} catch(...) { meter.measure([&](int) { volatile int x=0;return x;});return;} conv.configure(&src_tensor, &ker_tensor, &bias_tensor, &dst_tensor, p.pad_stride_info());src_tensor.allocator() ->allocate();ker_tensor.allocator() ->allocate();bias_tensor.allocator() ->allocate();dst_tensor.allocator() ->allocate();meter.measure([&](int) { conv.run();});}) NONIUS_LOCAL_BENCHMARK("NEWinogradConvolutionLayer_NHWC"
 
nonius::benchmark_registry & benchmark_functions (void)
 

Variables

nonius::chronometer meter
 
Configuration p {meter}
 
Tensor src_tensor {}
 
Tensor dst_tensor {}
 
Tensor ker_tensor {}
 
Tensor bias_tensor {}
 
 try
 

Macro Definition Documentation

◆ NONIUS_LOCAL_BENCHMARK

#define NONIUS_LOCAL_BENCHMARK (   name,
  ... 
)
Value:
namespace \
{ \
static ::nonius::benchmark_registrar \
NONIUS_DETAIL_UNIQUE_NAME(benchmark_registrar)(local_benchmark_registry(), name, __VA_ARGS__); \
}

Definition at line 226 of file Convolution.cpp.

228 { \
229 static ::nonius::benchmark_registrar \
230 NONIUS_DETAIL_UNIQUE_NAME(benchmark_registrar)(local_benchmark_registry(), name, __VA_ARGS__); \
231 }

Function Documentation

◆ allocator()

src_tensor allocator ( ) -> init(p.src_info< NHWC >())

◆ benchmark_functions()

nonius::benchmark_registry & benchmark_functions ( void  )

Definition at line 485 of file Convolution.cpp.

486{
487 return local_benchmark_registry();
488}

◆ catch()

catch (   ...)

Definition at line 296 of file Convolution.cpp.

297 {
298 meter.measure([&](int) {
299 // DO NOTHING
300 volatile int x = 0;
301 return x;
302 });
303 return;
304 }
nonius::chronometer meter

References meter.

◆ measure()

meter measure ( [&] (int) { conv.run();}  )

◆ NONIUS_LOCAL_BENCHMARK() [1/3]

NONIUS_LOCAL_BENCHMARK ( "NEDirectConvolutionLayer_NCHW"  ,
[] (nonius::chronometer meter) { NEDirectConvolutionLayer conv;Configuration p{meter};Tensor src_tensor{};Tensor dst_tensor{};Tensor ker_tensor{};Tensor bias_tensor{};src_tensor.allocator() ->init(p.src_info< NCHW >());dst_tensor.allocator() ->init(p.dst_info< NCHW >());ker_tensor.allocator() ->init(p.ker_info< NCHW >());bias_tensor.allocator() ->init(p.bias_info());try { check(conv.validate(src_tensor.info(), ker_tensor.info(), bias_tensor.info(), dst_tensor.info(), p.pad_stride_info()));} catch(...) { meter.measure([&](int) { volatile int x=0;return x;});return;} conv.configure(&src_tensor, &ker_tensor, &bias_tensor, &dst_tensor, p.pad_stride_info());src_tensor.allocator() ->allocate();ker_tensor.allocator() ->allocate();bias_tensor.allocator() ->allocate();dst_tensor.allocator() ->allocate();meter.measure([&](int) { conv.run();});}   
)

◆ NONIUS_LOCAL_BENCHMARK() [2/3]

NONIUS_LOCAL_BENCHMARK ( "NEGEMMConvolutionLayer_NCHW"  ,
[] (nonius::chronometer meter) { NEGEMMConvolutionLayer conv;Configuration p{meter};Tensor src_tensor{};Tensor dst_tensor{};Tensor ker_tensor{};Tensor bias_tensor{};src_tensor.allocator() ->init(p.src_info< NCHW >());dst_tensor.allocator() ->init(p.dst_info< NCHW >());ker_tensor.allocator() ->init(p.ker_info< NCHW >());bias_tensor.allocator() ->init(p.bias_info());try { check(conv.validate(src_tensor.info(), ker_tensor.info(), bias_tensor.info(), dst_tensor.info(), p.pad_stride_info()));} catch(...) { meter.measure([&](int) { volatile int x=0;return x;});return;} conv.configure(&src_tensor, &ker_tensor, &bias_tensor, &dst_tensor, p.pad_stride_info());src_tensor.allocator() ->allocate();ker_tensor.allocator() ->allocate();bias_tensor.allocator() ->allocate();dst_tensor.allocator() ->allocate();meter.measure([&](int) { conv.run();});}   
)

◆ NONIUS_LOCAL_BENCHMARK() [3/3]

NONIUS_LOCAL_BENCHMARK ( "NEWinogradConvolutionLayer_NCHW"  ,
[] (nonius::chronometer meter) { NEWinogradConvolutionLayer conv;Configuration p{meter};Tensor src_tensor{};Tensor dst_tensor{};Tensor ker_tensor{};Tensor bias_tensor{};src_tensor.allocator() ->init(p.src_info< NCHW >());dst_tensor.allocator() ->init(p.dst_info< NCHW >());ker_tensor.allocator() ->init(p.ker_info< NCHW >());bias_tensor.allocator() ->init(p.bias_info());try { check(conv.validate(src_tensor.info(), ker_tensor.info(), bias_tensor.info(), dst_tensor.info(), p.pad_stride_info()));} catch(...) { meter.measure([&](int) { volatile int x=0;return x;});return;} conv.configure(&src_tensor, &ker_tensor, &bias_tensor, &dst_tensor, p.pad_stride_info());src_tensor.allocator() ->allocate();ker_tensor.allocator() ->allocate();bias_tensor.allocator() ->allocate();dst_tensor.allocator() ->allocate();meter.measure([&](int) { conv.run();});}   
)

◆ NONIUS_PARAM() [1/11]

NONIUS_PARAM ( BATCH  ,
 
)

◆ NONIUS_PARAM() [2/11]

NONIUS_PARAM ( IFM_C  ,
 
)

◆ NONIUS_PARAM() [3/11]

NONIUS_PARAM ( IFM_H  ,
244   
)

◆ NONIUS_PARAM() [4/11]

NONIUS_PARAM ( IFM_W  ,
244   
)

◆ NONIUS_PARAM() [5/11]

NONIUS_PARAM ( KER_H  ,
 
)

◆ NONIUS_PARAM() [6/11]

NONIUS_PARAM ( KER_W  ,
 
)

◆ NONIUS_PARAM() [7/11]

NONIUS_PARAM ( OFM_C  ,
 
)

◆ NONIUS_PARAM() [8/11]

NONIUS_PARAM ( OFM_H  ,
244   
)

◆ NONIUS_PARAM() [9/11]

NONIUS_PARAM ( OFM_W  ,
244   
)

◆ NONIUS_PARAM() [10/11]

NONIUS_PARAM ( STRIDE_H  ,
 
)

◆ NONIUS_PARAM() [11/11]

NONIUS_PARAM ( STRIDE_W  ,
 
)

Variable Documentation

◆ bias_tensor

Tensor bias_tensor {}

Definition at line 284 of file Convolution.cpp.

284{};

Referenced by NONIUS_LOCAL_BENCHMARK(), NONIUS_LOCAL_BENCHMARK(), and NONIUS_LOCAL_BENCHMARK().

◆ dst_tensor

Tensor dst_tensor {}

Definition at line 282 of file Convolution.cpp.

282{};

Referenced by NONIUS_LOCAL_BENCHMARK(), NONIUS_LOCAL_BENCHMARK(), and NONIUS_LOCAL_BENCHMARK().

◆ ker_tensor

Tensor ker_tensor {}

Definition at line 283 of file Convolution.cpp.

283{};

Referenced by NONIUS_LOCAL_BENCHMARK(), NONIUS_LOCAL_BENCHMARK(), and NONIUS_LOCAL_BENCHMARK().

◆ meter

nonius::chronometer meter
Initial value:
{
NEDirectConvolutionLayer conv

Definition at line 275 of file Convolution.cpp.

Referenced by catch(), NONIUS_LOCAL_BENCHMARK(), NONIUS_LOCAL_BENCHMARK(), and NONIUS_LOCAL_BENCHMARK().

◆ p

Configuration p {meter}

◆ src_tensor

Tensor src_tensor {}

Definition at line 281 of file Convolution.cpp.

281{};

Referenced by NONIUS_LOCAL_BENCHMARK(), NONIUS_LOCAL_BENCHMARK(), and NONIUS_LOCAL_BENCHMARK().

◆ try

try
Initial value:
{
check(conv.validate(src_tensor.info(), ker_tensor.info(), bias_tensor.info(), dst_tensor.info(),
p.pad_stride_info()))
Tensor src_tensor
Tensor ker_tensor
Configuration p
Tensor dst_tensor
Tensor bias_tensor

Definition at line 291 of file Convolution.cpp.