ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnfw::cker::Conv Class Reference

#include <Conv.h>

Public Member Functions

 Conv ()
 
void prepareF32 (const Shape &filter_shape, const float *filter_data, PaddingType padding_type, bool &is_replaced_weights, uint32_t dilationWidthFactor, uint32_t dilationHeightFactor)
 
void prepareQ8uPerTensor (const Shape &input_shape, const Shape &kernel_shape, const Shape &output_shape, uint32_t stride_width, uint32_t stride_height, uint32_t dilation_width_factor, uint32_t dilation_height_factor)
 
void operator() (const ConvParams &params, const Shape &input_shape, const float *input_data, const Shape &filter_shape, const float *filter_data, const Shape &bias_shape, const float *bias_data, const Shape &output_shape, float *output_data)
 
void operator() (const ConvParams &params, const Shape &input_shape, const uint8_t *input_data, const Shape &filter_shape, const uint8_t *filter_data, const Shape &bias_shape, const int32_t *bias_data, const Shape &output_shape, uint8_t *output_data)
 
void operator() (const ConvParams &params, const Shape &input_shape, const uint8_t *input_data, const Shape &filter_shape, const uint8_t *filter_data, const int32_t *filter_zero_point, const Shape &bias_shape, const int32_t *bias_data, const Shape &output_shape, uint8_t *output_data)
 
void operator() (const ConvParams &params, const Shape &input_shape, const int8_t *input_data, const Shape &filter_shape, const int8_t *filter_data, const Shape &bias_shape, const int32_t *bias_data, const Shape &output_shape, int8_t *output_data)
 
std::vector< int32_t > & per_channel_output_multiplier ()
 
std::vector< int > & per_channel_output_shift ()
 

Detailed Description

Definition at line 55 of file Conv.h.

Constructor & Destructor Documentation

◆ Conv()

nnfw::cker::Conv::Conv ( )
inline

Definition at line 58 of file Conv.h.

58: _modified_filter_data(), _im2col_shape(4), _need_im2col(false), _prepared(false) {}

Member Function Documentation

◆ operator()() [1/4]

void nnfw::cker::Conv::operator() ( const ConvParams params,
const Shape input_shape,
const float *  input_data,
const Shape filter_shape,
const float *  filter_data,
const Shape bias_shape,
const float *  bias_data,
const Shape output_shape,
float *  output_data 
)
inline

Definition at line 86 of file Conv.h.

89 {
90 if (usableMultiThreaded(params.padding_type, params.dilation_width_factor,
91 params.dilation_height_factor))
92 {
93 bool transposed_in_execution = false;
94 if (!_prepared)
95 {
96 // This means that filter is not constant
97 // TODO Apply optimized kernel if multithreaded kernel is slower than optimized kernel by
98 // transposing filter data
99 transposeFilter(filter_shape, filter_data, transposed_in_execution);
100 }
101 multithreaded::Conv(params, input_shape, input_data, filter_shape, &_modified_filter_data[0],
102 bias_shape, bias_data, output_shape, output_data);
103 }
104 else
105 {
106 // TODO Support optimized kernel
107 reference::Conv(params, input_shape, input_data, filter_shape, filter_data, bias_shape,
108 bias_data, output_shape, output_data);
109 }
110 }
const luci_interpreter::RuntimeShape output_shape
void Conv(const ConvParams &params, const Shape &input_shape, const float *input_data, const Shape &filter_shape, const float *filter_data, const Shape &bias_shape, const float *bias_data, const Shape &output_shape, float *output_data)
Definition Conv.h:254
void Conv(const ConvParams &params, const Shape &input_shape, const float *input_data, const Shape &filter_shape, const float *filter_data, const Shape &bias_shape, const float *bias_data, const Shape &output_shape, float *output_data)
Definition Conv.h:33

References nnfw::cker::multithreaded::Conv(), nnfw::cker::reference::Conv(), nnfw::cker::ConvParams::dilation_height_factor, nnfw::cker::ConvParams::dilation_width_factor, output_shape, and nnfw::cker::ConvParams::padding_type.

◆ operator()() [2/4]

void nnfw::cker::Conv::operator() ( const ConvParams params,
const Shape input_shape,
const int8_t *  input_data,
const Shape filter_shape,
const int8_t *  filter_data,
const Shape bias_shape,
const int32_t *  bias_data,
const Shape output_shape,
int8_t *  output_data 
)
inline

Definition at line 141 of file Conv.h.

144 {
145 reference::Conv<int8_t, false>(params, _per_channel_output_multiplier.data(),
146 _per_channel_output_shift.data(), input_shape, input_data,
147 filter_shape, filter_data, nullptr /* filter_zero_point */,
148 bias_shape, bias_data, output_shape, output_data);
149 }

References output_shape.

◆ operator()() [3/4]

void nnfw::cker::Conv::operator() ( const ConvParams params,
const Shape input_shape,
const uint8_t *  input_data,
const Shape filter_shape,
const uint8_t *  filter_data,
const int32_t *  filter_zero_point,
const Shape bias_shape,
const int32_t *  bias_data,
const Shape output_shape,
uint8_t *  output_data 
)
inline

Definition at line 130 of file Conv.h.

134 {
135 reference::Conv<uint8_t, true>(params, _per_channel_output_multiplier.data(),
136 _per_channel_output_shift.data(), input_shape, input_data,
137 filter_shape, filter_data, filter_zero_point, bias_shape,
138 bias_data, output_shape, output_data);
139 }

References output_shape.

◆ operator()() [4/4]

void nnfw::cker::Conv::operator() ( const ConvParams params,
const Shape input_shape,
const uint8_t *  input_data,
const Shape filter_shape,
const uint8_t *  filter_data,
const Shape bias_shape,
const int32_t *  bias_data,
const Shape output_shape,
uint8_t *  output_data 
)
inline

Definition at line 112 of file Conv.h.

115 {
116 if (!_prepared)
117 {
118 // This means that input or output are dynamic or filter is not constant
119 IsRequiredIm2col(input_shape, filter_shape, output_shape, params.stride_width,
120 params.stride_height, params.dilation_width_factor,
121 params.dilation_height_factor);
122 }
123
124 int im2col_size = _need_im2col ? _im2col_shape.FlatSize() : 1;
125 std::vector<uint8_t> im2col_data(im2col_size);
126 optimized::Conv(params, input_shape, input_data, filter_shape, filter_data, bias_shape,
127 bias_data, output_shape, output_data, _im2col_shape, im2col_data.data());
128 }
int FlatSize() const
Definition Shape.h:181
void Conv(const ConvParams &params, const Shape &input_shape, const uint8_t *input_data, const Shape &filter_shape, const uint8_t *filter_data, const Shape &bias_shape, const int32_t *bias_data, const Shape &output_shape, uint8_t *output_data, const Shape &im2col_shape, uint8_t *im2col_data)
Definition Conv.h:83

References nnfw::cker::optimized::Conv(), nnfw::cker::ConvParams::dilation_height_factor, nnfw::cker::ConvParams::dilation_width_factor, nnfw::cker::Shape::FlatSize(), output_shape, nnfw::cker::ConvParams::stride_height, and nnfw::cker::ConvParams::stride_width.

◆ per_channel_output_multiplier()

std::vector< int32_t > & nnfw::cker::Conv::per_channel_output_multiplier ( )
inline

Definition at line 150 of file Conv.h.

150{ return _per_channel_output_multiplier; }

Referenced by onert::backend::cpu::ops::ConvolutionLayer::prepare().

◆ per_channel_output_shift()

std::vector< int > & nnfw::cker::Conv::per_channel_output_shift ( )
inline

Definition at line 151 of file Conv.h.

151{ return _per_channel_output_shift; }

Referenced by onert::backend::cpu::ops::ConvolutionLayer::prepare().

◆ prepareF32()

void nnfw::cker::Conv::prepareF32 ( const Shape filter_shape,
const float *  filter_data,
PaddingType  padding_type,
bool &  is_replaced_weights,
uint32_t  dilationWidthFactor,
uint32_t  dilationHeightFactor 
)
inline

Definition at line 60 of file Conv.h.

63 {
64 if (!_prepared)
65 {
66 if (usableMultiThreaded(padding_type, dilationWidthFactor, dilationHeightFactor))
67 {
68 transposeFilter(filter_shape, filter_data, is_replaced_weights);
69 }
70 _prepared = true;
71 }
72 }

Referenced by onert::backend::cpu::ops::ConvolutionLayer::prepare().

◆ prepareQ8uPerTensor()

void nnfw::cker::Conv::prepareQ8uPerTensor ( const Shape input_shape,
const Shape kernel_shape,
const Shape output_shape,
uint32_t  stride_width,
uint32_t  stride_height,
uint32_t  dilation_width_factor,
uint32_t  dilation_height_factor 
)
inline

Definition at line 74 of file Conv.h.

77 {
78 if (!_prepared)
79 {
80 IsRequiredIm2col(input_shape, kernel_shape, output_shape, stride_width, stride_height,
81 dilation_width_factor, dilation_height_factor);
82 _prepared = true;
83 }
84 }

References output_shape.

Referenced by onert::backend::cpu::ops::ConvolutionLayer::prepare().


The documentation for this class was generated from the following file: