1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_ML_NN_COMMON_GRAPH_DUMP_H
18 #define ANDROID_ML_NN_COMMON_GRAPH_DUMP_H
19 
20 #include <android/hardware/neuralnetworks/1.1/types.h>
21 
22 #include <iostream>
23 
24 namespace android {
25 namespace nn {
26 
27 // Write a representation of the model in Graphviz (.dot) format to
28 // the specified stream.  (See http://www.graphviz.org.)
29 //
30 // Operations are represented by boxes, and operands by ellipses.  The
31 // number in a box/ellipse is the operation/operand index.  In the
32 // case of an operation, we include the operation type (such as ADD).
33 // In the case of an operand, we include the an abbreviated form of
34 // the operand code (such as FLOAT32) and dimensions; and, if the
35 // operand has lifetime CONSTANT_COPY, CONSTANT_REFERENCE, or
36 // NO_VALUE, an abbreviated form of that lifetime.
37 //
38 // A graph edge from an operand to an operation is marked with the
39 // input index (position in the operation's input vector).  A graph
40 // edge from an operation to an operand is marked with the output
41 // index (position in the operation's output vector).  The number is
42 // omitted from a lone input edge or a lone output edge.
43 //
44 // A model input or output (operand) is shown in "reverse colors" --
45 // white text on a black background.
46 //
47 void graphDump(const char* name, const ::android::hardware::neuralnetworks::V1_1::Model& model,
48                std::ostream& outStream = std::cout);
49 
50 }  // namespace nn
51 }  // namespace android
52 
53 #endif  // ANDROID_ML_NN_COMMON_GRAPH_DUMP_H
54