DataFormat.proto 2.4 KB
Newer Older
1
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
Z
zhangjinchao01 已提交
2 3 4 5 6 7 8 9 10 11 12 13

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. */
Y
Yu Yang 已提交
14
syntax = "proto2";
Z
zhangjinchao01 已提交
15 16 17 18 19

package paddle;

/*
 If values is not empty and ids is empty, this is a dense vector.
L
liaogang 已提交
20 21
 If values is not empty and ids is not empty, this is a sparse vector. The
 position of each value
Z
zhangjinchao01 已提交
22
 is specified by ids.
L
liaogang 已提交
23 24
 If values is empty and ids is not empty, this is a sparse vector whose non-zero
 values are 1.
Z
zhangjinchao01 已提交
25 26 27
 The position of each 1 is specified by ids.
*/
message VectorSlot {
L
liaogang 已提交
28 29
  repeated float values = 1 [ packed = true ];
  repeated uint32 ids = 2 [ packed = true ];
Z
zhangjinchao01 已提交
30
  /* For multidimensional data, for example "image width height depth" */
L
liaogang 已提交
31 32
  repeated uint32 dims = 3 [ packed = true ];
  repeated string strs = 4;
Z
zhangjinchao01 已提交
33 34 35
};

/*
L
liaogang 已提交
36 37 38 39 40 41
 SubseqSlot use to record whether VectorSlot or any other slot in future has
 subseq.
 If not all VectorSlot have subseq, we only store the one who has subseq, and
 use *slot_id* to record it.
 One vector_slots has one sequence, and it may have N subseq, thus the number of
 *lens* will be N too.
Z
zhangjinchao01 已提交
42 43
*/
message SubseqSlot {
L
liaogang 已提交
44 45
  required uint32 slot_id = 1; // the id of slot who has subseq
  repeated uint32 lens = 2;    // lengths of sub-sequence in the slot
Z
zhangjinchao01 已提交
46 47 48 49 50 51 52
};

message SlotDef {
  enum SlotType {
    VECTOR_DENSE = 0;
    VECTOR_SPARSE_NON_VALUE = 1;
    VECTOR_SPARSE_VALUE = 2;
L
liaogang 已提交
53
    INDEX = 3; // This can be used as label, or word id, etc.
Z
zhangjinchao01 已提交
54 55 56 57 58
    VAR_MDIM_DENSE = 4;
    VAR_MDIM_INDEX = 5;
    STRING = 6;
  }
  required SlotType type = 1;
L
liaogang 已提交
59 60
  required uint32 dim =
      2; // For INDEX slots, this means the maximal index plus 1.
Z
zhangjinchao01 已提交
61 62 63 64 65 66 67 68
};

message DataHeader {
  // INDEX slot should be always after VECTOR slots.
  repeated SlotDef slot_defs = 1;
};

message DataSample {
L
liaogang 已提交
69 70
  optional bool is_beginning = 1
      [ default = true ]; // is the beginning of a sequence
Z
zhangjinchao01 已提交
71
  repeated VectorSlot vector_slots = 2;
L
liaogang 已提交
72
  repeated uint32 id_slots = 3 [ packed = true ];
Z
zhangjinchao01 已提交
73 74 75 76
  /* use ids of VectorSlot */
  repeated VectorSlot var_id_slots = 4;
  repeated SubseqSlot subseq_slots = 5;
};