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>();
74 _impl->op->configure(a->
info(), b->
info(), (c !=
nullptr) ? c->
info() :
nullptr, d->
info(), alpha, beta, gemm_info);
76 _impl->aux_mem_req = _impl->op->workspace();
79 _impl->workspace = manage_workspace<Tensor>(_impl->aux_mem_req, _impl->memory_group, _impl->run_pack, _impl->prep_pack);
92 _impl->op->run(_impl->run_pack);
97 if(!_impl->is_prepared)
99 _impl->op->prepare(_impl->prep_pack);
101 auto has_reshape = std::find_if(_impl->aux_mem_req.begin(),
102 _impl->aux_mem_req.end(),
103 [](
const MemoryInfo & m) ->
bool {
return m.lifetime == MemoryLifetime::Persistent; });
105 if(has_reshape !=
std::end(_impl->aux_mem_req))
107 _impl->original_b->mark_as_unused();
111 _impl->run_pack.add_const_tensor(
ACL_SRC_1, _impl->original_b);
115 release_temporaries<Tensor>(_impl->aux_mem_req, _impl->workspace);
116 _impl->is_prepared =
true;
~NEGEMM()
Default destructor.
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)
Interface for CPU tensor.
NEGEMM(std::shared_ptr< IMemoryManager > memory_manager=nullptr, IWeightsManager *weights_manager=nullptr)
Constructor.
Copyright (c) 2017-2021 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.
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(...)