23.11
|
Go to the documentation of this file.
39 struct NEFullyConnectedLayer::Impl
41 MemoryGroup memory_group{};
42 IWeightsManager *weights_manager{
nullptr};
44 std::unique_ptr<cpu::CpuFullyConnected> op{
nullptr};
46 const ITensor *original_weights{
nullptr};
48 ITensorPack run_pack{};
49 WorkspaceData<Tensor> workspace{};
52 bool is_prepared{
false};
53 bool dynamic_weights{
false};
60 : _impl(std::make_unique<Impl>())
62 _impl->memory_group =
MemoryGroup(std::move(memory_manager));
63 _impl->weights_manager = weights_manager;
76 biases !=
nullptr ? biases->
info() :
nullptr,
80 _impl->op = std::make_unique<cpu::CpuFullyConnected>();
81 _impl->original_weights = weights;
82 _impl->is_prepared =
false;
84 _impl->op->configure(
input->info(), weights->
info(), (biases !=
nullptr) ? biases->
info() :
nullptr, output->
info(),
87 if (_impl->weights_manager !=
nullptr)
89 _impl->weights_manager->manage(_impl->original_weights);
92 _impl->aux_mem_req = _impl->op->workspace();
95 manage_workspace<Tensor>(_impl->aux_mem_req, _impl->memory_group, _impl->run_pack, _impl->run_pack);
125 if (!_impl->dynamic_weights)
131 _impl->op->run(_impl->run_pack);
136 if (!_impl->is_prepared)
138 _impl->op->prepare(_impl->run_pack);
141 release_temporaries<Tensor>(_impl->aux_mem_req, _impl->workspace);
142 _impl->is_prepared =
true;
145 if (_impl->weights_manager !=
nullptr && _impl->weights_manager->are_weights_managed(_impl->original_weights))
150 const ITensor *original_b = _impl->original_weights;
153 _impl->weights_manager->pre_mark_as_unused(original_b);
155 _impl->original_weights->mark_as_used();
156 _impl->weights_manager->release(_impl->original_weights);
std::vector< MemoryInfo > MemoryRequirements
Convolution Layer Weights Information class.
static Status has_opt_impl(arm_compute::WeightFormat &expected_weight_format, const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, FullyConnectedLayerInfo fc_info, WeightsInfo weights_info)
Static function that queries whether there exists fixed-format kernel and if it exists it will return...
Interface for CPU tensor.
Fully connected layer info.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
void prepare() override
Prepare the function for executing.
WeightFormat
Memory layouts for the weights tensor.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
bool are_weights_reshaped
void configure(const ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *output, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo(), const WeightsInfo &weights_info=WeightsInfo())
Set the input and output tensors.
NEFullyConnectedLayer(std::shared_ptr< IMemoryManager > memory_manager=nullptr, IWeightsManager *weights_manager=nullptr)
Constructor.
~NEFullyConnectedLayer()
Default destructor.
void run() override
Run the kernels contained in the function.
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo(), const WeightsInfo &weights_info=WeightsInfo())
Static function to check if given info will lead to a valid configuration of CpuFullyConnected.
static Status has_opt_impl(arm_compute::WeightFormat &expected_weight_format, const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const FullyConnectedLayerInfo &fc_info, const WeightsInfo &weights_info)
Static function that queries whether fixed-format kernel exists for a given problem description.
bool is_used() const
Flags if the tensor is used or not.
Memory group resources scope handling class.
Copyright (c) 2017-2023 Arm Limited.
bool retain_internal_weights
Retain internal reshaped weights.
Store the tensor's metadata.
bool transpose_weights
Transpose weights if true.
virtual bool are_values_constant() const =0
Flag indicating whether the values of the tensor are constant, meaning that they can change on kernel...
static Status validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo(), const WeightsInfo &weights_info=WeightsInfo())
Static function to check if given info will lead to a valid configuration of NEFullyConnectedLayer.
Weights manager interface to handle weights transformations.
#define ARM_COMPUTE_LOG_PARAMS(...)