// // 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 { class FileLoader; class GeometryComputerUtils { public: MNN_PUBLIC static void makeRaster(const CommandBuffer& srcBuffer, CommandBuffer& dstBuffer, GeometryComputer::Context& ctx); static void addConvert(const CommandBuffer& srcBuffer, CommandBuffer& dstBuffer, GeometryComputer::Context& ctx); static std::shared_ptr makeCommand(flatbuffers::FlatBufferBuilder& builder, const std::vector& inputs, const std::vector& outputs); static std::shared_ptr makeBinary(int type, Tensor* input0, Tensor* input1, Tensor* output); static std::shared_ptr makeReduce(ReductionType type, Tensor* input0, Tensor* output, int axis = 1); static std::shared_ptr makeUnary(UnaryOpOperation type, Tensor* input0, Tensor* output); static std::shared_ptr makeLayerNorm(Tensor* input0, Tensor* output, std::vector axis, float epsilon, std::vector gamma, std::vector beta, std::vector external, int group = 1, bool useRMS = false); static std::shared_ptr makeMatMul(Tensor* input0, Tensor* input1, Tensor* output, Tensor* Bias = nullptr, bool transposeA = false, bool transposeB = false); static flatbuffers::Offset makePool(flatbuffers::FlatBufferBuilder& builder, std::pair kernel, std::pair stride, PoolType type, MNN::PoolPadType pad, std::pair pads, bool isglobal, AvgPoolCountType countType = AvgPoolCountType_DEFAULT); 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); MNN_PUBLIC static int buildConstantTensors(std::vector& infos); // TODO: Remove cpuRuntime parameter in future MNN_PUBLIC static ErrorCode shapeComputeAndGeometryTransform(const Runtime* cpuRuntime, FileLoader* external, std::vector& infos, GeometryComputer::Context& geoContext, std::shared_ptr backupBackend, Runtime::CompilerType compileType, bool skipShapeCompute = false, bool permitCodegen = false); }; }; // namespace MNN #endif