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