• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1syntax = "proto3";
2
3package tensorflow;
4option cc_enable_arenas = true;
5option java_outer_classname = "TensorProtos";
6option java_multiple_files = true;
7option java_package = "org.tensorflow.framework";
8option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework";
9import "tensorflow/core/framework/resource_handle.proto";
10import "tensorflow/core/framework/tensor_shape.proto";
11import "tensorflow/core/framework/types.proto";
12
13// Protocol buffer representing a tensor.
14message TensorProto {
15  DataType dtype = 1;
16
17  // Shape of the tensor.  TODO(touts): sort out the 0-rank issues.
18  TensorShapeProto tensor_shape = 2;
19
20  // Only one of the representations below is set, one of "tensor_contents" and
21  // the "xxx_val" attributes.  We are not using oneof because as oneofs cannot
22  // contain repeated fields it would require another extra set of messages.
23
24  // Version number.
25  //
26  // In version 0, if the "repeated xxx" representations contain only one
27  // element, that element is repeated to fill the shape.  This makes it easy
28  // to represent a constant Tensor with a single value.
29  int32 version_number = 3;
30
31  // Serialized raw tensor content from either Tensor::AsProtoTensorContent or
32  // memcpy in tensorflow::grpc::EncodeTensorToByteBuffer. This representation
33  // can be used for all tensor types. The purpose of this representation is to
34  // reduce serialization overhead during RPC call by avoiding serialization of
35  // many repeated small items.
36  bytes tensor_content = 4;
37
38  // Type specific representations that make it easy to create tensor protos in
39  // all languages.  Only the representation corresponding to "dtype" can
40  // be set.  The values hold the flattened representation of the tensor in
41  // row major order.
42
43  // DT_HALF, DT_BFLOAT16. Note that since protobuf has no int16 type, we'll
44  // have some pointless zero padding for each value here.
45  repeated int32 half_val = 13 [packed = true];
46
47  // DT_FLOAT.
48  repeated float float_val = 5 [packed = true];
49
50  // DT_DOUBLE.
51  repeated double double_val = 6 [packed = true];
52
53  // DT_INT32, DT_INT16, DT_INT8, DT_UINT8.
54  repeated int32 int_val = 7 [packed = true];
55
56  // DT_STRING
57  repeated bytes string_val = 8;
58
59  // DT_COMPLEX64. scomplex_val(2*i) and scomplex_val(2*i+1) are real
60  // and imaginary parts of i-th single precision complex.
61  repeated float scomplex_val = 9 [packed = true];
62
63  // DT_INT64
64  repeated int64 int64_val = 10 [packed = true];
65
66  // DT_BOOL
67  repeated bool bool_val = 11 [packed = true];
68
69  // DT_COMPLEX128. dcomplex_val(2*i) and dcomplex_val(2*i+1) are real
70  // and imaginary parts of i-th double precision complex.
71  repeated double dcomplex_val = 12 [packed = true];
72
73  // DT_RESOURCE
74  repeated ResourceHandleProto resource_handle_val = 14;
75
76  // DT_VARIANT
77  repeated VariantTensorDataProto variant_val = 15;
78
79  // DT_UINT32
80  repeated uint32 uint32_val = 16 [packed = true];
81
82  // DT_UINT64
83  repeated uint64 uint64_val = 17 [packed = true];
84};
85
86// Protocol buffer representing the serialization format of DT_VARIANT tensors.
87message VariantTensorDataProto {
88  // Name of the type of objects being serialized.
89  string type_name = 1;
90  // Portions of the object that are not Tensors.
91  bytes metadata = 2;
92  // Tensors contained within objects being serialized.
93  repeated TensorProto tensors = 3;
94}
95