Compute Library
 19.08
NEFullyConnectedLayer Class Reference

Basic function to compute a Fully Connected layer on NEON. More...

#include <NEFullyConnectedLayer.h>

Collaboration diagram for NEFullyConnectedLayer:
[legend]

Public Member Functions

 NEFullyConnectedLayer (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 Constructor. More...
 
 NEFullyConnectedLayer (const NEFullyConnectedLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEFullyConnectedLayer (NEFullyConnectedLayer &&)=default
 Default move constructor. More...
 
NEFullyConnectedLayeroperator= (const NEFullyConnectedLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEFullyConnectedLayeroperator= (NEFullyConnectedLayer &&)=default
 Default move assignment operator. More...
 
void configure (const ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *output, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo())
 Set the input and output tensors. More...
 
void run () override
 Run the kernels contained in the function. More...
 
void prepare () override
 Prepare the function for executing. More...
 
- Public Member Functions inherited from IFunction
virtual ~IFunction ()=default
 Destructor. More...
 

Static Public Member Functions

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. More...
 

Detailed Description

Basic function to compute a Fully Connected layer on NEON.

This function calls the following NEON kernels:

  1. NEIm2ColKernel (called when the input comes from a convolutional layer)
  2. NEFullyConnectedLayerReshapeWeights (if are_weights_reshaped is set to false and transpose_weights is set to true ) (called once)
  3. NEGEMMMatrixMultiplyKernel or NEGEMMLowpMatrixMultiplyCore (if quantized asymmetric)
  4. NEGEMMMatrixAccumulateBiasesKernel or NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint (if quantized asymmetric) (if biases is not equal to nullptr)
Note
The fully connected layer accepts "weights" tensors only with 2 dimensions.

Definition at line 74 of file NEFullyConnectedLayer.h.

Constructor & Destructor Documentation

◆ NEFullyConnectedLayer() [1/3]

NEFullyConnectedLayer ( std::shared_ptr< IMemoryManager memory_manager = nullptr)

Constructor.

Definition at line 77 of file NEFullyConnectedLayer.cpp.

78  : _memory_group(std::move(memory_manager)), _flatten_kernel(), _convert_weights(), _reshape_weights_function(), _mm_gemm(), _mm_gemmlowp(), _gemmlowp_output_stage(), _accumulate_biases_kernel(),
79  _flatten_output(), _gemmlowp_output(), _converted_weights_output(), _reshape_weights_output(), _original_weights(nullptr), _are_weights_converted(true), _are_weights_reshaped(false),
80  _is_fc_after_conv(false), _accumulate_biases(false), _is_quantized(false), _is_prepared(false)
81 {
82 }

◆ NEFullyConnectedLayer() [2/3]

Prevent instances of this class from being copied (As this class contains pointers)

◆ NEFullyConnectedLayer() [3/3]

Default move constructor.

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
const ITensor weights,
const ITensor biases,
ITensor output,
FullyConnectedLayerInfo  fc_info = FullyConnectedLayerInfo() 
)

Set the input and output tensors.

Parameters
[in]inputSource tensor. Data type supported: QASYMM8/F16/F32.
[in]weightsWeights tensor. The weights must be 2 dimensional. If this function is called after a Convolution Layer, the (transposed) weights will have as many rows as the product of the first 3 input's dimensions. If it is called after another FullyConnected Layer, the (transposed) weights will have as many rows as the input's first dimension. Data type supported: Same as input.
[in]biasesBias tensor. Can be nullptr. Data type supported:Same as input.
[out]outputDestination tensor. Its shape should be equal to the output of a matrix multiplication between:
  • The output of im2col on the input and the (transposed) 2D weights, if the function is called after a Convolution Layer
  • The input tensor and the (transposed) 2D weights, if the function is called after another FullyConnected Layer. Data type supported: Same as input.
[in]fc_info(Optional) Fully connected layer additional info

Definition at line 139 of file NEFullyConnectedLayer.cpp.

141 {
142  ARM_COMPUTE_ERROR_ON_NULLPTR(input, weights, output);
143 
144  // Perform validate step
146  weights->info(),
147  biases != nullptr ? biases->info() : nullptr,
148  output->info(),
149  fc_info));
150 
151  _are_weights_converted = true;
152  _are_weights_reshaped = fc_info.transpose_weights ? fc_info.are_weights_reshaped : true;
153  _is_fc_after_conv = true;
154  _accumulate_biases = false;
155  _is_quantized = is_data_type_quantized_asymmetric(input->info()->data_type());
156  _original_weights = weights;
157 
158  // Configure gemmlowp output
159  if(_is_quantized)
160  {
161  _gemmlowp_output.allocator()->init(output->info()->clone()->set_is_resizable(true).reset_padding().set_data_type(DataType::S32));
162  }
163 
164  // Configure accumulate biases kernel for non quantized asymmetric types
165  if(biases != nullptr && !_is_quantized)
166  {
167  _accumulate_biases = true;
168 
169  // Configure accumulate biases kernel
170  _accumulate_biases_kernel.configure(output, biases);
171  }
172 
173  // With the Fully Connected layer we can have 4 different cases:
174  // 1) Convolution layer -> Fully Connected layer without batches
175  // 2) Fully Connected layer -> Fully Connected layer without batches
176  // 3) Convolution layer -> Fully Connected layer with batches
177  // 4) Fully Connected layer -> Fully Connected layer with batches
178 
179  const ITensor *weights_to_use = weights;
180 
181  // Check if we have a fully connected layer with batches
182  const bool is_batched_fc_layer = output->info()->dimension(1) > 1;
183  if(is_batched_fc_layer)
184  {
185  _is_fc_after_conv = (TensorShape::num_max_dimensions >= 4) && (std::equal(input->info()->tensor_shape().cbegin() + 3,
186  input->info()->tensor_shape().cend(),
187  output->info()->tensor_shape().cbegin() + 1));
188  }
189  else
190  {
191  _is_fc_after_conv = input->info()->num_dimensions() > 1;
192  }
193 
194  // Reshape weights if needed
195  if(!_are_weights_reshaped)
196  {
197  // Reshape the weights
198  _reshape_weights_function.configure(weights, &_reshape_weights_output);
199  weights_to_use = &_reshape_weights_output;
200  }
201 
202  // Convert weights if needed
203  if(_is_fc_after_conv && (input->info()->data_layout() != fc_info.weights_trained_layout))
204  {
205  // Convert weights
206  _convert_weights.configure(weights_to_use,
207  &_converted_weights_output,
208  input->info()->tensor_shape(),
209  fc_info.weights_trained_layout);
210 
211  weights_to_use = &_converted_weights_output;
212  _are_weights_converted = false;
213  }
214 
215  ITensor *tmp_output = (_is_quantized) ? &_gemmlowp_output : output;
216  if(_is_fc_after_conv)
217  {
218  // Fully Connected layer after a Convolution Layer without batches
219  configure_conv_fc(input, weights_to_use, tmp_output);
220  }
221  else
222  {
223  // Fully Connected layer after a Fully Connected Layer without batches
224  configure_fc_fc(input, weights_to_use, tmp_output);
225  }
226 
227  // Configure output stage for asymmetric quantized types
228  if(_is_quantized)
229  {
230  const UniformQuantizationInfo iq_info = input->info()->quantization_info().uniform();
232  const UniformQuantizationInfo oq_info = output->info()->quantization_info().uniform();
233 
234  float multiplier = (iq_info.scale * wq_info.scale) / oq_info.scale;
235  int output_multiplier;
236  int output_shift;
237  quantization::calculate_quantized_multiplier_less_than_one(multiplier, &output_multiplier, &output_shift);
238  _gemmlowp_output_stage.configure(&_gemmlowp_output, biases, output, output_multiplier, output_shift, oq_info.offset);
239  _gemmlowp_output.allocator()->allocate();
240  }
241 
242  _are_weights_reshaped = _are_weights_reshaped || fc_info.retain_internal_weights;
243 }
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
arm_compute::Status calculate_quantized_multiplier_less_than_one(float multiplier, int *quant_multiplier, int *right_shift)
Calculate quantized representation of multiplier with value less than one.
TensorInfo * info() const override
Interface to be implemented by the child class to return the tensor's metadata.
Definition: CLTensor.cpp:35
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...
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:798
void configure(const ITensor *input, const ITensor *bias, ITensor *output, int result_fixedpoint_multiplier, int result_shift, int result_offset_after_shift, int min=0, int max=0)
Initialise the kernel's inputs, output.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
QuantizationInfo quantization_info() const override
Get the quantization settings (scale and offset) of the tensor.
Definition: TensorInfo.h:293
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:327
Quantization info when assuming per layer quantization.
Interface for NEON tensor.
Definition: ITensor.h:36
TensorAllocator * allocator()
Return a pointer to the tensor's allocator.
Definition: Tensor.cpp:48
1 channel, 1 S32 per channel
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
bool are_weights_reshaped
Reshape the weights tensor if false.
Definition: Types.h:797
void allocate() override
Allocate size specified by TensorInfo of CPU memory.
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.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
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:1030
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:234
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:210
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
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:795
bool transpose_weights
Transpose weights if true.
Definition: Types.h:796
void configure(const ITensor *input, ITensor *output)
Set the input and output tensors.
static constexpr size_t num_max_dimensions
Number of dimensions the tensor has.
Definition: Dimensions.h:45
void configure(ITensor *accum, const ITensor *biases)
Set the accumulate buffer and the biases of the kernel.
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.

References TensorAllocator::allocate(), Tensor::allocator(), FullyConnectedLayerInfo::are_weights_reshaped, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::quantization::calculate_quantized_multiplier_less_than_one(), Dimensions< T >::cbegin(), Dimensions< T >::cend(), ICloneable< T >::clone(), NEConvertFullyConnectedWeights::configure(), NEFullyConnectedLayerReshapeWeights::configure(), NEGEMMMatrixAccumulateBiasesKernel::configure(), NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint::configure(), ITensorInfo::data_layout(), ITensorInfo::data_type(), ITensorInfo::dimension(), ITensor::info(), CLTensor::info(), TensorAllocator::init(), arm_compute::is_data_type_quantized_asymmetric(), ITensorInfo::num_dimensions(), Dimensions< size_t >::num_max_dimensions, UniformQuantizationInfo::offset, ITensorInfo::quantization_info(), TensorInfo::quantization_info(), FullyConnectedLayerInfo::retain_internal_weights, arm_compute::S32, UniformQuantizationInfo::scale, ITensorInfo::tensor_shape(), FullyConnectedLayerInfo::transpose_weights, QuantizationInfo::uniform(), NEFullyConnectedLayer::validate(), arm_compute::test::validation::weights, and FullyConnectedLayerInfo::weights_trained_layout.

Referenced by NERNNLayer::configure(), and NELSTMLayer::configure().

◆ operator=() [1/2]

NEFullyConnectedLayer& operator= ( const NEFullyConnectedLayer )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ operator=() [2/2]

NEFullyConnectedLayer& operator= ( NEFullyConnectedLayer &&  )
default

Default move assignment operator.

◆ prepare()

void prepare ( )
overridevirtual

Prepare the function for executing.

Any one off pre-processing step required by the function is handled here

Note
Prepare stage might not need all the function's buffers' backing memory to be available in order to execute

Reimplemented from IFunction.

Definition at line 380 of file NEFullyConnectedLayer.cpp.

381 {
382  if(!_is_prepared)
383  {
384  ARM_COMPUTE_ERROR_ON(!_original_weights->is_used());
385 
386  auto release_unused = [](Tensor * w)
387  {
388  if(!w->is_used())
389  {
390  w->allocator()->free();
391  }
392  };
393 
394  // Pointer to current weights
395  const ITensor *cur_weights = _original_weights;
396 
397  // Reshape of the weights (happens only once)
398  if(!_are_weights_reshaped)
399  {
400  // Run reshape weights kernel and mark weights as unused
401  _reshape_weights_output.allocator()->allocate();
402  _reshape_weights_function.run();
403 
404  cur_weights->mark_as_unused();
405  cur_weights = &_reshape_weights_output;
406  _are_weights_reshaped = true;
407  }
408 
409  // Convert weights if needed (happens only once)
410  if(!_are_weights_converted)
411  {
412  _converted_weights_output.allocator()->allocate();
413  _convert_weights.run();
414 
415  cur_weights->mark_as_unused();
416  _are_weights_converted = true;
417  }
418 
419  // Release reshaped weights if unused
420  release_unused(&_reshape_weights_output);
421 
422  // Prepare GEMM prepare and release unused weights
423  if(!_is_quantized)
424  {
425  _mm_gemm.prepare();
426  }
427 
428  // Release converted weights if unused
429  release_unused(&_reshape_weights_output);
430  release_unused(&_converted_weights_output);
431 
432  _is_prepared = true;
433  }
434 }
SimpleTensor< float > w
Definition: DFT.cpp:156
void run() override final
Run the kernels contained in the function.
bool is_used() const
Flags if the tensor is used or not.
Definition: ITensor.cpp:162
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337
Interface for NEON tensor.
Definition: ITensor.h:36
TensorAllocator * allocator()
Return a pointer to the tensor's allocator.
Definition: Tensor.cpp:48
void mark_as_unused() const
Marks a tensor as unused.
Definition: ITensor.cpp:167
void allocate() override
Allocate size specified by TensorInfo of CPU memory.
Basic implementation of the tensor interface.
Definition: Tensor.h:37
void prepare() override
Prepare the function for executing.
Definition: NEGEMM.cpp:273
void run() override
Run the kernels contained in the function.

References TensorAllocator::allocate(), Tensor::allocator(), ARM_COMPUTE_ERROR_ON, ITensor::is_used(), ITensor::mark_as_unused(), NEGEMM::prepare(), INESimpleFunctionNoBorder::run(), NEConvertFullyConnectedWeights::run(), and arm_compute::test::validation::w.

Referenced by NERNNLayer::prepare(), and NEFullyConnectedLayer::run().

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For NEON kernels:

  • Multi-threading is used for the kernels which are parallelisable.
  • By default std::thread::hardware_concurrency() threads are used.
Note
CPPScheduler::set_num_threads() can be used to manually set the number of threads

For OpenCL kernels:

  • All the kernels are enqueued on the queue associated with CLScheduler.
  • The queue is then flushed.
Note
The function will not block until the kernels are executed. It is the user's responsibility to wait.
Will call prepare() on first run if hasn't been done

Implements IFunction.

Definition at line 344 of file NEFullyConnectedLayer.cpp.

345 {
346  prepare();
347 
348  MemoryGroupResourceScope scope_mg(_memory_group);
349 
350  // Linearize input if it comes from a convolutional layer
351  if(_is_fc_after_conv)
352  {
353  NEScheduler::get().schedule(&_flatten_kernel, Window::DimY);
354  }
355 
356  // Run matrix multiply
357  if(_is_quantized)
358  {
359  _mm_gemmlowp.run();
360  }
361  else
362  {
363  _mm_gemm.run();
364  }
365 
366  // Accumulate biases if provided
367  if(_is_quantized)
368  {
369  _gemmlowp_output_stage.run();
370  }
371  else
372  {
373  if(_accumulate_biases)
374  {
375  NEScheduler::get().schedule(&_accumulate_biases_kernel, Window::DimY);
376  }
377  }
378 }
void run() override final
Run the kernels contained in the function.
void run() override
Run the kernels contained in the function.
Definition: NEGEMM.cpp:239
void run() override
Run the kernels contained in the function.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
Memory group resources scope handling class.
Definition: IMemoryGroup.h:46
virtual void schedule(ICPPKernel *kernel, const Hints &hints)=0
Runs the kernel in the same thread as the caller synchronously.
void prepare() override
Prepare the function for executing.
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:96

References Window::DimY, Scheduler::get(), NEFullyConnectedLayer::prepare(), INESimpleFunctionNoBorder::run(), NEGEMM::run(), NEGEMMLowpMatrixMultiplyCore::run(), and IScheduler::schedule().

Referenced by NERNNLayer::run(), and NELSTMLayer::run().

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo weights,
const ITensorInfo biases,
const ITensorInfo output,
FullyConnectedLayerInfo  fc_info = FullyConnectedLayerInfo() 
)
static

Static function to check if given info will lead to a valid configuration of NEFullyConnectedLayer.

Parameters
[in]inputSource tensor info. Data type supported: QASYMM8/F16/F32.
[in]weightsWeights tensor info. The weights must be 2 dimensional. If this function is called after a Convolution Layer, the (transposed) weights will have as many rows as the product of the first 3 input's dimensions. If it is called after another FullyConnected Layer, the (transposed) weights will have as many rows as the input's first dimension. Data type supported: Same as input.
[in]biasesBias tensor info. Can be nullptr. Data type supported:Same as input.
[out]outputDestination tensor info. Its shape should be equal to the output of a matrix multiplication between:
  • The output of im2col on the input and the (transposed) 2D weights, if the function is called after a Convolution Layer
  • The input tensor and the (transposed) 2D weights, if the function is called after another FullyConnected Layer. Data type supported: Same as input.
[in]fc_info(Optional) Fully connected layer additional info
Returns
a status

Definition at line 245 of file NEFullyConnectedLayer.cpp.

247 {
252  ARM_COMPUTE_RETURN_ERROR_ON(weights->num_dimensions() > 2);
253 
254  bool weights_reshaped = fc_info.transpose_weights ? fc_info.are_weights_reshaped : true;
255  bool is_fc_after_conv = true;
256  bool is_quantized = is_data_type_quantized_asymmetric(input->data_type());
257 
258  const ITensorInfo &flatten_input = TensorInfo(input->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(compute_flatten_shape(input)));
259  const ITensorInfo &reshaped_weights = TensorInfo(weights->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(compute_transposed_shape(*weights)));
260  const ITensorInfo &converted_weights = weights_reshaped ? TensorInfo(weights->clone()->set_is_resizable(true).reset_padding()) : TensorInfo(*reshaped_weights.clone());
261  const ITensorInfo &gemmlowp_output = TensorInfo(output->clone()->set_is_resizable(true).reset_padding().set_data_type(DataType::S32));
262 
263  // Configure accumulate biases kernel for non quantized asymmetric types
264  if(biases != nullptr && !is_quantized)
265  {
268  }
269 
270  // With the Fully Connected layer we can have 4 different cases:
271  // 1) Convolution layer -> Fully Connected layer without batches
272  // 2) Fully Connected layer -> Fully Connected layer without batches
273  // 3) Convolution layer -> Fully Connected layer with batches
274  // 4) Fully Connected layer -> Fully Connected layer with batches
275 
276  const ITensorInfo *input_to_use = input;
277  const ITensorInfo *weights_to_use = weights;
278  const ITensorInfo *tmp_output = (is_quantized) ? &gemmlowp_output : output;
279 
280  // Check if we have a fully connected layer with batches
281  const bool is_batched_fc_layer = output->dimension(1) > 1;
282 
283  if(is_batched_fc_layer)
284  {
285  is_fc_after_conv = (TensorShape::num_max_dimensions >= 4) && (std::equal(input->tensor_shape().cbegin() + 3,
286  input->tensor_shape().cend(),
287  output->tensor_shape().cbegin() + 1));
288  }
289  else
290  {
291  is_fc_after_conv = input->num_dimensions() > 1;
292  }
293 
294  if(!weights_reshaped)
295  {
296  // Validate reshape weights kernel
298  weights_to_use = &reshaped_weights;
299  }
300 
301  if(is_fc_after_conv && (input->data_layout() != fc_info.weights_trained_layout))
302  {
303  // Validate convert weights kernel
305  &converted_weights,
306  input->tensor_shape(),
307  fc_info.weights_trained_layout));
308  weights_to_use = &converted_weights;
309  }
310 
311  if(is_fc_after_conv)
312  {
313  // Fully Connected layer after a Convolution Layer without batches
314  ARM_COMPUTE_RETURN_ERROR_ON((weights_to_use->dimension(1) != (input->dimension(0) * input->dimension(1) * input->dimension(2))));
315 
316  // Validate flatten kernel
318  input_to_use = &flatten_input;
319  }
320  else
321  {
322  // Fully Connected layer after a Fully Connected Layer without batches
323  ARM_COMPUTE_RETURN_ERROR_ON(input->dimension(0) != weights_to_use->dimension(1));
324  }
325  // Validate matrix multiply kernel
326  ARM_COMPUTE_RETURN_ON_ERROR(validate_mm(*input_to_use, *weights_to_use, *tmp_output));
327 
328  // Validate output stage for asymmetric quantized types
329  if(is_quantized)
330  {
331  const UniformQuantizationInfo iq_info = input->quantization_info().uniform();
332  const UniformQuantizationInfo wq_info = weights->quantization_info().uniform();
333  const UniformQuantizationInfo oq_info = output->quantization_info().uniform();
334  const float multiplier = iq_info.scale * wq_info.scale / oq_info.scale;
335 
336  ARM_COMPUTE_UNUSED(multiplier);
337  ARM_COMPUTE_RETURN_ERROR_ON(multiplier > 1.0f);
339  }
340 
341  return Status{};
342 }
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
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:798
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:545
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193
virtual DataType data_type() const =0
Data type used for each element of the tensor.
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:791
1 channel, 1 F32 per channel
Store the tensor's metadata.
Definition: ITensorInfo.h:40
Quantization info when assuming per layer quantization.
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:244
1 channel, 1 F16 per channel
TensorShape compute_transposed_shape(const ITensorInfo &input)
Calculate the transposed shape of a tensor.
static Status validate(const ITensorInfo *input, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEFullyConnectedLayerRes...
1 channel, 1 S32 per channel
TensorShape compute_flatten_shape(const ITensorInfo *input)
Calculate the flattened output shape of a tensor.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
quantized, asymmetric fixed-point 8-bit number
bool are_weights_reshaped
Reshape the weights tensor if false.
Definition: Types.h:797
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.
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1030
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:234
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:163
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:210
DataLayout weights_trained_layout
Layout that the weights have been trained with.
Definition: Types.h:795
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...
static Status validate(const ITensorInfo *accum, const ITensorInfo *biases)
Static function to check if given info will lead to a valid configuration of NEGEMMMatrixAccumulateBi...
bool transpose_weights
Transpose weights if true.
Definition: Types.h:796
Store the tensor's metadata.
Definition: TensorInfo.h:45
static Status validate(const ITensorInfo *input, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEFlattenLayerKernel.
static constexpr size_t num_max_dimensions
Number of dimensions the tensor has.
Definition: Dimensions.h:45
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.
static Status validate(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, int min=0, int max=0)
Static function to check if given info will lead to a valid configuration of NEGEMMLowpQuantizeDownIn...

References FullyConnectedLayerInfo::are_weights_reshaped, ARM_COMPUTE_RETURN_ERROR_ON, ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, ARM_COMPUTE_UNUSED, Dimensions< T >::cbegin(), Dimensions< T >::cend(), ICloneable< T >::clone(), arm_compute::misc::shape_calculator::compute_flatten_shape(), arm_compute::misc::shape_calculator::compute_transposed_shape(), ITensorInfo::data_layout(), ITensorInfo::data_type(), ITensorInfo::dimension(), arm_compute::F16, arm_compute::F32, arm_compute::is_data_type_quantized_asymmetric(), ITensorInfo::num_dimensions(), Dimensions< size_t >::num_max_dimensions, arm_compute::QASYMM8, ITensorInfo::quantization_info(), FullyConnectedLayerInfo::retain_internal_weights, arm_compute::S32, UniformQuantizationInfo::scale, ITensorInfo::tensor_shape(), FullyConnectedLayerInfo::transpose_weights, QuantizationInfo::uniform(), NEConvertFullyConnectedWeights::validate(), NEFullyConnectedLayerReshapeWeights::validate(), NEGEMMMatrixAccumulateBiasesKernel::validate(), NEFlattenLayerKernel::validate(), NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint::validate(), arm_compute::test::validation::weights, and FullyConnectedLayerInfo::weights_trained_layout.

Referenced by NEFullyConnectedLayer::configure(), NERNNLayer::validate(), and NELSTMLayer::validate().


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