MNN/tools/converter/source/optimizer/SubGraphComplete.hpp

51 lines
1.3 KiB
C++
Raw Normal View History

2020-11-05 16:41:56 +08:00
//
// SubGraphComplete.hpp
// MNN
//
// Created by MNN on 2020/06/24.
// Copyright © 2018, Alibaba Group Holding Limited
//
#ifndef MNN_CONVERTER_OPTIMIZER_SUBGRAPH_COMPLETE_HPP_
#define MNN_CONVERTER_OPTIMIZER_SUBGRAPH_COMPLETE_HPP_
#include "MNN/expr/Expr.hpp"
2020-12-15 14:12:35 +08:00
#include <vector>
#include <string>
#include <unordered_map>
#include <functional>
2020-11-05 16:41:56 +08:00
namespace MNN {
namespace Express {
struct OptimizeContext {
std::vector<SubGraphProtoT*> subgraphs;
2020-12-15 14:12:35 +08:00
bool is_training;
bool verbose;
2020-11-05 16:41:56 +08:00
NetSource source;
std::vector<SubGraphProtoT*> completed_subgraphs;
2020-12-15 14:12:35 +08:00
using NetTPtr = std::unique_ptr<MNN::NetT>;
template <typename K, typename V>
using HashMap = std::unordered_map<K, V>;
// NetTPtr (*RunOptimize)(NetTPtr&, const HashMap<std::string, VARP>&);
std::function<NetTPtr(NetTPtr&, // NOLINT
const HashMap<std::string, VARP>&)> RunOptimize;
2020-11-05 16:41:56 +08:00
};
SubGraphProtoT* FindSubGraphByName(
const std::vector<SubGraphProtoT*>& subgraphs,
const std::string& subgraph_name);
bool CompleteSubGraph(const std::unordered_map<std::string, VARP>& inputs,
const SubGraphProtoT* subgraph);
} // namespace Express
} // namespace MNN
#endif // MNN_CONVERTER_OPTIMIZER_SUBGRAPH_COMPLETE_HPP_