2019-04-17 10:49:11 +08:00
|
|
|
//
|
|
|
|
// CPUMatMul.hpp
|
|
|
|
// MNN
|
|
|
|
//
|
|
|
|
// Created by MNN on 2018/08/06.
|
|
|
|
// Copyright © 2018, Alibaba Group Holding Limited
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef CPUMATMUL_HPP
|
|
|
|
#define CPUMATMUL_HPP
|
|
|
|
|
2019-06-17 20:10:35 +08:00
|
|
|
#include <functional>
|
2019-12-27 22:16:57 +08:00
|
|
|
#include "core/Execution.hpp"
|
2020-02-26 09:57:17 +08:00
|
|
|
#include "backend/cpu/compute/StrassenMatmulComputor.hpp"
|
|
|
|
|
2019-04-17 10:49:11 +08:00
|
|
|
namespace MNN {
|
|
|
|
|
|
|
|
class CPUMatMul : public Execution {
|
|
|
|
public:
|
2021-06-11 17:17:13 +08:00
|
|
|
CPUMatMul(Backend *backend, bool transposeA, bool transposeB, bool transposeC, bool multiThread);
|
2019-04-17 10:49:11 +08:00
|
|
|
virtual ~CPUMatMul() = default;
|
2019-06-17 20:10:35 +08:00
|
|
|
virtual ErrorCode onResize(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
|
2019-04-17 10:49:11 +08:00
|
|
|
virtual ErrorCode onExecute(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) override;
|
2021-06-11 17:17:13 +08:00
|
|
|
void execute(const float* APtr, const float* BPtr, float* CPtr, const float* BiasPtr);
|
2019-04-17 10:49:11 +08:00
|
|
|
|
|
|
|
private:
|
2021-06-11 17:17:13 +08:00
|
|
|
void _scheduleForVec(int e, int l, int h);
|
|
|
|
void _scheduleForVecE(int e, int l, int h);
|
2019-04-17 10:49:11 +08:00
|
|
|
bool mTransposeA;
|
|
|
|
bool mTransposeB;
|
2021-06-11 17:17:13 +08:00
|
|
|
bool mTransposeC;
|
2020-02-26 09:57:17 +08:00
|
|
|
bool mSupportMultiThread = false;
|
2021-06-11 17:17:13 +08:00
|
|
|
std::vector<std::pair<std::function<void(int, const float*, const float*, const float*)>, int>> mPreFunctions;
|
|
|
|
std::vector<std::pair<std::function<void(int, const float*, const float*, const float*, float*)>, int>> mPostFunctions;
|
2020-02-26 09:57:17 +08:00
|
|
|
std::shared_ptr<StrassenMatrixComputor> mComputer;
|
2021-06-11 17:17:13 +08:00
|
|
|
bool mStrassenUseBiasDirectly = false;
|
2019-04-17 10:49:11 +08:00
|
|
|
};
|
|
|
|
} // namespace MNN
|
|
|
|
|
|
|
|
#endif // CPUMATMUL_HPP
|