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.2/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 (if provided) or to the logcat (if no stream 29 // is provided). (See http://www.graphviz.org.) 30 // 31 // Operations are represented by boxes, and operands by ellipses. The 32 // number in a box/ellipse is the operation/operand index. In the 33 // case of an operation, we include the operation type (such as ADD). 34 // In the case of an operand, we include the an abbreviated form of 35 // the operand code (such as FLOAT32) and dimensions; and, if the 36 // operand has lifetime CONSTANT_COPY, CONSTANT_REFERENCE, or 37 // NO_VALUE, an abbreviated form of that lifetime. 38 // 39 // A graph edge from an operand to an operation is marked with the 40 // input index (position in the operation's input vector). A graph 41 // edge from an operation to an operand is marked with the output 42 // index (position in the operation's output vector). The number is 43 // omitted from a lone input edge or a lone output edge. 44 // 45 // A model input or output (operand) is shown in "reverse colors" -- 46 // white text on a black background. 47 // 48 void graphDump(const char* name, 49 const ::android::hardware::neuralnetworks::V1_2::Model& model, 50 std::ostream* outStream = nullptr); 51 52 } // namespace nn 53 } // namespace android 54 55 #endif // ANDROID_ML_NN_COMMON_GRAPH_DUMP_H 56