MNN/source/math/WingoradGenerater.hpp

47 lines
1.3 KiB
C++
Raw Permalink Normal View History

2019-04-17 10:49:11 +08:00
//
// WingoradGenerater.hpp
// MNN
//
// Created by MNN on 2018/08/20.
// Copyright © 2018, Alibaba Group Holding Limited
//
#ifndef WingoradGenerater_hpp
#define WingoradGenerater_hpp
#include <memory>
2022-08-12 10:30:48 +08:00
#include <vector>
2019-12-27 22:16:57 +08:00
#include "math/Matrix.hpp"
2019-04-17 10:49:11 +08:00
namespace MNN {
namespace Math {
class MNN_PUBLIC WinogradGenerater {
public:
2020-07-04 01:21:30 +08:00
// If dividedInG, make A, B not frac, else make A, G not frac
WinogradGenerater(int computeUnit, int kernelSize, float interp = 0.5f, bool dividedInG = false);
2022-08-12 10:30:48 +08:00
WinogradGenerater(std::vector<int> computeUnit, std::vector<int> kernelSize, float interp = 0.5f, bool dividedInG = false);
2019-04-17 10:49:11 +08:00
~WinogradGenerater() = default;
std::shared_ptr<Tensor> A() const {
return mA;
}
std::shared_ptr<Tensor> B() const {
return mB;
}
std::shared_ptr<Tensor> G() const {
return mG;
}
std::shared_ptr<Tensor> allocTransformWeight(const Tensor* originWeight, int unitCi = 4, int unitCo = 4, bool alloc = true);
2021-04-08 15:34:23 +08:00
void transformWeight(const Tensor* dest, const Tensor* source, bool ciFirst = false);
2019-04-17 10:49:11 +08:00
private:
2022-08-12 10:30:48 +08:00
std::shared_ptr<Tensor> mA, mA_Right;
std::shared_ptr<Tensor> mG, mG_Right;
2019-04-17 10:49:11 +08:00
std::shared_ptr<Tensor> mB;
2022-08-12 10:30:48 +08:00
int mUnitY, mUnitX;
int mKernelY, mKernelX;
2019-04-17 10:49:11 +08:00
};
} // namespace Math
} // namespace MNN
#endif /* WingoradGenerater_hpp */