Compute Library
 21.02
NEFullyConnectedLayer.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
25 
43 
44 #include <algorithm>
45 #include <cmath>
46 
47 namespace arm_compute
48 {
50 
51 namespace
52 {
53 // Get min, max bound of a quantized assymetric output tensor, with the effect of fused activation
54 std::pair<PixelValue, PixelValue> get_quantized_asymmetric_output_min_max(const QuantizationInfo &q_info, const ActivationLayerInfo &act_info, DataType data_type)
55 {
56  PixelValue type_min{};
57  PixelValue type_max{};
58  std::tie(type_min, type_max) = get_min_max(data_type);
59  const UniformQuantizationInfo q_unif = q_info.uniform();
60 
61  if(act_info.enabled())
62  {
63  switch(act_info.activation())
64  {
66  type_min = PixelValue(q_unif.offset);
67  break;
69  type_min = PixelValue(q_unif.offset);
70  type_max = PixelValue(act_info.a(), data_type, q_info);
71  break;
73  type_min = PixelValue(act_info.b(), data_type, q_info);
74  type_max = PixelValue(act_info.a(), data_type, q_info);
75  break;
76  default:
77  ARM_COMPUTE_ERROR("Activation function not supported.");
78  break;
79  }
80  }
81 
82  return std::make_pair(type_min, type_max);
83 }
84 
85 Status get_gemmlowp_output_stage_info(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *output, const ActivationLayerInfo &act,
86  GEMMLowpOutputStageInfo &gemmlowp_output_stage_info)
87 {
88  const auto data_type = input->data_type();
89  const QuantizationInfo oq_info = output->quantization_info();
90  const UniformQuantizationInfo iq_unif = input->quantization_info().uniform();
91  const UniformQuantizationInfo wq_unif = weights->quantization_info().uniform();
92  const UniformQuantizationInfo oq_unif = oq_info.uniform();
93 
94  float multiplier = (iq_unif.scale * wq_unif.scale) / oq_unif.scale;
95  int32_t output_multiplier;
96  int32_t output_shift;
97 
98  ARM_COMPUTE_RETURN_ON_ERROR(quantization::calculate_quantized_multiplier(multiplier, &output_multiplier, &output_shift));
99 
100  PixelValue type_min{};
101  PixelValue type_max{};
102  std::tie(type_min, type_max) = get_quantized_asymmetric_output_min_max(oq_info, act, data_type);
103 
104  gemmlowp_output_stage_info.gemmlowp_multiplier = output_multiplier;
105  gemmlowp_output_stage_info.gemmlowp_shift = output_shift;
106  gemmlowp_output_stage_info.gemmlowp_offset = oq_unif.offset;
107  gemmlowp_output_stage_info.type = GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT;
108  gemmlowp_output_stage_info.gemmlowp_min_bound = type_min.get<int32_t>();
109  gemmlowp_output_stage_info.gemmlowp_max_bound = type_max.get<int32_t>();
110 
111  return Status{};
112 }
113 
114 Status validate_mm(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const ActivationLayerInfo &act)
115 {
116  if(is_data_type_quantized_asymmetric(input->data_type()))
117  {
118  // Since we need negative offsets for computing convolution, we need to change QuantizationInfo()
119  // Extract and negate input and weights offset
120  const QuantizationInfo input_quantization_info(input->quantization_info().uniform().scale, -input->quantization_info().uniform().offset);
121  const QuantizationInfo weights_quantization_info(weights->quantization_info().uniform().scale, -weights->quantization_info().uniform().offset);
122 
123  GEMMLowpOutputStageInfo gemmlowp_output_stage_info;
124  ARM_COMPUTE_RETURN_ON_ERROR(get_gemmlowp_output_stage_info(input, weights, output, act, gemmlowp_output_stage_info));
125 
126  GEMMInfo gemm_info;
127  gemm_info.set_gemmlowp_output_stage(gemmlowp_output_stage_info);
128 
129  // Validate gemmlowp function
130  ARM_COMPUTE_RETURN_ON_ERROR(NEGEMMLowpMatrixMultiplyCore::validate(&input->clone()->set_quantization_info(input_quantization_info),
131  &weights->clone()->set_quantization_info(weights_quantization_info),
132  biases,
133  output,
134  gemm_info));
135  }
136  else
137  {
138  ARM_COMPUTE_RETURN_ON_ERROR(NEGEMM::validate(input, weights, biases, output, 1.f, 1.0f, GEMMInfo(false, false, true /* Reshape weights only for the first run */)));
139  }
140 
141  return Status{};
142 }
143 } // namespace
144 
146 {
147  auto k = std::make_unique<NETransposeKernel>();
148  k->configure(input, output);
149  _kernel = std::move(k);
150 }
151 
153 {
154  return NETransposeKernel::validate(input, output);
155 }
156 
158 
159 NEFullyConnectedLayer::NEFullyConnectedLayer(std::shared_ptr<IMemoryManager> memory_manager, IWeightsManager *weights_manager)
160  : _memory_group(std::move(memory_manager)), _weights_manager(weights_manager), _flatten(), _convert_weights(), _convert_weights_managed(), _reshape_weights_function(),
161  _reshape_weights_managed_function(), _mm_gemm(nullptr, weights_manager), _mm_gemmlowp(nullptr, weights_manager), _flatten_output(), _converted_weights_output(), _reshape_weights_output(),
162  _original_weights(nullptr), _are_weights_converted(true), _are_weights_reshaped(false), _is_fc_after_conv(false), _is_quantized_asymmetric(false), _is_prepared(false)
163 {
164 }
165 
166 void NEFullyConnectedLayer::configure_mm(const ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *output, const ActivationLayerInfo &act)
167 {
168  if(_is_quantized_asymmetric)
169  {
170  // Since we need negative offsets for computing convolution, we need to change QuantizationInfo()
171  // Extract and negate input and weights offset
172  const QuantizationInfo input_quantization_info = input->info()->quantization_info();
173  const QuantizationInfo weights_quantization_info = weights->info()->quantization_info();
174 
175  input->info()->set_quantization_info(QuantizationInfo(input_quantization_info.uniform().scale, -input_quantization_info.uniform().offset));
176  weights->info()->set_quantization_info(QuantizationInfo(weights_quantization_info.uniform().scale, -weights_quantization_info.uniform().offset));
177 
178  // Configure gemmlowp function and output stage for asymmetric quantized types
179  GEMMLowpOutputStageInfo gemmlowp_output_stage_info;
180  const Status status = get_gemmlowp_output_stage_info(input->info(), weights->info(), output->info(), act, gemmlowp_output_stage_info);
182 
183  GEMMInfo gemm_info;
184  gemm_info.set_gemmlowp_output_stage(gemmlowp_output_stage_info);
185  gemm_info.set_activation_info(act);
186  _mm_gemmlowp.configure(input, weights, biases, output, gemm_info);
187 
188  // Revert back QuantizatioInfo as input and weights could be used in other fully connected layers
189  input->info()->set_quantization_info(input_quantization_info);
190  weights->info()->set_quantization_info(weights_quantization_info);
191  }
192  else
193  {
194  // Configure matrix multiply kernel
195  GEMMInfo gemm_info(false, false, true /* Reshape weights only for the first run */);
196  gemm_info.set_activation_info(act);
197  _mm_gemm.configure(input, weights, biases, output, 1.f, 1.0f, gemm_info);
198  }
199 }
200 
201 void NEFullyConnectedLayer::configure_conv_fc(const ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *output, const ActivationLayerInfo &act)
202 {
203  ARM_COMPUTE_ERROR_ON((weights->info()->dimension(1) != (input->info()->dimension(0) * input->info()->dimension(1) * input->info()->dimension(2))));
204 
205  // If the fully connected layer is called after a convolution layer, the input tensor must be linearized
206 
207  // Initialize output tensor for flatten
208  TensorShape shape_flatten = compute_flatten_shape(input->info());
209  _flatten_output.allocator()->init(input->info()->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(shape_flatten));
210 
211  // Configure flatten kernel
212  _memory_group.manage(&_flatten_output);
213 
214  _flatten.configure(input, &_flatten_output);
215 
216  // Configure matrix multiply kernel
217  configure_mm(&_flatten_output, weights, biases, output, act);
218 
219  // Allocate the output tensor for flatten once all the configure methods have been called
220  _flatten_output.allocator()->allocate();
221 }
222 
223 void NEFullyConnectedLayer::configure_fc_fc(const ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *output, const ActivationLayerInfo &act)
224 {
225  ARM_COMPUTE_ERROR_ON(input->info()->dimension(0) != weights->info()->dimension(1));
226 
227  // Configure matrix multiply kernel
228  configure_mm(input, weights, biases, output, act);
229 }
230 
231 void NEFullyConnectedLayer::configure(const ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *output,
232  FullyConnectedLayerInfo fc_info)
233 {
234  // Perform validate step
235  ARM_COMPUTE_ERROR_ON_NULLPTR(input, weights, output);
237  weights->info(),
238  biases != nullptr ? biases->info() : nullptr,
239  output->info(),
240  fc_info));
241 
242  _are_weights_converted = true;
243  _are_weights_reshaped = fc_info.transpose_weights ? fc_info.are_weights_reshaped : true;
244  _is_fc_after_conv = true;
245  _is_quantized_asymmetric = is_data_type_quantized_asymmetric(input->info()->data_type());
246  _original_weights = weights;
247 
248  if(_weights_manager)
249  {
250  _weights_manager->manage(weights);
251  }
252 
253  // With the Fully Connected layer we can have 4 different cases:
254  // 1) Convolution layer -> Fully Connected layer without batches
255  // 2) Fully Connected layer -> Fully Connected layer without batches
256  // 3) Convolution layer -> Fully Connected layer with batches
257  // 4) Fully Connected layer -> Fully Connected layer with batches
258 
259  const ITensor *weights_to_use = weights;
260 
261  // Check if we have a fully connected layer with batches
262  const bool is_batched_fc_layer = output->info()->dimension(1) > 1;
263  if(is_batched_fc_layer)
264  {
265  _is_fc_after_conv = (TensorShape::num_max_dimensions >= 4) && (std::equal(input->info()->tensor_shape().cbegin() + 3,
266  input->info()->tensor_shape().cend(),
267  output->info()->tensor_shape().cbegin() + 1));
268  }
269  else
270  {
271  _is_fc_after_conv = input->info()->num_dimensions() > 1;
272  }
273 
274  // Reshape weights if needed
275  if(!_are_weights_reshaped)
276  {
277  if(_weights_manager && _weights_manager->are_weights_managed(weights))
278  {
279  _reshape_weights_managed_function.configure(weights);
280  weights_to_use = _weights_manager->acquire(weights, &_reshape_weights_managed_function);
281  }
282  else
283  {
284  // Reshape the weights
285  _reshape_weights_function.configure(weights, &_reshape_weights_output);
286  weights_to_use = &_reshape_weights_output;
287  }
288  }
289 
290  // Convert weights if needed
291  if(_is_fc_after_conv && (input->info()->data_layout() != fc_info.weights_trained_layout))
292  {
293  if(_weights_manager && _weights_manager->are_weights_managed(weights_to_use))
294  {
295  _convert_weights_managed.configure(weights_to_use,
296  input->info()->tensor_shape(),
297  fc_info.weights_trained_layout);
298  weights_to_use = _weights_manager->acquire(weights, &_convert_weights_managed);
299  }
300  else
301  {
302  // Convert weights
303  _convert_weights.configure(weights_to_use,
304  &_converted_weights_output,
305  input->info()->tensor_shape(),
306  fc_info.weights_trained_layout);
307 
308  weights_to_use = &_converted_weights_output;
309  }
310  _are_weights_converted = false;
311  }
312 
313  if(_is_fc_after_conv)
314  {
315  // Fully Connected layer after a Convolution Layer without batches
316  configure_conv_fc(input, weights_to_use, biases, output, fc_info.activation_info);
317  }
318  else
319  {
320  // Fully Connected layer after a Fully Connected Layer without batches
321  configure_fc_fc(input, weights_to_use, biases, output, fc_info.activation_info);
322  }
323 
324  _are_weights_reshaped = _are_weights_reshaped || fc_info.retain_internal_weights;
325 }
326 
327 Status NEFullyConnectedLayer::validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output,
328  FullyConnectedLayerInfo fc_info)
329 {
331  ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, weights, output);
335  ARM_COMPUTE_RETURN_ERROR_ON(biases != nullptr && biases->num_dimensions() > 1);
338 
339  bool weights_reshaped = fc_info.transpose_weights ? fc_info.are_weights_reshaped : true;
340  bool is_fc_after_conv = true;
341 
342  const ITensorInfo &flatten_input = TensorInfo(input->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(compute_flatten_shape(input)));
343  const ITensorInfo &reshaped_weights = TensorInfo(weights->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(compute_transposed_shape(*weights)));
344  const ITensorInfo &converted_weights = weights_reshaped ? TensorInfo(weights->clone()->set_is_resizable(true).reset_padding()) : TensorInfo(*reshaped_weights.clone());
345 
346  // With the Fully Connected layer we can have 4 different cases:
347  // 1) Convolution layer -> Fully Connected layer without batches
348  // 2) Fully Connected layer -> Fully Connected layer without batches
349  // 3) Convolution layer -> Fully Connected layer with batches
350  // 4) Fully Connected layer -> Fully Connected layer with batches
351 
352  const ITensorInfo *input_to_use = input;
353  const ITensorInfo *weights_to_use = weights;
354 
355  // Check if we have a fully connected layer with batches
356  const bool is_batched_fc_layer = output->dimension(1) > 1;
357 
358  if(is_batched_fc_layer)
359  {
360  is_fc_after_conv = (TensorShape::num_max_dimensions >= 4) && (std::equal(input->tensor_shape().cbegin() + 3,
361  input->tensor_shape().cend(),
362  output->tensor_shape().cbegin() + 1));
363  }
364  else
365  {
366  is_fc_after_conv = input->num_dimensions() > 1;
367  }
368 
369  if(!weights_reshaped)
370  {
371  // Validate reshape weights kernel
373  weights_to_use = &reshaped_weights;
374  }
375 
376  if(is_fc_after_conv && (input->data_layout() != fc_info.weights_trained_layout))
377  {
378  // Validate convert weights kernel
380  &converted_weights,
381  input->tensor_shape(),
382  fc_info.weights_trained_layout));
383  weights_to_use = &converted_weights;
384  }
385 
386  if(is_fc_after_conv)
387  {
388  // Fully Connected layer after a Convolution Layer without batches
389  ARM_COMPUTE_RETURN_ERROR_ON((weights_to_use->dimension(1) != (input->dimension(0) * input->dimension(1) * input->dimension(2))));
390 
391  // Validate flatten kernel
393  input_to_use = &flatten_input;
394  }
395  else
396  {
397  // Fully Connected layer after a Fully Connected Layer without batches
398  ARM_COMPUTE_RETURN_ERROR_ON(input->dimension(0) != weights_to_use->dimension(1));
399  }
400  // Validate matrix multiply kernel
401  ARM_COMPUTE_RETURN_ON_ERROR(validate_mm(input_to_use, weights_to_use, biases, output, fc_info.activation_info));
402 
403  return Status{};
404 }
405 
407 {
408  prepare();
409 
410  MemoryGroupResourceScope scope_mg(_memory_group);
411 
412  // Linearize input if it comes from a convolutional layer
413  if(_is_fc_after_conv)
414  {
415  _flatten.run();
416  }
417 
418  // Run matrix multiply
419  if(_is_quantized_asymmetric)
420  {
421  _mm_gemmlowp.run();
422  }
423  else
424  {
425  _mm_gemm.run();
426  }
427 }
428 
430 {
431  if(!_is_prepared)
432  {
433  if(!_weights_manager)
434  {
435  ARM_COMPUTE_ERROR_ON(!_original_weights->is_used());
436  }
437 
438  auto release_unused = [](Tensor * w)
439  {
440  if(!w->is_used())
441  {
442  w->allocator()->free();
443  }
444  };
445 
446  // Pointer to current weights
447  const ITensor *cur_weights = _original_weights;
448 
449  // Reshape of the weights (happens only once)
450  if(!_are_weights_reshaped)
451  {
452  if(_weights_manager && _weights_manager->are_weights_managed(_original_weights))
453  {
454  cur_weights = _weights_manager->run(cur_weights, &_reshape_weights_managed_function);
455  }
456  else
457  {
458  // Reshape of the weights (happens only once)
459  if(!_are_weights_reshaped)
460  {
461  // Run reshape weights kernel and mark weights as unused
462  _reshape_weights_output.allocator()->allocate();
463  _reshape_weights_function.run();
464  }
465  cur_weights->mark_as_unused();
466  cur_weights = &_reshape_weights_output;
467  }
468  _are_weights_reshaped = true;
469  }
470 
471  // Convert weights if needed (happens only once)
472  if(!_are_weights_converted)
473  {
474  if(_weights_manager && _weights_manager->are_weights_managed(cur_weights))
475  {
476  _weights_manager->run(cur_weights, &_convert_weights_managed);
477  }
478  else
479  {
480  _converted_weights_output.allocator()->allocate();
481  _convert_weights.run();
482  cur_weights->mark_as_unused();
483  }
484 
485  _are_weights_converted = true;
486  }
487 
488  // Release reshaped weights if unused
489  release_unused(&_reshape_weights_output);
490 
491  // Prepare GEMM prepare and release unused weights
492  if(!_is_quantized_asymmetric)
493  {
494  _mm_gemm.prepare();
495  }
496 
497  // Release converted weights if unused
498  release_unused(&_reshape_weights_output);
499  release_unused(&_converted_weights_output);
500 
501  _is_prepared = true;
502  }
503 }
504 } // namespace arm_compute
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Definition: Utils.h:1168
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
SimpleTensor< float > w
Definition: DFT.cpp:156
Shape of a tensor.
Definition: TensorShape.h:39
Quantize using a fixed point multiplication.
void run() override final
Run the kernels contained in the function.
void set_activation_info(const ActivationLayerInfo &activation_info)
Set activation layer info.
Definition: Types.h:2162
void init(const TensorAllocator &allocator, const Coordinates &coords, TensorInfo &sub_info)
Shares the same backing memory with another tensor allocator, while the tensor info might be differen...
bool enabled() const
Check if initialised.
Definition: Types.h:1600
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
bool retain_internal_weights
Retain internal reshaped weights.
Definition: Types.h:1618
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
virtual DataType data_type() const =0
Data type used for each element of the tensor.
bool is_used() const
Flags if the tensor is used or not.
Definition: ITensor.cpp:163
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
Fully connected layer info.
Definition: Types.h:1613
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
Status calculate_quantized_multiplier(float multiplier, int32_t *quant_multiplier, int32_t *shift, bool ignore_epsilon=false)
Calculate quantized representation of multiplier.
void manage(const ITensor *weights, ITransformWeights *parent=nullptr)
Start managing a weights tensor.
Status class.
Definition: Error.h:52
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Definition: Error.h:296
Activation Layer Information class.
Definition: Types.h:1550
Interface for Neon tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2021 Arm Limited.
1 channel, 1 F16 per channel
TensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: Tensor.cpp:48
TensorShape compute_transposed_shape(const ITensorInfo &input)
Calculate the transposed shape of a tensor.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:163
void mark_as_unused() const
Marks a tensor as unused.
Definition: ITensor.cpp:168
static Status validate(const ITensorInfo *input, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEFullyConnectedLayerRes...
void manage(IMemoryManageable *obj) override
Sets a object to be managed by the given memory group.
Definition: MemoryGroup.h:79
bool are_weights_managed(const ITensor *weights)
Check if the weights are managed.
TensorShape compute_flatten_shape(const ITensorInfo *input)
Calculate the flattened output shape of a tensor.
const DataType data_type
Definition: Im2Col.cpp:150
static Status validate(const ITensorInfo *a, const ITensorInfo *b, const ITensorInfo *c, const ITensorInfo *output, float alpha, float beta, const GEMMInfo &gemm_info=GEMMInfo())
Static function to check if given info will lead to a valid configuration of NEGEMM.
Definition: NEGEMM.cpp:190
Quantization information.
void run() override
Run the kernels contained in the function.
void run() override
Run the kernels contained in the function.
Definition: NEGEMM.cpp:309
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
void configure(const ITensor *a, const ITensor *b, const ITensor *c, ITensor *output, const GEMMInfo &gemm_info=GEMMInfo())
Initialise the kernel&#39;s inputs, output.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
void run() override
Run the kernels contained in the function.
quantized, asymmetric fixed-point 8-bit number unsigned
bool are_weights_reshaped
Reshape the weights tensor if false.
Definition: Types.h:1617
void configure(const ITensor *input, ITensor *output)
Initialise the kernel&#39;s input and output.
void configure(const ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *output, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo())
Set the input and output tensors.
void allocate() override
Allocate size specified by TensorInfo of CPU memory.
NEFullyConnectedLayer(std::shared_ptr< IMemoryManager > memory_manager=nullptr, IWeightsManager *weights_manager=nullptr)
Constructor.
UniformQuantizationInfo uniform() const
Return per layer quantization info.
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
GEMMLowp output stage info.
Definition: Types.h:1952
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
void configure(const ITensor *input, const TensorShape &original_input_shape, DataLayout data_layout)
Basic implementation of the tensor interface.
Definition: Tensor.h:37
virtual ITensorInfo & set_quantization_info(const QuantizationInfo &quantization_info)=0
Set the quantization settings (scale and offset) of the tensor.
static Status validate(const ITensorInfo *input, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NETransposeKernel.
ActivationLayerInfo activation_info
Fused activation to apply after the matrix multiplication.
Definition: Types.h:1620
Weights manager interface to handle weights transformations.
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
void configure(const ITensor *input, ITensor *output, const TensorShape &original_input_shape, DataLayout data_layout)
Initialize the function.
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1190
__constant DATA_TYPE16 type_min
Definition: minmaxloc.cl:46
std::array< T, num_max_dimensions >::const_iterator cend() const
Returns a read-only (constant) iterator that points one past the last element in the dimension array...
Definition: Dimensions.h:255
std::array< T, num_max_dimensions >::const_iterator cbegin() const
Returns a read-only (constant) iterator that points to the first element in the dimension array...
Definition: Dimensions.h:231
~NEFullyConnectedLayer()
Default destructor.
Memory group resources scope handling class.
Definition: IMemoryGroup.h:82
void set_gemmlowp_output_stage(GEMMLowpOutputStageInfo &output_stage)
Sets GEMMLowp output stage.
Definition: Types.h:2114
void run() override
Run the kernels contained in the function.
static Status validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo())
Static function to check if given info will lead to a valid configuration of NEFullyConnectedLayer.
DataLayout weights_trained_layout
Layout that the weights have been trained with.
Definition: Types.h:1615
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:545
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const TensorShape &original_input_shape, DataLayout data_layout)
Static function to check if given info will lead to a valid configuration of NEConvertFullyConnectedW...
void configure(const ITensor *a, const ITensor *b, const ITensor *c, ITensor *d, float alpha, float beta, const GEMMInfo &gemm_info=GEMMInfo())
Initialise the kernel&#39;s inputs, output.
Definition: NEGEMM.cpp:72
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:792
void prepare() override
Prepare the function for executing.
Definition: NEGEMM.cpp:359
__constant DATA_TYPE16 type_max
Definition: minmaxloc.cl:47
bool transpose_weights
Transpose weights if true.
Definition: Types.h:1616
void configure(const ITensor *input, ITensor *output)
Set the input and output tensors.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
Store the tensor&#39;s metadata.
Definition: TensorInfo.h:45
static Status validate(const ITensorInfo *a, const ITensorInfo *b, const ITensorInfo *c, const ITensorInfo *output, const GEMMInfo &gemm_info=GEMMInfo())
Static function to check if given info will lead to a valid configuration of NEGEMMLowpMatrixMultiply...
GEMM information class.
Definition: Types.h:2003
static Status validate(const ITensorInfo *input, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEFlattenLayer.
ITensor * run(const ITensor *weights, ITransformWeights *weights_transform)
Run the reshape function.
ActivationFunction activation() const
Get the type of activation function.
Definition: Types.h:1585
quantized, asymmetric fixed-point 8-bit number signed
void prepare() override
Prepare the function for executing.
static constexpr size_t num_max_dimensions
Number of dimensions the tensor has.
Definition: Dimensions.h:46
DataType
Available data types.
Definition: Types.h:77
std::tuple< PixelValue, PixelValue > get_min_max(DataType dt)
Compute the mininum and maximum values a data type can take.
Definition: Utils.h:564
ErrorCode error_code() const
Gets error code.
Definition: Error.h:89
ITensor * acquire(const ITensor *weights, ITransformWeights *weights_transform)
Acquire the requested reshape tensor of the selected weights.
void run() override
Run the kernels contained in the function.
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.