ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
kbenchmark::kernels::acl_common Namespace Reference

Data Structures

struct  PaddingInfo
 

Functions

PaddingInfo calculatePadding (const std::string &padding_name, const uint32_t ifm_H, const uint32_t ifm_W, const uint32_t ofm_H, const uint32_t ofm_W, const uint32_t vertical_stride, const uint32_t horizontal_stride, const uint32_t ker_H, const uint32_t ker_W)
 
PadStrideInfo asPadStrideInfo (const PaddingInfo &padding, uint32_t vertical_stride, uint32_t horizontal_stride)
 
ActivationLayerInfo asActivationLayerInfo (const std::string &act_name)
 

Function Documentation

◆ asActivationLayerInfo()

ActivationLayerInfo kbenchmark::kernels::acl_common::asActivationLayerInfo ( const std::string &  act_name)

Definition at line 82 of file Utils.h.

83{
84 if (act_name == "NONE")
85 {
86 return ActivationLayerInfo{};
87 }
88 else if (act_name == "RELU")
89 {
90 return ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU};
91 }
92 else
93 {
94 throw std::runtime_error{"Not support activation layer info"};
95 }
96}

◆ asPadStrideInfo()

PadStrideInfo kbenchmark::kernels::acl_common::asPadStrideInfo ( const PaddingInfo padding,
uint32_t  vertical_stride,
uint32_t  horizontal_stride 
)

◆ calculatePadding()

PaddingInfo kbenchmark::kernels::acl_common::calculatePadding ( const std::string &  padding_name,
const uint32_t  ifm_H,
const uint32_t  ifm_W,
const uint32_t  ofm_H,
const uint32_t  ofm_W,
const uint32_t  vertical_stride,
const uint32_t  horizontal_stride,
const uint32_t  ker_H,
const uint32_t  ker_W 
)

Definition at line 39 of file Utils.h.

43{
44 uint32_t top;
45 uint32_t bottom;
46 uint32_t left;
47 uint32_t right;
48
49 if (padding_name == "VALID")
50 {
51 top = bottom = left = right = 0;
52 }
53 else if (padding_name == "SAME")
54 {
55 const int32_t vertical_needed_input = (ofm_H - 1) * vertical_stride + ker_H;
56 const int32_t vertical_total_padding = std::max(0, vertical_needed_input - (int32_t)ifm_H);
57
58 const int32_t horizontal_needed_input = (ofm_W - 1) * horizontal_stride + ker_W;
59 const int32_t horizontal_total_padding = std::max(0, horizontal_needed_input - (int32_t)ifm_W);
60
61 top = vertical_total_padding / 2;
62 bottom = (vertical_total_padding + 1) / 2;
63 left = horizontal_total_padding / 2;
64 right = (horizontal_total_padding + 1) / 2;
65 }
66
67 return PaddingInfo{top, bottom, left, right};
68}