41 MemoryGroup memory_group{};
42 IWeightsManager *weights_manager{
nullptr };
44 std::unique_ptr<cpu::CpuGemm> op{
nullptr };
46 const ITensor *original_b{
nullptr };
47 bool is_prepared{
false };
49 ITensorPack run_pack{};
50 ITensorPack prep_pack{};
51 WorkspaceData<Tensor> workspace{};
56 : _impl(
std::make_unique<Impl>())
58 _impl->memory_group =
MemoryGroup(std::move(memory_manager));
59 _impl->weights_manager = weights_manager;
70 _impl->is_prepared =
false;
71 _impl->original_b =
b;
72 _impl->op = std::make_unique<cpu::CpuGemm>();
78 b_info_to_use->set_are_values_constant(
false);
81 _impl->op->configure(a->
info(), b_info_to_use.get(), (c !=
nullptr) ? c->
info() :
nullptr, d->
info(), alpha, beta,
gemm_info);
83 _impl->aux_mem_req = _impl->op->workspace();
86 _impl->workspace = manage_workspace<Tensor>(_impl->aux_mem_req, _impl->memory_group, _impl->run_pack, _impl->prep_pack);
92 auto b_to_use = b->
clone();
95 b_to_use->set_are_values_constant(
false);
113 _impl->op->run(_impl->run_pack);
118 if(!_impl->is_prepared)
120 _impl->op->prepare(_impl->prep_pack);
122 auto has_reshape = std::find_if(_impl->aux_mem_req.begin(),
123 _impl->aux_mem_req.end(),
124 [](
const MemoryInfo &
m) ->
bool {
return m.lifetime == MemoryLifetime::Persistent; });
126 if(has_reshape !=
std::end(_impl->aux_mem_req))
128 _impl->original_b->mark_as_unused();
132 _impl->run_pack.add_const_tensor(
ACL_SRC_1, _impl->original_b);
136 release_temporaries<Tensor>(_impl->aux_mem_req, _impl->workspace);
137 _impl->is_prepared =
true;
~NEGEMM()
Default destructor.
static Status has_opt_impl(arm_compute::WeightFormat &weight_format, const ITensorInfo *a, const ITensorInfo *b, const ITensorInfo *c, const ITensorInfo *d, const GEMMInfo &gemm_info=GEMMInfo())
Indicates whether or not there is an optimal assembly implementation that can be used to process the ...
static Status validate(const ITensorInfo *a, const ITensorInfo *b, const ITensorInfo *c, const ITensorInfo *d, float alpha, float beta, const GEMMInfo &gemm_info=GEMMInfo())
Static function to check if given info will lead to a valid configuration of CpuGemm.
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
WeightFormat
Memory layouts for the weights tensor.
Interface for CPU tensor.
NEGEMM(std::shared_ptr< IMemoryManager > memory_manager=nullptr, IWeightsManager *weights_manager=nullptr)
Constructor.
Copyright (c) 2017-2023 Arm Limited.
std::vector< MemoryInfo > MemoryRequirements
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.
void run() override
Run the kernels contained in the function.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
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.
void end(TokenStream &in, bool &valid)
Weights manager interface to handle weights transformations.
Memory group resources scope handling class.
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's inputs, output.
void prepare() override
Prepare the function for executing.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
bool reshape_b_only_on_first_run() const
Flag which specifies if the reshape of matrix B should executed only for the first.
static Status has_opt_impl(arm_compute::WeightFormat &expected_weight_format, const ITensorInfo *a, const ITensorInfo *b, const ITensorInfo *c, const ITensorInfo *output, float alpha, float beta, const GEMMInfo &gemm_info=GEMMInfo())
Static function that queries whether there exists fixed-format kernel and if it exists it will return...