framework.proto 2.8 KB
Newer Older
Y
Yi Wang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.

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 = "proto2";
package paddle.framework;

enum AttrType {
  INT = 0;
  FLOAT = 1;
  STRING = 2;
  INTS = 3;
  FLOATS = 4;
  STRINGS = 5;
25
  INT_PAIRS = 6;
D
dangqingqing 已提交
26 27
  BOOL = 7;
  BOOLS = 8;
Y
Yi Wang 已提交
28 29
}

30 31 32 33 34
message IntPair {
  required int32 first = 1;
  required int32 second = 2;
};

Y
Yi Wang 已提交
35 36 37 38 39 40 41 42 43 44 45 46 47
// OpDesc describes an instance of a C++ framework::OperatorBase
// derived class type.
message OpDesc {

  message Attr {
    required string name = 1;
    required AttrType type = 2;
    optional int32 i = 3;
    optional float f = 4;
    optional string s = 5;
    repeated int32 ints = 6;
    repeated float floats = 7;
    repeated string strings = 8;
48
    repeated IntPair int_pairs = 9;
D
dangqingqing 已提交
49 50
    optional bool b = 10;
    repeated bool bools = 6;
Y
Yi Wang 已提交
51 52 53
  };

  message Var {
54 55
    required string parameter = 1;
    repeated string arguments = 2;
Y
Yi Wang 已提交
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
  };

  required string type = 3;
  repeated Var inputs = 1;
  repeated Var outputs = 2;
  repeated Attr attrs = 4;
};

// OpProto describes a C++ framework::OperatorBase derived class.
message OpProto {

  // VarProto describes the C++ type framework::Variable.
  message Var {
    required string name = 1;
    required string comment = 2;
Y
Yu Yang 已提交
71

Y
Yi Wang 已提交
72 73
    optional bool duplicable = 3 [ default = false ];
    optional bool intermediate = 4 [ default = false ];
74
    optional bool not_in_gradient = 5 [ default = false ];
Y
Yi Wang 已提交
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
  }

  // AttrProto describes the C++ type Attribute.
  message Attr {
    required string name = 1;
    required AttrType type = 2;
    required string comment = 3;
    // If that attribute is generated, it means the Paddle third
    // language binding has responsibility to fill that
    // attribute. End-User should not set that attribute.
    optional bool generated = 4 [ default = false ];
  }

  required string type = 1;
  repeated Var inputs = 2;
  repeated Var outputs = 3;
  repeated Attr attrs = 4;
  required string comment = 5;
}
Q
qiaolongfei 已提交
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

enum DataType {
  BOOL = 0;
  INT16 = 1;
  INT32 = 2;
  INT64 = 3;
  FP16 = 4;
  FP32 = 5;
  FP64 = 6;
}

message LoDTensorDesc {
  required DataType data_type = 1;
  repeated int32 dims = 2; // [UNK, 640, 480] is saved as [-1, 640, 480]
  optional int32 lod_level = 3 [ default = 0 ];
}

message VarDesc {
  required string name = 1;
  optional LoDTensorDesc lod_tensor = 2;
}