ONE - On-device Neural Engine
Loading...
Searching...
No Matches
PoolLayer.cc File Reference
#include "PoolLayer.h"
#include <cker/operation/AveragePool.h>
#include <cker/operation/MaxPool.h>
#include <unordered_map>

Go to the source code of this file.

Namespaces

namespace  onert
 
namespace  onert::backend
 
namespace  onert::backend::cpu
 
namespace  onert::backend::cpu::ops
 

Macros

#define POOLING_PARAMETERS
 

Macro Definition Documentation

◆ POOLING_PARAMETERS

#define POOLING_PARAMETERS
Value:
op_params.stride_height = strideHeight; \
op_params.stride_width = strideWidth; \
op_params.filter_height = kernelHeight; \
op_params.filter_width = kernelWidth; \
op_params.padding_values.height = (int8_t)paddingTop; \
op_params.padding_values.width = (int8_t)paddingLeft; \
op_params.float_activation_min = 0; \
op_params.float_activation_max = 0; \
op_params.quantized_activation_min = 0; \
op_params.quantized_activation_max = 0;
float float_activation_max
Definition Types.h:99
int32_t quantized_activation_min
Definition Types.h:95
int32_t quantized_activation_max
Definition Types.h:96
float float_activation_min
Definition Types.h:98
PaddingValues padding_values
Definition Types.h:89

Definition at line 75 of file PoolLayer.cc.

92{
93 assert(input != nullptr);
94 assert(output != nullptr);
95
96 _input = input;
97 _output = output;
98
100
101 switch (_input->data_type())
102 {
103 case OperandType::FLOAT32:
104 {
105 float output_activation_min = 0;
106 float output_activation_max = 0;
107 CalculateActivationRange<float>(activation, &output_activation_min, &output_activation_max);
108 op_params.float_activation_min = output_activation_min;
109 op_params.float_activation_max = output_activation_max;
110
111 _kernel = generateKernelGeneric<float>(op_params, op_type);
112 break;
113 }
114 case OperandType::QUANT_UINT8_ASYMM:
115 {
116 int32_t output_activation_min = 0;
117 int32_t output_activation_max = 0;
118 CalculateActivationRangeQuantized(activation, _output, &output_activation_min,
119 &output_activation_max);
120 op_params.quantized_activation_min = output_activation_min;
121 op_params.quantized_activation_max = output_activation_max;
122 _kernel = generateKernelGeneric<uint8_t>(op_params, op_type);
123 break;
124 }
125 case OperandType::QUANT_INT8_ASYMM:
126 {
127 int32_t output_activation_min = 0;
128 int32_t output_activation_max = 0;
129 CalculateActivationRangeQuantized(activation, _output, &output_activation_min,
130 &output_activation_max);
131 op_params.quantized_activation_min = output_activation_min;
132 op_params.quantized_activation_max = output_activation_max;
133 _kernel = generateKernelGeneric<int8_t>(op_params, op_type);
134 break;
135 }
136 default:
137 throw std::runtime_error{"Pool: unsupported data type"};
138 }
139}
140
141void PoolLayer::run() { _kernel(_input, _output); }
142
143#undef AVGPOOLING_PARAMETERS
144
145} // namespace ops
146} // namespace cpu
147} // namespace backend
148} // namespace onert
#define POOLING_PARAMETERS
Definition PoolLayer.cc:75
void CalculateActivationRangeQuantized(ir::Activation activation, const IPortableTensor *output, int32_t *act_min, int32_t *act_max)