35 auto k = std::make_unique<GCTransposeKernel>();
36 k->configure(input, output);
37 _kernel = std::move(k);
41 : _memory_group(
std::move(memory_manager)), _weights_manager(
std::move(weights_manager)), _im2col_kernel(), _reshape_weights_kernel(), _mm_kernel(), _accumulate_biases_kernel(), _im2col_output(),
42 _reshape_weights_output(), _original_weights(nullptr), _are_weights_reshaped(true), _is_fc_after_conv(true), _accumulate_biases(false)
63 _memory_group.
manage(&_im2col_output);
67 _mm_kernel.
configure(&_im2col_output, weights, output, 1.0f,
false);
78 _mm_kernel.
configure(input, weights, output, 1.0f,
false);
88 _original_weights = weights;
90 _is_fc_after_conv =
true;
91 _accumulate_biases =
false;
97 _accumulate_biases =
true;
100 _accumulate_biases_kernel.
configure(output, biases);
109 const IGCTensor *weights_to_use = weights;
111 if(!_are_weights_reshaped)
113 weights_to_use = &_reshape_weights_output;
116 _reshape_weights_kernel.
configure(weights, &_reshape_weights_output);
120 const bool is_batched_fc_layer = output->
info()->
dimension(1) > 1;
122 if(is_batched_fc_layer)
133 if(_is_fc_after_conv)
136 configure_conv_fc(input, weights_to_use, output);
141 configure_fc_fc(input, weights_to_use, output);
155 if(_is_fc_after_conv)
160 if(!_are_weights_reshaped || _is_fc_after_conv)
169 if(_accumulate_biases)
180 if(!_are_weights_reshaped)
186 _reshape_weights_kernel.
run();
191 _are_weights_reshaped =
true;
void configure(const IGCTensor *input, const IGCTensor *weights, const IGCTensor *biases, IGCTensor *output, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo())
Set the input and output tensors.
void configure(const IGCTensor *input, IGCTensor *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, const Size2D &dilation=Size2D(1U, 1U))
Set the input and output of the kernel.
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.
void dispatch(IGCKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
bool retain_internal_weights
Retain internal reshaped weights.
void run() override final
Run the kernels contained in the function.
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.
1 channel, 1 F32 per channel
void memory_barrier()
Defines a barrier ordering memory transactions.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Fully connected layer info.
Interface for GLES Compute tensor.
void init(const TensorInfo &input, size_t alignment=0)
Initialize a tensor based on the passed TensorInfo.
Copyright (c) 2017-2021 Arm Limited.
1 channel, 1 F16 per channel
void mark_as_unused() const
Marks a tensor as unused.
void manage(IMemoryManageable *obj) override
Sets a object to be managed by the given memory group.
static GCScheduler & get()
Access the scheduler singleton.
GLuint gc_buffer() const override
Interface to be implemented by the child class to return the tensor's gles compute buffer id...
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(...)
void prepare() override
Prepare the function for executing.
bool are_weights_reshaped
Reshape the weights tensor if false.
void configure(const IGCTensor *input0, const IGCTensor *input1, IGCTensor *output, float alpha, bool is_interleaved_transposed=true, const GEMMReshapeInfo &reshape_info=GEMMReshapeInfo())
Initialise the kernel's input, output and alpha.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
void run() override
Run the kernels contained in the function.
Padding and stride information class.
Weights manager interface to handle weights transformations.
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
virtual void allocate()=0
Interface to be implemented by the child class to allocate the tensor.
void configure(const IGCTensor *input, IGCTensor *output)
Set the input and output tensors.
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...
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...
Memory group resources scope handling class.
Class for specifying the size of an image or rectangle.
Interface to enqueue GLES kernels and get/set the GLES CommandQueue.
bool transpose_weights
Transpose weights if true.
void configure(IGCTensor *accum, const IGCTensor *biases)
Set the accumulate buffer and the biases of the kernel.
Store the tensor's metadata.
static constexpr size_t num_max_dimensions
Number of dimensions the tensor has.
DataType
Available data types.
ITensorAllocator * allocator()
Return a pointer to the tensor's allocator.
GCFullyConnectedLayer(std::shared_ptr< IMemoryManager > memory_manager=nullptr, IWeightsManager *weights_manager=nullptr)
Constructor.
TensorShape & set(size_t dimension, size_t value, bool apply_dim_correction=true, bool increase_dim_unit=true)
Accessor to set the value of one of the dimensions.