GraphDump.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #ifndef ANDROID_ML_NN_COMMON_GRAPH_DUMP_H
  17. #define ANDROID_ML_NN_COMMON_GRAPH_DUMP_H
  18. #include <android/hardware/neuralnetworks/1.2/types.h>
  19. #include <iostream>
  20. namespace android {
  21. namespace nn {
  22. // Write a representation of the model in Graphviz (.dot) format to
  23. // the specified stream (if provided) or to the logcat (if no stream
  24. // is provided). (See http://www.graphviz.org.)
  25. //
  26. // Operations are represented by boxes, and operands by ellipses. The
  27. // number in a box/ellipse is the operation/operand index. In the
  28. // case of an operation, we include the operation type (such as ADD).
  29. // In the case of an operand, we include the an abbreviated form of
  30. // the operand code (such as FLOAT32) and dimensions; and, if the
  31. // operand has lifetime CONSTANT_COPY, CONSTANT_REFERENCE, or
  32. // NO_VALUE, an abbreviated form of that lifetime.
  33. //
  34. // A graph edge from an operand to an operation is marked with the
  35. // input index (position in the operation's input vector). A graph
  36. // edge from an operation to an operand is marked with the output
  37. // index (position in the operation's output vector). The number is
  38. // omitted from a lone input edge or a lone output edge.
  39. //
  40. // A model input or output (operand) is shown in "reverse colors" --
  41. // white text on a black background.
  42. //
  43. void graphDump(const char* name,
  44. const ::android::hardware::neuralnetworks::V1_2::Model& model,
  45. std::ostream* outStream = nullptr);
  46. } // namespace nn
  47. } // namespace android
  48. #endif // ANDROID_ML_NN_COMMON_GRAPH_DUMP_H