37 struct NEFullyConnectedLayer::Impl
39 MemoryGroup memory_group{};
40 IWeightsManager *weights_manager{
nullptr };
42 std::unique_ptr<cpu::CpuFullyConnected> op{
nullptr };
44 const ITensor *original_weights{
nullptr };
46 ITensorPack run_pack{};
47 WorkspaceData<Tensor> workspace{};
50 bool is_prepared{
false };
56 : _impl(
std::make_unique<Impl>())
58 _impl->memory_group =
MemoryGroup(std::move(memory_manager));
59 _impl->weights_manager = weights_manager;
69 biases !=
nullptr ? biases->
info() :
nullptr,
73 _impl->op = std::make_unique<cpu::CpuFullyConnected>();
74 _impl->original_weights = weights;
75 _impl->is_prepared =
false;
77 _impl->op->configure(input->
info(), weights->
info(), (biases !=
nullptr) ? biases->
info() :
nullptr, output->
info(), fc_info);
79 if(_impl->weights_manager !=
nullptr)
81 _impl->weights_manager->manage(weights);
84 _impl->aux_mem_req = _impl->op->workspace();
86 _impl->workspace = manage_workspace<Tensor>(_impl->aux_mem_req, _impl->memory_group, _impl->run_pack, _impl->run_pack);
100 _impl->op->run(_impl->run_pack);
105 if(!_impl->is_prepared)
107 _impl->op->prepare(_impl->run_pack);
110 release_temporaries<Tensor>(_impl->aux_mem_req, _impl->workspace);
111 _impl->is_prepared =
true;
114 if(_impl->weights_manager !=
nullptr && _impl->weights_manager->are_weights_managed(_impl->original_weights))
117 const ITensor *original_b = _impl->original_weights;
120 _impl->weights_manager->mark_as_unused(original_b);
122 _impl->original_weights->mark_as_used();
123 _impl->weights_manager->release(_impl->original_weights);
bool is_used() const
Flags if the tensor is used or not.
Fully connected layer info.
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Interface for CPU tensor.
Copyright (c) 2017-2021 Arm Limited.
std::vector< MemoryInfo > MemoryRequirements
void configure(const ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *output, FullyConnectedLayerInfo fc_info=FullyConnectedLayerInfo())
Set the input and output tensors.
NEFullyConnectedLayer(std::shared_ptr< IMemoryManager > memory_manager=nullptr, IWeightsManager *weights_manager=nullptr)
Constructor.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
Weights manager interface to handle weights transformations.
~NEFullyConnectedLayer()
Default destructor.
Memory group resources scope handling class.
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())
Static function to check if given info will lead to a valid configuration of CpuFullyConnected.
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.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
void prepare() override
Prepare the function for executing.