45 std::unique_ptr<OperatorType> op{
nullptr };
52 bool is_prepared{
false };
56 : _impl(
std::make_unique<Impl>())
59 _impl->weights_manager = weights_manager;
74 _impl->op = std::make_unique<OperatorType>();
77 _impl->op->configure(compile_context, a->
info(), b->
info(), c !=
nullptr ? c->
info() :
nullptr, output->
info(), alpha, beta, gemm_info);
78 _impl->aux_mem_req = _impl->op->workspace();
81 if(_impl->is_prepared)
83 _impl->run_pack.add_const_tensor(
ACL_SRC_0, a);
84 _impl->run_pack.add_tensor(
ACL_DST, output);
89 _impl->prep_pack = { {
ACL_SRC_1, _impl->b } };
91 _impl->workspace_tensors = manage_workspace<CLTensor>(_impl->op->workspace(), _impl->memory_group, _impl->run_pack, _impl->prep_pack);
106 _impl->op->run(_impl->run_pack);
111 if(!_impl->is_prepared)
113 _impl->op->prepare(_impl->prep_pack);
115 auto has_reshape = std::find_if(_impl->aux_mem_req.begin(),
116 _impl->aux_mem_req.end(),
117 [](
const MemoryInfo & m) ->
bool {
return m.lifetime == MemoryLifetime::Persistent; });
119 if(has_reshape !=
std::end(_impl->aux_mem_req))
121 _impl->b->mark_as_unused();
126 _impl->run_pack.add_const_tensor(
ACL_SRC_1, _impl->b);
128 _impl->is_prepared =
true;
std::vector< WorkspaceDataElement< TensorType > > WorkspaceData
void prepare() override
Prepare the function for executing.
~CLGEMM()
Default destructor.
void run() override
Run the kernels contained in the function.
CLGEMM(std::shared_ptr< IMemoryManager > memory_manager=nullptr, IWeightsManager *weights_manager=nullptr)
Default constructor.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
Store the tensor's metadata.
Manages all the OpenCL kernels compilation and caching, provides accessors for the OpenCL Context...
bool retain_internal_weights() const
Flag which specifies if the weights tensor has to be retained from previous run.
Copyright (c) 2017-2021 Arm Limited.
std::vector< MemoryInfo > MemoryRequirements
void configure(const CLCompileContext &compile_context, const ICLTensor *a, const ICLTensor *b, const ICLTensor *c, ICLTensor *output, float alpha, float beta, const GEMMInfo &gemm_info=GEMMInfo())
Initialise the kernel's inputs and output.
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.
Interface for OpenCL tensor.
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 CLGEMM.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
static Status validate(const ITensorInfo *a, const ITensorInfo *b, const ITensorInfo *c, const ITensorInfo *output, float alpha, float beta, const GEMMInfo &gemm_info)
Static function to check if given info will lead to a valid configuration.
Basic function to execute GEMM on OpenCL.