|
- /* Copyright 2021 Tianshu AI Platform. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============================================================= */
-
- syntax = "proto3";
- package oneflow;
-
- message TensorShapeProto {
- message Dim {
- int64 size = 1;
- string name = 2;
- }
-
- repeated Dim dim = 2;
- bool unknown_rank = 3;
- };
-
- message TensorProto {
- string dtype = 1;
-
- // Shape of the tensor. TODO(touts): sort out the 0-rank issues.
- TensorShapeProto tensor_shape = 2;
-
- // Only one of the representations below is set, one of "tensor_contents" and
- // the "xxx_val" attributes. We are not using oneof because as oneofs cannot
- // contain repeated fields it would require another extra set of messages.
-
- // Version number.
- //
- // In version 0, if the "repeated xxx" representations contain only one
- // element, that element is repeated to fill the shape. This makes it easy
- // to represent a constant Tensor with a single value.
- int32 version_number = 3;
-
- // Serialized raw tensor content from either Tensor::AsProtoTensorContent or
- // memcpy in tensorflow::grpc::EncodeTensorToByteBuffer. This representation
- // can be used for all tensor types. The purpose of this representation is to
- // reduce serialization overhead during RPC call by avoiding serialization of
- // many repeated small items.
- bytes tensor_content = 4;
-
- // Type specific representations that make it easy to create tensor protos in
- // all languages. Only the representation corresponding to "dtype" can
- // be set. The values hold the flattened representation of the tensor in
- // row major order.
-
- // DT_HALF. Note that since protobuf has no int16 type, we'll have some
- // pointless zero padding for each value here.
- repeated int32 half_val = 13 [packed = true];
-
- // DT_FLOAT.
- repeated float float_val = 5 [packed = true];
-
- // DT_DOUBLE.
- repeated double double_val = 6 [packed = true];
-
- // DT_INT32, DT_INT16, DT_INT8, DT_UINT8.
- repeated int32 int_val = 7 [packed = true];
-
- // DT_STRING
- repeated bytes string_val = 8;
-
- // DT_COMPLEX64. scomplex_val(2*i) and scomplex_val(2*i+1) are real
- // and imaginary parts of i-th single precision complex.
- repeated float scomplex_val = 9 [packed = true];
-
- // DT_INT64
- repeated int64 int64_val = 10 [packed = true];
-
- // DT_BOOL
- repeated bool bool_val = 11 [packed = true];
-
- // DT_COMPLEX128. dcomplex_val(2*i) and dcomplex_val(2*i+1) are real
- // and imaginary parts of i-th double precision complex.
- repeated double dcomplex_val = 12 [packed = true];
-
- };
|