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 5.2 kB

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