MCPcopy Create free account
hub / github.com/ARM-software/armnn / SerializeNetworkToDotFile

Function SerializeNetworkToDotFile

tests/ExecuteNetwork/ArmNNExecutor.cpp:78–123  ·  view source on GitHub ↗

* Given a reference to an optimized network and a target directory, serialize the network in .dot file format to * a file called " _optimized_networkgraph.dot" * * @param network The network to serialize. * @param dumpDir The target directory. * @return the full path to the serialized file. */

Source from the content-addressed store, hash-verified

76 * @return the full path to the serialized file.
77 */
78std::string SerializeNetworkToDotFile(const armnn::IOptimizedNetwork& optimizedNetwork, const std::string& dumpDir)
79{
80 if (dumpDir.empty())
81 {
82 throw InvalidArgumentException("An output directory must be specified.");
83 }
84 fs::path outputDirectory(dumpDir);
85 if (!exists(outputDirectory))
86 {
87 throw InvalidArgumentException(
88 fmt::format("The specified directory does not exist: {}", outputDirectory.c_str()));
89 }
90
91 fs::path fileName;
92 fileName += dumpDir;
93 // used to get a timestamp to name diagnostic files (the ArmNN serialized graph
94 // and getSupportedOperations.txt files)
95 timespec ts;
96 if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) == 0)
97 {
98 std::stringstream ss;
99 ss << std::to_string(ts.tv_sec) << "_" << std::to_string(ts.tv_nsec) << "_optimized_networkgraph.dot";
100 fileName += ss.str();
101 }
102 else
103 {
104 // This is incredibly unlikely but just in case.
105 throw RuntimeException("clock_gettime, CLOCK_MONOTONIC_RAW returned a non zero result.");
106 }
107
108 // Write the network graph to a dot file.
109 std::ofstream fileStream;
110 fileStream.open(fileName, std::ofstream::out | std::ofstream::trunc);
111 if (!fileStream.good())
112 {
113 throw RuntimeException(fmt::format("An error occurred when creating %s", fileName.c_str()));
114 }
115
116 if (optimizedNetwork.SerializeToDot(fileStream) != armnn::Status::Success)
117 {
118 throw RuntimeException(fmt::format("An error occurred when serializing to file %s", fileName.c_str()));
119 }
120 fileStream.flush();
121 fileStream.close();
122 return fileName;
123}
124#endif
125
126ArmNNExecutor::ArmNNExecutor(const ExecuteNetworkParams& params, armnn::IRuntime::CreationOptions runtimeOptions)

Callers 1

ArmNNExecutorMethod · 0.85

Calls 11

existsFunction · 0.85
formatEnum · 0.85
RuntimeExceptionClass · 0.85
emptyMethod · 0.80
flushMethod · 0.80
to_stringFunction · 0.50
c_strMethod · 0.45
strMethod · 0.45
openMethod · 0.45
SerializeToDotMethod · 0.45

Tested by

no test coverage detected