MCPcopy Create free account
hub / github.com/alibaba/MNN / tensorflow2MNNNet

Function tensorflow2MNNNet

tools/converter/source/tensorflow/tensorflowConverter.cpp:16–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include "tensorflowConverter.hpp"
15
16int tensorflow2MNNNet(const std::string inputModel, const std::string bizCode,
17 std::unique_ptr<MNN::NetT> &netT) {
18 // Load tensorflow model.
19 tensorflow::GraphDef tfGraph;
20 bool success = tf_read_proto_from_binary(inputModel.c_str(), &tfGraph);
21 DCHECK(success) << "read_proto_from_binary failed!";
22 if (!success) {
23 MNN_ERROR("[ERROR] MNNConvert just support tensorflow frozen graph model. Model file is not tf frozen graph model.\n");
24 return 1;
25 }
26
27 TFGraphResolver resolver(tfGraph);
28 for (int i = 0; i < resolver.graph_size(); ++i) {
29 const TFGraph *graph = resolver.graph(i);
30 auto graph_proto = graph->ToProto();
31 // The graph indexed by 0 is main graph.
32 if (i == 0) {
33 netT->oplists = std::move(graph_proto->nodes);
34 netT->tensorName = graph_proto->tensors;
35 } else {
36 netT->subgraphs.push_back(std::move(graph_proto));
37 }
38 }
39 netT->sourceType = MNN::NetSource_TENSORFLOW;
40 netT->bizCode = bizCode;
41 return 0;
42}

Callers 1

convertModelMethod · 0.85

Calls 6

graph_sizeMethod · 0.80
graphMethod · 0.80
ToProtoMethod · 0.80
c_strMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected