21.02
|
Basic function to execute GEMM on Neon. More...
#include <NEGEMM.h>
Public Member Functions | |
NEGEMM (std::shared_ptr< IMemoryManager > memory_manager=nullptr, IWeightsManager *weights_manager=nullptr) | |
Constructor. More... | |
NEGEMM (const NEGEMM &)=delete | |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
NEGEMM (NEGEMM &&)=default | |
Default move constructor. More... | |
NEGEMM & | operator= (const NEGEMM &)=delete |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
NEGEMM & | operator= (NEGEMM &&)=default |
Default move assignment operator. More... | |
~NEGEMM () | |
Default destructor. More... | |
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. More... | |
void | run () override |
Run the kernels contained in the function. More... | |
void | prepare () override |
Prepare the function for executing. More... | |
Public Member Functions inherited from IFunction | |
virtual | ~IFunction ()=default |
Destructor. More... | |
Static Public Member Functions | |
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. More... | |
Basic function to execute GEMM on Neon.
This function calls the following Neon kernels:
If optimized assembly is available:
NEGEMM | ( | std::shared_ptr< IMemoryManager > | memory_manager = nullptr , |
IWeightsManager * | weights_manager = nullptr |
||
) |
Constructor.
Definition at line 63 of file NEGEMM.cpp.
Prevent instances of this class from being copied (As this class contains pointers)
|
default |
Default destructor.
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.
[in] | a | First input tensor (Matrix A or Vector A). Data type supported: BFLOAT16/F16/F32 |
[in] | b | Second input tensor (Matrix B). Data type supported: same as a |
[in] | c | Third input tensor (Matrix C). It can be a nullptr if just the multiplication between a and b is needed. Data type supported: same as a |
[out] | d | Output tensor. Data type supported: same as a |
[in] | alpha | Weight of the matrix product |
[in] | beta | Weight of matrix C |
[in] | gemm_info | (Optional) Specifies if the matrix A and/or matrix B have been reshaped and if the reshape of matrix B should happen only for the first run |
Definition at line 72 of file NEGEMM.cpp.
References GEMMInfo::activation_info(), TensorAllocator::allocate(), Tensor::allocator(), ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::test::validation::b, ICloneable< T >::clone(), NEActivationLayer::configure(), NEArithmeticAddition::configure(), arm_compute::data_size_from_type(), ITensorInfo::data_type(), ITensorInfo::dimension(), ActivationLayerInfo::enabled(), ITensor::info(), TensorAllocator::init(), NEGEMMAssemblyDispatch::is_activation_supported(), ActivationLayerInfo::LINEAR, MemoryGroup::manage(), GEMMInfo::reshape_b_only_on_first_run(), arm_compute::SATURATE, TensorShape::set(), ITensorInfo::tensor_shape(), NEGEMMAssemblyDispatch::validate(), and NEGEMM::validate().
Referenced by NERNNLayer::configure(), NEWinogradConvolutionLayer::configure(), and NELSTMLayer::configure().
Prevent instances of this class from being copied (As this class contains pointers)
|
overridevirtual |
Prepare the function for executing.
Any one off pre-processing step required by the function is handled here
Reimplemented from IFunction.
Definition at line 359 of file NEGEMM.cpp.
References TensorAllocator::allocate(), Tensor::allocator(), IWeightsManager::are_weights_managed(), ARM_COMPUTE_ERROR_ON, Window::DimY, Scheduler::get(), ITensor::is_used(), ITensor::mark_as_unused(), and IScheduler::schedule().
Referenced by NERNNLayer::prepare(), NEWinogradConvolutionLayer::prepare(), NEFullyConnectedLayer::prepare(), NEGEMMConvolutionLayer::prepare(), and NEGEMM::run().
|
overridevirtual |
Run the kernels contained in the function.
For Neon kernels:
For OpenCL kernels:
Implements IFunction.
Definition at line 309 of file NEGEMM.cpp.
References Window::DimX, Window::DimY, Scheduler::get(), NEGEMM::prepare(), NEActivationLayer::run(), NEArithmeticAddition::run(), and IScheduler::schedule().
Referenced by NERNNLayer::run(), NEWinogradConvolutionLayer::run(), NELSTMLayer::run(), NEFullyConnectedLayer::run(), and NEGEMMConvolutionLayer::run().
|
static |
Static function to check if given info will lead to a valid configuration of NEGEMM.
[in] | a | First input tensor info (Matrix or Vector A). Data types supported: BFLOAT16/F16/F32 |
[in] | b | Second input tensor info (Matrix B). Data type supported: same as a . |
[in] | c | Third input tensor info (Matrix C). It can be a nullptr if just the multiplication between a and b is needed. Data type supported: same as a . |
[out] | output | Output tensor info. Data type supported: same as a |
[in] | alpha | Weight of the matrix product |
[in] | beta | Weight of matrix C |
[in] | gemm_info | (Optional) Specifies if the matrix A and/or matrix B have been reshaped and if the reshape of matrix B should happen only for the first run |
Definition at line 190 of file NEGEMM.cpp.
References GEMMInfo::activation_info(), ARM_COMPUTE_RETURN_ERROR_ON, ARM_COMPUTE_RETURN_ERROR_ON_CPU_BF16_UNSUPPORTED, ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED, ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES, ARM_COMPUTE_RETURN_ERROR_ON_MSG, ARM_COMPUTE_RETURN_ON_ERROR, ARM_COMPUTE_UNUSED, arm_compute::auto_init_if_empty(), arm_compute::test::validation::b, arm_compute::BFLOAT16, ICloneable< T >::clone(), TensorInfo::clone(), arm_compute::misc::shape_calculator::compute_interleaved_shape(), arm_compute::misc::shape_calculator::compute_mm_shape(), arm_compute::misc::shape_calculator::compute_transpose1xW_with_element_size_shape(), ITensorInfo::data_type(), GEMMInfo::depth_output_gemm3d(), ITensorInfo::dimension(), ActivationLayerInfo::enabled(), arm_compute::F16, arm_compute::F32, GEMMInfo::is_a_reshaped(), GEMMInfo::is_b_reshaped(), GEMMInfo::reinterpret_input_as_3d(), GEMMInfo::reshape_b_only_on_first_run(), arm_compute::SATURATE, ITensorInfo::total_size(), NEGEMMMatrixAdditionKernel::validate(), NEGEMMMatrixMultiplyKernel::validate(), NEActivationLayer::validate(), NEGEMMInterleave4x4Kernel::validate(), NEArithmeticAddition::validate(), NEGEMMTranspose1xWKernel::validate(), and NEGEMMAssemblyDispatch::validate().
Referenced by NEGEMM::configure(), and NELSTMLayer::validate().