|
| 1 | +@0x8316e0f30c445924; |
| 2 | + |
| 3 | +# The structs here try to mirror all the *Config structs as close as possible. |
| 4 | +# Before changing anything take a look at https://capnproto.org/language.html#evolving-your-protocol |
| 5 | + |
| 6 | +struct Weight { |
| 7 | + name @0 :Text; |
| 8 | + tensor @1 :Tensor; |
| 9 | +} |
| 10 | + |
| 11 | +struct Tensor { |
| 12 | + shape @0 :List(UInt64); |
| 13 | + data @1 :List(Float32); |
| 14 | +} |
| 15 | + |
| 16 | +struct Layer { |
| 17 | + name @0 :Text; |
| 18 | + config @1 :LayerConfig; |
| 19 | + weightsData @2 :List(Weight); |
| 20 | +} |
| 21 | + |
| 22 | +struct LayerConfig { |
| 23 | + name @0 :Text; |
| 24 | + layerType :union { |
| 25 | + # Common layers |
| 26 | + convolution @1 :ConvolutionConfig; |
| 27 | + linear @2 :LinearConfig; |
| 28 | + logSoftmax @3 :Void; |
| 29 | + pooling @4 :PoolingConfig; |
| 30 | + sequential @5 :SequentialConfig; |
| 31 | + softmax @6 :Void; |
| 32 | + # Activation layers |
| 33 | + relu @7 :Void; |
| 34 | + sigmoid @8 :Void; |
| 35 | + # Loss layers |
| 36 | + negativeLogLikelihood @9 :NegativeLogLikelihoodConfig; |
| 37 | + # Utility layers |
| 38 | + reshape @10 :ReshapeConfig; |
| 39 | + } |
| 40 | + |
| 41 | + outputs @11 :List(Text); |
| 42 | + inputs @12 :List(Text); |
| 43 | + params @13 :List(WeightConfig); |
| 44 | + propagateDown @14 :List(Bool); |
| 45 | +} |
| 46 | + |
| 47 | +# TODO: incomplete since WeightConfig isn't really used internally in Leaf. |
| 48 | +struct WeightConfig { |
| 49 | + name @0 :Text; |
| 50 | +} |
| 51 | + |
| 52 | +struct ConvolutionConfig { |
| 53 | + numOutput @0 :UInt64; |
| 54 | + filterShape @1 :List(UInt64); |
| 55 | + stride @2 :List(UInt64); |
| 56 | + padding @3 :List(UInt64); |
| 57 | +} |
| 58 | + |
| 59 | +struct LinearConfig { |
| 60 | + outputSize @0 :UInt64; |
| 61 | +} |
| 62 | + |
| 63 | +struct PoolingConfig { |
| 64 | + mode @0 :PoolingMode; |
| 65 | + filterShape @1 :List(UInt64); |
| 66 | + stride @2 :List(UInt64); |
| 67 | + padding @3 :List(UInt64); |
| 68 | +} |
| 69 | + |
| 70 | +enum PoolingMode { |
| 71 | + max @0; |
| 72 | + average @1; # not implemented yet, but we can't create a single variant enum so this is better than a meaningless "Dummy" value. |
| 73 | +} |
| 74 | + |
| 75 | +struct SequentialConfig { |
| 76 | + layers @0 :List(LayerConfig); |
| 77 | + inputs @1 :List(ShapedInput); |
| 78 | + forceBackward @2 :Bool; |
| 79 | +} |
| 80 | + |
| 81 | +struct ShapedInput { |
| 82 | + name @0 :Text; |
| 83 | + shape @1 :List(UInt64); |
| 84 | +} |
| 85 | + |
| 86 | +struct NegativeLogLikelihoodConfig { |
| 87 | + numClasses @0 :UInt64; |
| 88 | +} |
| 89 | + |
| 90 | +struct ReshapeConfig { |
| 91 | + shape @0 :List(UInt64); |
| 92 | +} |
0 commit comments