Basic function to execute GEMM. This function calls the following kernels: * * -# cpu::CpuGemm */
| 42 | * -# cpu::CpuGemm |
| 43 | */ |
| 44 | class NEGEMM : public IFunction |
| 45 | { |
| 46 | public: |
| 47 | /** Constructor */ |
| 48 | NEGEMM(std::shared_ptr<IMemoryManager> memory_manager = nullptr, IWeightsManager *weights_manager = nullptr); |
| 49 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 50 | NEGEMM(const NEGEMM &) = delete; |
| 51 | /** Default move constructor */ |
| 52 | NEGEMM(NEGEMM &&) = default; |
| 53 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 54 | NEGEMM &operator=(const NEGEMM &) = delete; |
| 55 | /** Default move assignment operator */ |
| 56 | NEGEMM &operator=(NEGEMM &&) = default; |
| 57 | /** Default destructor */ |
| 58 | ~NEGEMM(); |
| 59 | /** Initialise the kernel's inputs, output |
| 60 | * |
| 61 | * Valid data layouts: |
| 62 | * - All |
| 63 | * |
| 64 | * Valid data type configurations: |
| 65 | * |src0 |src1 |src2 |dst | |
| 66 | * |:------------|:-----------|:---------|:--------------| |
| 67 | * |F32 |F32 |F32 |F32 | |
| 68 | * |F16 |F16 |F16 |F16 | |
| 69 | * |BFLOAT16 |BFLOAT16 |BFLOAT16 |BFLOAT16 | |
| 70 | * |
| 71 | * @note GEMM: General Matrix Multiply - [alpha * A * B + beta * C]. |
| 72 | * @note GEMM: The tensors a, b, c, d must have the same data type. You should not mix data types when calling this function. |
| 73 | * |
| 74 | * @note Batched GEMM only supports broadcasting cases where RHS rank < LHS rank but not the other way around |
| 75 | * |
| 76 | * @param[in] a First input tensor (Matrix A or Vector A). Data type supported: BFLOAT16/F16/F32 |
| 77 | * @param[in] b Second input tensor (Matrix B). Data type supported: same as @p a |
| 78 | * @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 |
| 79 | * @param[out] d Output tensor. Data type supported: same as @p a |
| 80 | * @param[in] alpha Weight of the matrix product |
| 81 | * @param[in] beta Weight of matrix C |
| 82 | * @param[in] gemm_info (Optional) Specifies if the matrix A and/or matrix B have been reshaped and |
| 83 | * if the reshape of matrix B should happen only for the first run |
| 84 | */ |
| 85 | void configure(const ITensor *a, |
| 86 | const ITensor *b, |
| 87 | const ITensor *c, |
| 88 | ITensor *d, |
| 89 | float alpha, |
| 90 | float beta, |
| 91 | const GEMMInfo &gemm_info = GEMMInfo()); |
| 92 | /** Static function to check if given info will lead to a valid configuration of @ref NEGEMM. |
| 93 | * |
| 94 | * Similar to @ref NEGEMM::configure() |
| 95 | * |
| 96 | * @return a status |
| 97 | */ |
| 98 | static Status validate(const ITensorInfo *a, |
| 99 | const ITensorInfo *b, |
| 100 | const ITensorInfo *c, |
| 101 | const ITensorInfo *output, |