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/CL/CLScheduler.h>
#include <arm_compute/runtime/CL/CLFunctions.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 ("CLDirectConvolutionLayer_NCHW", [](nonius::chronometer meter) { CLDirectConvolutionLayer conv;Configuration p{meter};CLTensor src_tensor{};CLTensor dst_tensor{};CLTensor ker_tensor{};CLTensor 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();CLScheduler::get().sync();});}) NONIUS_LOCAL_BENCHMARK("CLDirectConvolutionLayer_NHWC"
 
src_tensor allocator () -> init(p.src_info< NHWC >())
 
 catch (...)
 
meter measure ([&](int) { conv.run();CLScheduler::get().sync();})
 
 NONIUS_LOCAL_BENCHMARK ("CLGEMMConvolutionLayer_NCHW", [](nonius::chronometer meter) { CLGEMMConvolutionLayer conv;Configuration p{meter};CLTensor src_tensor{};CLTensor dst_tensor{};CLTensor ker_tensor{};CLTensor 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();CLScheduler::get().sync();});}) NONIUS_LOCAL_BENCHMARK("CLGEMMConvolutionLayer_NHWC"
 
 NONIUS_LOCAL_BENCHMARK ("CLWinogradConvolutionLayer_NCHW", [](nonius::chronometer meter) { CLWinogradConvolutionLayer conv;Configuration p{meter};CLTensor src_tensor{};CLTensor dst_tensor{};CLTensor ker_tensor{};CLTensor 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();CLScheduler::get().sync();});}) NONIUS_LOCAL_BENCHMARK("CLWinogradConvolutionLayer_NHWC"
 
nonius::benchmark_registry & benchmark_functions (void)
 

Variables

nonius::chronometer meter
 
Configuration p {meter}
 
CLTensor src_tensor {}
 
CLTensor dst_tensor {}
 
CLTensor ker_tensor {}
 
CLTensor 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 233 of file Convolution.cpp.

235 { \
236 static ::nonius::benchmark_registrar \
237 NONIUS_DETAIL_UNIQUE_NAME(benchmark_registrar)(local_benchmark_registry(), name, __VA_ARGS__); \
238 }

Function Documentation

◆ allocator()

◆ benchmark_functions()

nonius::benchmark_registry & benchmark_functions ( void  )

Definition at line 510 of file Convolution.cpp.

511{
512 return local_benchmark_registry();
513}

◆ catch()

catch (   ...)

Definition at line 306 of file Convolution.cpp.

307 {
308 meter.measure([&](int) {
309 // DO NOTHING
310 volatile int x = 0;
311 return x;
312 });
313 return;
314 }
nonius::chronometer meter

References meter.

◆ measure()

meter measure ( [&] (int) { conv.run();CLScheduler::get().sync();}  )

Referenced by main().

◆ NONIUS_LOCAL_BENCHMARK() [1/3]

NONIUS_LOCAL_BENCHMARK ( "CLDirectConvolutionLayer_NCHW"  ,
[] (nonius::chronometer meter) { CLDirectConvolutionLayer conv;Configuration p{meter};CLTensor src_tensor{};CLTensor dst_tensor{};CLTensor ker_tensor{};CLTensor 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();CLScheduler::get().sync();});}   
)

◆ NONIUS_LOCAL_BENCHMARK() [2/3]

NONIUS_LOCAL_BENCHMARK ( "CLGEMMConvolutionLayer_NCHW"  ,
[] (nonius::chronometer meter) { CLGEMMConvolutionLayer conv;Configuration p{meter};CLTensor src_tensor{};CLTensor dst_tensor{};CLTensor ker_tensor{};CLTensor 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();CLScheduler::get().sync();});}   
)

◆ NONIUS_LOCAL_BENCHMARK() [3/3]

NONIUS_LOCAL_BENCHMARK ( "CLWinogradConvolutionLayer_NCHW"  ,
[] (nonius::chronometer meter) { CLWinogradConvolutionLayer conv;Configuration p{meter};CLTensor src_tensor{};CLTensor dst_tensor{};CLTensor ker_tensor{};CLTensor 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();CLScheduler::get().sync();});}   
)

◆ 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

◆ dst_tensor

◆ ker_tensor

◆ meter

nonius::chronometer meter
Initial value:
{
CLDirectConvolutionLayer conv

Definition at line 285 of file Convolution.cpp.

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

◆ p

Configuration p {meter}

Definition at line 289 of file Convolution.cpp.

289{meter};

Referenced by nnkit::support::onnx::Allocator::Alloc(), nnkit::support::onnx::Allocator::Allocator(), loco::AnnotatedItem< Annotation >::annot(), luci_interpreter::BuddyMemoryManager::BuddyMemoryManager(), fme_apply::check_patterns_valid(), onert_micro::import::OMExecutionPlanCreator::createBackwardExecutionPlan(), onert_micro::import::OMExecutionPlanCreator::createForwardExecutionPlan(), flatbuffers::DefaultAllocator::dealloc(), flatbuffers::Deallocate(), flatbuffers::grpc::SliceAllocator::deallocate(), flatbuffers::DefaultAllocator::deallocate(), fme_apply::FMEqualizer::equalize(), moco::PlaneInference::fill(), luci_interpreter::kernels::fillArithmeticActivationRange(), training_configure_tool::findAllTensorsRanksCombinations(), training_configure_tool::findBestSparseBackpropagationTensorsRanks(), flatbuffers::FloatToString(), nnkit::support::onnx::Allocator::Free(), pepper::KVStoreInterface< KVStoreTrait::Queryable >::get(), onert::compiler::BackendManager::getAll(), onert_micro::import::OMDynamicShapesHandler::importDynamicShapesFromTrainConfig(), moco::PlaneInference::infer(), main(), nnfw::cker::optimized::MulElementwise(), nnfw::cker::optimized::MulElementwise(), nnfw::cker::optimized::MulSimpleBroadcast(), NONIUS_LOCAL_BENCHMARK(), NONIUS_LOCAL_BENCHMARK(), NONIUS_LOCAL_BENCHMARK(), moco::tf::eltwise::binary::InputConnector< NodeTy >::operator()(), moco::PlaneInference::operator()(), moco::Padding2DInference::operator()(), bino::UniformTransform< Callable >::operator()(), nnfw::cker::depthwise_conv_op::functor::DepthwiseInputCopyOp< T >::operator()(), flatbuffers::unique_ptr< T >::operator=(), loco::PermutingEncoder< Domain::DepthwiseFilter >::perm(), loco::PermutingDecoder< Domain::DepthwiseFilter >::perm(), loco::PermutingEncoder< Domain::Feature >::perm(), loco::PermutingDecoder< Domain::Feature >::perm(), loco::PermutingEncoder< Domain::Filter >::perm(), loco::PermutingDecoder< Domain::Filter >::perm(), loco::PermutingEncoder< Domain::Matrix >::perm(), loco::PermutingDecoder< Domain::Matrix >::perm(), fme_apply::read(), flatbuffers::IndirectHelper< T >::Read(), flatbuffers::IndirectHelper< Offset< T > >::Read(), flatbuffers::IndirectHelper< const T * >::Read(), read_layer_params(), tflite::reference_ops::ReverseSequence(), logo::SimplifyDomainConversionPass::run(), luci::QuantizeOnnxDequantizeLinearPass::run(), luci::QuantizeOnnxQDQPass::run(), onert_micro::train::OMBackpropExecute::runBackward(), nnfw::cker::StridedSlicePadIndices(), nnfw::cker::Transpose2D(), onert::exec::ExecTime::updateOperationExecTime(), coco::updaters(), nnc::ArtifactGeneratorCppCode::visit(), nnc::ArtifactGeneratorCppDecl::visit(), fipe::wrap(), and fme_detect::write().

◆ src_tensor

◆ try

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

Definition at line 301 of file Convolution.cpp.