44 cpu::AsmGemmInfo init_assembly_metadata(
const GEMMInfo &
info)
46 cpu::AsmGemmInfo asm_info;
48 asm_info.reinterpret_input_as_3d = info.reinterpret_input_as_3d();
49 asm_info.depth_output_gemm3d = info.depth_output_gemm3d();
50 asm_info.activation_info = info.activation_info();
51 asm_info.fast_mode = info.fast_math();
69 _run_vector_matrix_multiplication = a->
dimension(1) < 2;
70 _run_alpha_scale = alpha != 1.f;
78 const ITensorInfo *c_to_use = is_c_bias ? c :
nullptr;
79 _asm_glue = std::make_unique<cpu::CpuGemmAssemblyDispatch>();
80 _asm_glue->configure(a, b, c_to_use, d, asm_info);
83 auto asm_mem_req = _asm_glue->workspace();
84 _aux_mem[AsmGemmWorkspace] = asm_mem_req[AsmGemmWorkspace];
85 _aux_mem[Pretraspose] = asm_mem_req[Pretraspose];
90 _alpha_scale_func = std::make_unique<cpu::CpuActivation>();
97 ITensorInfo *gemm_output_to_use = (_run_bias_addition) ? &_tmp_d : d;
99 _mm_kernel = std::make_unique<cpu::kernels::CpuGemmMatrixMultiplyKernel>();
102 if(_run_vector_matrix_multiplication)
105 _mm_kernel->configure(a, b, gemm_output_to_use, alpha,
false);
114 _interleave_kernel = std::make_unique<cpu::kernels::CpuGemmInterleave4x4Kernel>();
115 _interleave_kernel->configure(a, &_tmp_a);
119 _transpose_kernel = std::make_unique<cpu::kernels::CpuGemmTranspose1xWKernel>();
120 _transpose_kernel->configure(b, &_tmp_b);
124 _mm_kernel->configure(&_tmp_a, &_tmp_b, gemm_output_to_use, alpha,
true,
GEMMReshapeInfo(m, n, k));
127 if(_run_bias_addition)
129 _add_bias = std::make_unique<cpu::CpuAdd>();
138 _ma_kernel = std::make_unique<cpu::kernels::CpuGemmMatrixAdditionKernel>();
139 _ma_kernel->configure(c, d, beta);
145 _activation_func = std::make_unique<cpu::CpuActivation>();
167 if(c !=
nullptr && !is_c_bias)
207 const bool run_vector_matrix_multiplication = a->
dimension(1) < 2;
217 int mult_transpose1xW_width = 1;
218 int mult_interleave4x4_height = 1;
229 if(run_interleave_transpose)
231 matrix_a_info = &tmp_a_info;
232 matrix_b_info = &tmp_b_info;
254 if(beta != 0 && c !=
nullptr && !is_c_bias)
278 if(_asm_glue->is_configured())
283 _asm_glue->run(asm_pack);
287 _alpha_scale_func->run(
pack);
297 if(!_run_vector_matrix_multiplication)
303 if(!_reshape_b_only_on_first_run)
311 mm_pack.add_const_tensor(
ACL_SRC_0, interleaved_a.
get());
312 mm_pack.add_const_tensor(
ACL_SRC_1, transposed_b.
get());
318 if(_run_bias_addition)
321 _add_bias->run(
pack);
336 _activation_func->run(
pack);
344 if(_asm_glue->is_configured())
346 _asm_glue->prepare(tensors);
348 else if(_reshape_b_only_on_first_run && !_run_vector_matrix_multiplication)
TensorShape compute_transpose1xW_with_element_size_shape(const ITensorInfo &b, int mult_transpose1xW_width=1)
Calculate the transposed 1xW width element shape.
std::unique_ptr< ITensorInfo > clone() const override
Provide a clone of the current object of class T.
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
bool enabled() const
Check if initialised.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_BF16_UNSUPPORTED(tensor)
void add_const_tensor(int id, const ITensor *tensor)
Add const tensor to the pack.
static bool is_activation_supported(const ActivationLayerInfo &activation)
Checks if activation is supported by the gemm assembly dispatcher.
GEMM reshape information class.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
TensorShape compute_mm_shape(const ITensorInfo &input0, const ITensorInfo &input1, bool is_interleaved_transposed, const GEMMReshapeInfo &reshape_info)
Calculate the matrix multiplication output shape of two tensors.
virtual void schedule_op(ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors)=0
Runs the kernel in the same thread as the caller synchronously.
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst)
Static function to check if given info will lead to a valid configuration of CpuGemmTranspose1xWKerne...
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
int depth_output_gemm3d() const
Depth of the output when GEMM output is reinterpreted as 3D tensor.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
static Status validate(const ITensorInfo *lhs, const ITensorInfo *rhs, const ITensorInfo *dst, float alpha, bool is_interleaved, const GEMMReshapeInfo &reshape_info)
Static function to check if given info will lead to a valid configuration of CpuGemmMatrixMultiplyKer...
Activation Layer Information class.
Interface for CPU tensor.
TensorShape compute_interleaved_shape(const ITensorInfo &a, int mult_interleave4x4_height=1, bool reinterpret_input_as_3d=false)
Calculate the interleaved shape of an input tensor.
Copyright (c) 2017-2021 Arm Limited.
bool is_b_reshaped() const
Flag which specifies if the matrix B has been reshaped.
std::vector< MemoryInfo > MemoryRequirements
1 channel, 1 F16 per channel
16-bit brain floating-point number
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
static Status validate(const ITensorInfo *a, const ITensorInfo *b, const ITensorInfo *c, const ITensorInfo *d, const AsmGemmInfo &info)
Indicates whether or not this function can be used to process the given parameters.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
bool reinterpret_input_as_3d() const
Flag which specifies if the input tensor has to be reinterpreted as 3D.
bool is_a_reshaped() const
Flag which specifies if the matrix A has been reshaped.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst)
Static function to check if given info will lead to a valid configuration of CpuGemmInterleave4x4Kern...
static Status validate(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst, ConvertPolicy policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const ActivationLayerInfo &act_info)
Static function to check if given info will lead to a valid configuration.
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
Target polymorphic_cast(Source *v)
Polymorphic cast between two types.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Store the tensor's metadata.
bool reshape_b_only_on_first_run() const
Flag which specifies if the reshape of matrix B should executed only for the first.
int offset_int_vec(int offset)
im2col_func configure(src_target.info(), dst_target.info(), spatial_kernel, conv_info, has_bias)
ActivationLayerInfo activation_info() const
Activation layer to apply after the matrix multiplication.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, float beta)
Static function to check if given info will lead to a valid configuration of CpuGemmMatrixAdditionKer...
Status validate(const ITensorInfo *scores_in, const ITensorInfo *boxes_in, const ITensorInfo *batch_splits_in, const ITensorInfo *scores_out, const ITensorInfo *boxes_out, const ITensorInfo *classes, const ITensorInfo *batch_splits_out, const ITensorInfo *keeps, const ITensorInfo *keeps_size, const BoxNMSLimitInfo info)
static IScheduler & get()
Access the scheduler singleton.