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.1 kB

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