You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

function.proto 4.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * This file is part of Open Source Software TensorFlow, version 1.15.0 https://github.com/tensorflow/tensorflow
  3. *
  4. * This file is included by GraphEngine so as to support model format conversion from tensorflow model to GraphEngine model.
  5. * This file in this distribution may have been modified by Huawei Technologies Co., Ltd ("Huawei Modifications").
  6. * All Huawei Modifications are Copyright 2019-2020 Huawei Technologies Co., Ltd.
  7. */
  8. syntax = "proto3";
  9. package domi.tensorflow;
  10. option cc_enable_arenas = true;
  11. option java_outer_classname = "FunctionProtos";
  12. option java_multiple_files = true;
  13. option java_package = "org.tensorflow.framework";
  14. import "attr_value.proto";
  15. import "node_def.proto";
  16. import "op_def.proto";
  17. // A library is a set of named functions.
  18. message FunctionDefLibrary {
  19. repeated FunctionDef function = 1;
  20. repeated GradientDef gradient = 2;
  21. }
  22. // A function can be instantiated when the runtime can bind every attr
  23. // with a value. When a GraphDef has a call to a function, it must
  24. // have binding for every attr defined in the signature.
  25. // * device spec, etc.
  26. message FunctionDef {
  27. // The definition of the function's name, arguments, return values,
  28. // attrs etc.
  29. OpDef signature = 1;
  30. // Attributes specific to this function definition.
  31. map<string, AttrValue> attr = 5;
  32. // NOTE: field id 2 deleted on Jan 11, 2017, GraphDef version 21.
  33. reserved 2;
  34. // In both of the following fields, there is the need to specify an
  35. // output that is used as either the input to another node (in
  36. // `node_def`) or as a return value of the function (in `ret`).
  37. // Unlike the NodeDefs in GraphDef, we need to be able to specify a
  38. // list in some cases (instead of just single outputs). Also, we
  39. // need to be able to deal with lists of unknown length (so the
  40. // output index may not be known at function definition time). So
  41. // we use the following format instead:
  42. // * "fun_in" where "fun_in" is the name of a function input arg in
  43. // the `signature` field above. This represents that input, whether
  44. // it is a single tensor or a list.
  45. // * "fun_in:0" gives the first element of a function input arg (a
  46. // non-list input is considered a list of length 1 for these
  47. // purposes).
  48. // * "node:out" where "node" is the name of a node in `node_def` and
  49. // "out" is the name one of its op's output arguments (the name
  50. // comes from the OpDef of the node's op). This represents that
  51. // node's output, whether it is a single tensor or a list.
  52. // Note: We enforce that an op's output arguments are never
  53. // renamed in the backwards-compatibility test.
  54. // * "node:out:0" gives the first element of a node output arg (a
  55. // non-list output is considered a list of length 1 for these
  56. // purposes).
  57. //
  58. // NOT CURRENTLY SUPPORTED (but may be in the future):
  59. // * "node:out:-1" gives last element in a node output list
  60. // * "node:out:1:" gives a list with all but the first element in a
  61. // node output list
  62. // * "node:out::-1" gives a list with all but the last element in a
  63. // node output list
  64. // The body of the function. Unlike the NodeDefs in a GraphDef, attrs
  65. // may have values of type `placeholder` and the `input` field uses
  66. // the "output" format above.
  67. // By convention, "op" in node_def is resolved by consulting with a
  68. // user-defined library first. If not resolved, "func" is assumed to
  69. // be a builtin op.
  70. repeated NodeDef node_def = 3;
  71. // A mapping from the output arg names from `signature` to the
  72. // outputs from `node_def` that should be returned by the function.
  73. map<string, string> ret = 4;
  74. }
  75. // GradientDef defines the gradient function of a function defined in
  76. // a function library.
  77. //
  78. // A gradient function g (specified by gradient_func) for a function f
  79. // (specified by function_name) must follow the following:
  80. //
  81. // The function 'f' must be a numerical function which takes N inputs
  82. // and produces M outputs. Its gradient function 'g', which is a
  83. // function taking N + M inputs and produces N outputs.
  84. //
  85. // I.e. if we have
  86. // (y1, y2, ..., y_M) = f(x1, x2, ..., x_N),
  87. // then, g is
  88. // (dL/dx1, dL/dx2, ..., dL/dx_N) = g(x1, x2, ..., x_N,
  89. // dL/dy1, dL/dy2, ..., dL/dy_M),
  90. // where L is a scalar-value function of (x1, x2, ..., xN) (e.g., the
  91. // loss function). dL/dx_i is the partial derivative of L with respect
  92. // to x_i.
  93. message GradientDef {
  94. string function_name = 1; // The function name.
  95. string gradient_func = 2; // The gradient function's name.
  96. }

图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示