Basic function to execute GEMM on OpenCL */
| 47 | |
| 48 | /** Basic function to execute GEMM on OpenCL */ |
| 49 | class CLGEMM : public IFunction |
| 50 | { |
| 51 | public: |
| 52 | /** Default constructor. |
| 53 | * |
| 54 | * @param[in] memory_manager (Optional) Memory manager. |
| 55 | * @param[in] weights_manager (Optional) Weights manager. |
| 56 | */ |
| 57 | CLGEMM(std::shared_ptr<IMemoryManager> memory_manager = nullptr, IWeightsManager *weights_manager = nullptr); |
| 58 | /** Default destructor */ |
| 59 | ~CLGEMM(); |
| 60 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 61 | CLGEMM(const CLGEMM &) = delete; |
| 62 | /** Default move constructor */ |
| 63 | CLGEMM(CLGEMM &&); |
| 64 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 65 | CLGEMM &operator=(const CLGEMM &) = delete; |
| 66 | /** Default move assignment operator */ |
| 67 | CLGEMM &operator=(CLGEMM &&); |
| 68 | /** Initialise the kernel's inputs and output |
| 69 | * |
| 70 | * Valid data layouts: |
| 71 | * - All |
| 72 | * |
| 73 | * Valid data type configurations: |
| 74 | * |src0 |src1 |src2 |dst | |
| 75 | * |:------------|:-----------|:---------|:--------------| |
| 76 | * |F32 |F32 |F32 |F32 | |
| 77 | * |F16 |F16 |F16 |F16 | |
| 78 | * |
| 79 | * @note GEMM: General Matrix Multiply - [alpha * A * B + beta * C]. |
| 80 | * |
| 81 | * @note All tensors must have the same data type. |
| 82 | * |
| 83 | * @note Whilst the first input tensor can be a vector, the second input tensor must be at least a matrix |
| 84 | * |
| 85 | * @note Batched GEMM only allows RHS tensor's rank to be <= 3 |
| 86 | * @note Batched GEMM only supports broadcasting cases where RHS rank < LHS rank but not the other way around |
| 87 | * |
| 88 | * @param[in] compile_context The compile context to be used. |
| 89 | * @param[in] a First input tensor (Matrix or Vector A). Data types supported: F16/F32 |
| 90 | * @param[in] b Second input tensor (Matrix B). Data type supported: same as @p a. |
| 91 | * @param[in] c Third input tensor (Matrix C). It can be a nullptr if just the multiplication between @p a and @p b is needed. Data type supported: same as @p a. |
| 92 | * @param[out] output Output tensor. Data type supported: same as @p a |
| 93 | * @param[in] alpha Weight of the matrix product |
| 94 | * @param[in] beta Weight of matrix C |
| 95 | * @param[in] gemm_info (Optional) Specifies if the matrix A and/or matrix B have been reshaped and |
| 96 | * if the reshape of matrix B should happen only for the first run. GEMMInfo also contains information about the reshaping |
| 97 | * in case matrix A and matrix B have been already transformed. |
| 98 | */ |
| 99 | void configure(const CLCompileContext &compile_context, |
| 100 | const ICLTensor *a, |
| 101 | const ICLTensor *b, |
| 102 | const ICLTensor *c, |
| 103 | ICLTensor *output, |
| 104 | float alpha, |
| 105 | float beta, |
| 106 | const GEMMInfo &gemm_info = GEMMInfo()); |