2020-11-05 16:41:56 +08:00
|
|
|
//
|
|
|
|
// GeometryComputerUtils.hpp
|
|
|
|
// MNN
|
|
|
|
//
|
|
|
|
// Created by MNN on 2020/05/11.
|
|
|
|
// Copyright © 2018, Alibaba Group Holding Limited
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef GeometryComputerUtils_hpp
|
|
|
|
#define GeometryComputerUtils_hpp
|
|
|
|
#include "core/Schedule.hpp"
|
|
|
|
#include "geometry/GeometryComputer.hpp"
|
|
|
|
namespace MNN {
|
2024-04-19 11:58:21 +08:00
|
|
|
class FileLoader;
|
2021-02-07 10:45:07 +08:00
|
|
|
class GeometryComputerUtils {
|
2020-11-05 16:41:56 +08:00
|
|
|
public:
|
2021-02-07 10:45:07 +08:00
|
|
|
MNN_PUBLIC static void makeRaster(const CommandBuffer& srcBuffer, CommandBuffer& dstBuffer, GeometryComputer::Context& ctx);
|
2020-11-05 16:41:56 +08:00
|
|
|
static void addConvert(const CommandBuffer& srcBuffer, CommandBuffer& dstBuffer, GeometryComputer::Context& ctx);
|
2024-04-19 11:58:21 +08:00
|
|
|
static std::shared_ptr<Command> makeCommand(flatbuffers::FlatBufferBuilder& builder, const std::vector<Tensor*>& inputs, const std::vector<Tensor*>& outputs);
|
|
|
|
static std::shared_ptr<Command> makeBinary(int type, Tensor* input0, Tensor* input1, Tensor* output);
|
|
|
|
static std::shared_ptr<Command> makeReduce(ReductionType type, Tensor* input0, Tensor* output);
|
|
|
|
static std::shared_ptr<Command> makeUnary(UnaryOpOperation type, Tensor* input0, Tensor* output);
|
2024-05-11 19:17:02 +08:00
|
|
|
static std::shared_ptr<Command> makeLayerNorm(Tensor* input0, Tensor* output, std::vector<int32_t> axis, float epsilon, std::vector<float> gamma, std::vector<float> beta, std::vector<int64_t> external, int group = 1, bool useRMS = false);
|
2024-04-19 11:58:21 +08:00
|
|
|
static std::shared_ptr<Command> makeMatMul(Tensor* input0, Tensor* input1, Tensor* output, Tensor* Bias = nullptr,
|
2020-11-05 16:41:56 +08:00
|
|
|
bool transposeA = false, bool transposeB = false);
|
2021-02-07 10:45:07 +08:00
|
|
|
static flatbuffers::Offset<Op> makePool(flatbuffers::FlatBufferBuilder& builder, std::pair<int, int> kernel, std::pair<int, int> stride, PoolType type, MNN::PoolPadType pad, std::pair<int, int> pads, bool isglobal, AvgPoolCountType countType = AvgPoolCountType_DEFAULT);
|
2020-11-05 16:41:56 +08:00
|
|
|
|
|
|
|
static Tensor::InsideDescribe::Region makeRawAddressRef(Tensor* src, int srcOffset, int size, int dstOffset = 0);
|
|
|
|
static void makeRawAddressRef(Tensor* dst, Tensor* src, int srcOffset, int size, int dstOffset = 0);
|
2022-12-30 15:18:58 +08:00
|
|
|
MNN_PUBLIC static int buildConstantTensors(std::vector<Schedule::OpCacheInfo>& infos);
|
2025-01-22 14:47:50 +08:00
|
|
|
// TODO: Remove cpuRuntime parameter in future
|
|
|
|
MNN_PUBLIC static ErrorCode shapeComputeAndGeometryTransform(const Runtime* cpuRuntime, FileLoader* external, std::vector<Schedule::OpCacheInfo>& infos,
|
2020-11-05 16:41:56 +08:00
|
|
|
GeometryComputer::Context& geoContext,
|
2021-06-11 17:17:13 +08:00
|
|
|
std::shared_ptr<Backend> backupBackend,
|
2023-07-18 09:36:26 +08:00
|
|
|
Runtime::CompilerType compileType, bool skipShapeCompute = false, bool permitCodegen = false);
|
2020-11-05 16:41:56 +08:00
|
|
|
};
|
|
|
|
}; // namespace MNN
|
|
|
|
|
|
|
|
#endif
|