-
Notifications
You must be signed in to change notification settings - Fork 658
/
Copy pathNeuralNetwork.proto
5502 lines (4756 loc) · 144 KB
/
NeuralNetwork.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2017-2019, Apple Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-3-clause license that can be
// found in LICENSE.txt or at https://opensource.org/licenses/BSD-3-Clause
/**
* A neural network is defined through a collection of layers
* and represents a directed acyclic graph (DAG).
* Each layer has a name, a layer type,
* a list of input names, a list of output names,
* and a collection of parameters specific to the layer type.
*
* The graph structure and connectivity of the neural network
* is inferred from the input and output names.
* A neural network starts with the layer
* whose input name is equal to the value specified in
* ``Model.description.input.name``,
* and ends with the layer
* whose output name is equal to the value specified in
* ``Model.description.output.name``.
* Layers must have unique input and output names,
* and a layer may not have input or output names that
* refer to layers that are not yet defined.
*
* For CoreML specification version <=3,
* all inputs are mapped to static rank 5 tensors, with axis notations
* [Sequence, Batch, Channel, Height, Width].
*
* From specification version 4 onwards (iOS >= 13, macOS >= 10.15), more options are available
* (see enums ``NeuralNetworkMultiArrayShapeMapping``, ``NeuralNetworkImageShapeMapping``)
* to map inputs to generic N-Dimensional (or N rank) tensors, where N >= 1.
*
* Each layer type may have specific constraints on the ranks of its inputs and outputs.
*
* Some of the layers (such as softmax, reduce, etc) have parameters that have been described in
* terms of notational axis "Channel", "Height", "Width" or "Sequence". They can be re-interpreted easily in
* the general ND setting by using the following rule:
* "width" is same as axis = -1 (i.e. the last axis from the end)
* "height" is same as axis = -2 (i.e. the second last axis from the end)
* "channel" is same as axis = -3 (i.e. the third last axis from the end)
* "sequence" is same as axis = -5 (i.e. the fifth last axis from the end)
*
* Several layers are available in 3 different variations, with the names ending
* in identifiers: ``like``, ``static`` and ``dynamic``. For instance, ``FillLike``,
* ``FillStatic`` and ``FillDynamic``. The ``static`` variation generally will have
* a property corresponding to the shape of the output. For instance, if the
* output of the ``FillStatic`` layer is desired to be of shape (10, 4), the
* property ``targetShape`` will have to be set to [10, 4]. In the ``dynamic`` case,
* the shape is an input, hence it can be changed at runtime. For instance, for
* a ``FillDynamic`` layer, the input would have to be an array containing the
* values 10 and 4, if the desired output is of shape (10, 4). Whereas in the
* ``like`` case, the additional input's shape is used as the output shape, ignoring
* its values. For instance, for a ``FillLike`` layer, for an input with shape
* (10, 4), the output generated will also be of shape (10, 4), values of the
* input will be ignored.
*/
syntax = "proto3";
option optimize_for = LITE_RUNTIME;
import public "DataStructures.proto";
import public "Parameters.proto";
package CoreML.Specification;
enum NeuralNetworkMultiArrayShapeMapping {
/*
* Describes how the MultiArray shape for the inputs,
* provided in Features Types proto via model description,
* is mapped to construct tensors that are fed into the Neural Network layers.
*/
/*
* Default legacy value. Only supported for CoreML Specification version <= 3.
*
* The default legacy shape mapping resolves all input shapes to a rank 5 equivalent
* with axis notation of [Seq, Batch, Channel, Height, Width].
*
* When this enum value is selected,
* the repeated shape field in the message "ArrayFeatureType" in feature types proto,
* must be either length 1 or length 3.
*
* The following rule is used to map the values in the shape field to the actual tensor shape:
* rank 1 shape is mapped to shape [1,1,C,1,1]
* rank 3 shape is mapped to shape [1,1,C,H,W]
* At runtime, the first two dimensions (Seq or Batch) can be presented as well, with non-1 values.
*
* It is invalid to use this enum value if any of the layers added
* Specification version 4 (iOS >= 13, macOS >= 10.15) onwards are used in the network.
* Validator will raise an error in that case.
*/
RANK5_ARRAY_MAPPING = 0;
/*
* The exact shape and rank (i.e. number of dimensions in the shape) of the input,
* as specified in the message "ArrayFeatureType", is passed through to the layers.
* Supported only for Specification version >= 4 (iOS >= 13, macOS >= 10.15).
*/
EXACT_ARRAY_MAPPING = 1;
}
enum NeuralNetworkImageShapeMapping {
/*
* Describes how the shape of the input tensors is constructed from image inputs.
*/
/*
* In this case, image input is mapped to a rank 5 tensor.
* For Color images, input tensor is shaped as [1,1,3,H,W].
* For Gray images, input tensor is shaped as [1,1,1,H,W].
*/
RANK5_IMAGE_MAPPING = 0;
/*
* For Color images, input tensor is shaped as [1,3,H,W].
* For Gray images, input tensor is shaped as [1,1,H,W].
* Supported only for Specification version >= 4 (iOS >= 13, macOS >= 10.15).
*/
RANK4_IMAGE_MAPPING = 1;
}
/**
A neural network.
*/
message NeuralNetwork {
repeated NeuralNetworkLayer layers = 1;
repeated NeuralNetworkPreprocessing preprocessing = 2;
// use this enum value to determine the input tensor shapes to the neural network, for multiarray inputs
NeuralNetworkMultiArrayShapeMapping arrayInputShapeMapping = 5;
// use this enum value to determine the input tensor shapes to the neural network, for image inputs
NeuralNetworkImageShapeMapping imageInputShapeMapping = 6;
NetworkUpdateParameters updateParams = 10;
}
/// Preprocessing
/// -------------
/**
* A neural network preprocessor that
* performs a scalar multiplication of an image
* followed by addition of scalar biases to the channels.
*
* Input: X
* An image in BGR or RGB format with shape ``[3, H, W]``
* or in grayscale format with shape ``[1, H, W]``.
* Output: Y
* An image with format and shape corresponding to the input.
*
* If the input image is in BGR format:
*
* .. code::
*
* Y[0, :, :] = channelScale * X[0, :, :] + blueBias
* Y[1, :, :] = channelScale * X[1, :, :] + greenBias
* Y[2, :, :] = channelScale * X[2, :, :] + redBias
*
* If the input image is in RGB format:
*
* .. code::
*
* Y[0, :, :] = channelScale * X[0, :, :] + redBias
* Y[1, :, :] = channelScale * X[1, :, :] + greenBias
* Y[2, :, :] = channelScale * X[2, :, :] + blueBias
*
* If the input image is in grayscale format:
*
* .. code::
*
* Y[0, :, :] = channelScale * X[0, :, :] + grayBias
*/
message NeuralNetworkImageScaler {
float channelScale = 10; ///Scalar to be multiplied.
float blueBias = 20; ///Scalar blue bias to be added.
float greenBias = 21; ///Scalar green bias to be added.
float redBias = 22; ///Scalar red bias to be added.
float grayBias = 30; ///Scalar bias to be added for grayscale images.
}
/**
* A neural network preprocessor that
* subtracts the provided mean image from the input image.
* The mean image is subtracted from the input named
* ``NeuralNetworkPreprocessing.featureName``.
*/
message NeuralNetworkMeanImage {
/**
* Mean image stored as a flattened array of floats,
* representing shape [Channel,Height,Width].
*/
repeated float meanImage = 1;
}
/// Preprocessing parameters for image inputs.
message NeuralNetworkPreprocessing {
string featureName = 1; /// must be equal to the input name to which the preprocessing is applied
oneof preprocessor {
NeuralNetworkImageScaler scaler = 10;
NeuralNetworkMeanImage meanImage = 11;
}
}
/// Activation Functions
/// --------------------
/**
* A rectified linear unit (ReLU) activation function.
*
* This function has the following formula:
*
* .. math::
* f(x) = \text{max}(0, x)
*/
message ActivationReLU {
}
/**
* A leaky rectified linear unit (ReLU) activation function.
*
* This function has the following formula:
*
* .. math::
* f(x) = \begin{cases}
* x & \text{if } x \geq 0 \\
* \alpha x & \text{if } x < 0
* \end{cases}
*/
message ActivationLeakyReLU {
float alpha = 1; //negative slope value for leakyReLU
}
/**
* A hyperbolic tangent activation function.
*
* This function has the following formula:
*
* .. math::
* f(x) = \dfrac{1 - e^{-2x}}{1 + e^{-2x}}
*/
message ActivationTanh {
}
/**
* A scaled hyperbolic tangent activation function.
*
* This function has the following formula:
*
* .. math::
* f(x) = \alpha \tanh(\beta x)
*/
message ActivationScaledTanh {
float alpha = 1;
float beta = 2;
}
/**
* A sigmoid activation function.
*
* This function has the following formula:
*
* .. math::
* f(x) = \dfrac{1}{1 + e^{-x}}
*/
message ActivationSigmoid {
}
/**
* A linear activation function.
*
* This function has the following formula:
*
* .. math::
* f(x) = \alpha x + \beta
*/
message ActivationLinear {
float alpha = 1;
float beta = 2;
}
/**
* A hard sigmoid activation function.
*
* This function has the following formula:
*
* .. math::
* f(x) = \text{min}(\text{max}(\alpha x + \beta, 0), 1)
*/
message ActivationSigmoidHard {
float alpha = 1;
float beta = 2;
}
/**
* A parameterized rectified linear unit (PReLU) activation function.
* Input must be at least rank 3. Axis = -3 is denoted by "C", or channels.
* "alpha" parameter can be a vector of length C.
*
* This function has the following formula:
*
* .. math::
* f(x_i) = \begin{cases}
* x_i & \text{if } x_i \geq 0 \\
* \alpha_i x_i & \text{if } x_i < 0
* \end{cases} \;,\;i=1,...,C
*/
message ActivationPReLU {
// parameter of length C or 1.
// If length is 1, same value is used for all channels
WeightParams alpha = 1;
}
/**
* An exponential linear unit (ELU) activation function.
*
* This function has the following formula:
*
* .. math::
* f(x) = \begin{cases}
* x & \text{if } x \geq 0 \\
* \alpha (e^x - 1) & \text{if } x < 0
* \end{cases}
*/
message ActivationELU {
float alpha = 1;
}
/**
* A thresholded rectified linear unit (ReLU) activation function.
*
* This function has the following formula:
*
* .. math::
* f(x) = \begin{cases}
* x & \text{if } x \geq \alpha \\
* 0 & \text{if } x < \alpha
* \end{cases}
*/
message ActivationThresholdedReLU {
float alpha = 1;
}
/**
* A softsign activation function.
*
* This function has the following formula:
*
* .. math::
* f(x) = \dfrac{x}{1 + |x|}
*/
message ActivationSoftsign {
}
/**
* A softplus activation function.
*
* This function has the following formula:
*
* .. math::
* f(x) = \text{log}(1 + e^x)
*/
message ActivationSoftplus {
}
/**
* A parametric softplus activation function.
* Input must be at least rank 3. axis = -3 is denoted by "C", or channels.
* "alpha"/"beta" parameter can be a vector of length C.
*
* This function has the following formula:
*
* .. math::
* f(x_i) = \alpha_i \text{log}(1 + e^{\beta_i x_i}) \;,\;i=1,...,C
*/
message ActivationParametricSoftplus {
// If length is 1, same value is used for all channels
WeightParams alpha = 1; //parameter of length C or 1
WeightParams beta = 2; //parameter of length C or 1
}
message ActivationParams {
oneof NonlinearityType {
ActivationLinear linear = 5;
ActivationReLU ReLU = 10;
ActivationLeakyReLU leakyReLU = 15;
ActivationThresholdedReLU thresholdedReLU = 20;
ActivationPReLU PReLU = 25;
ActivationTanh tanh = 30;
ActivationScaledTanh scaledTanh = 31;
ActivationSigmoid sigmoid = 40;
ActivationSigmoidHard sigmoidHard = 41;
ActivationELU ELU = 50;
ActivationSoftsign softsign = 60;
ActivationSoftplus softplus = 70;
ActivationParametricSoftplus parametricSoftplus = 71;
}
}
/**
* Representation of the intermediate tensors
*/
message Tensor {
// Number of dimensions in the tensor shape
uint32 rank = 1;
// actual value of the tensor shape.
// must be of length "rank". Can contain -1s for unknown dimensions.
repeated int64 dimValue = 2;
}
/**
* A single neural network layer.
*/
message NeuralNetworkLayer {
string name = 1; //descriptive name of the layer
repeated string input = 2;
repeated string output = 3;
repeated Tensor inputTensor = 4; // must be the same length as the "input" field
repeated Tensor outputTensor = 5; // must be the same length as the "output" field
// Must be set to true to mark the layer as updatable.
// If true, the weightParams in the layer's properties must also be set to updatable
// If false, the value of the isUpdatable parameter within the layer's weights are ignored
bool isUpdatable = 10;
oneof layer {
// Start at 100 here
ConvolutionLayerParams convolution = 100;
PoolingLayerParams pooling = 120;
ActivationParams activation = 130;
InnerProductLayerParams innerProduct = 140;
EmbeddingLayerParams embedding = 150;
// Normalization related layers
BatchnormLayerParams batchnorm = 160;
MeanVarianceNormalizeLayerParams mvn = 165;
L2NormalizeLayerParams l2normalize = 170;
SoftmaxLayerParams softmax = 175;
LRNLayerParams lrn = 180;
CropLayerParams crop = 190;
PaddingLayerParams padding = 200;
UpsampleLayerParams upsample = 210;
ResizeBilinearLayerParams resizeBilinear = 211;
CropResizeLayerParams cropResize = 212;
UnaryFunctionLayerParams unary = 220;
// Elementwise operations
AddLayerParams add = 230;
MultiplyLayerParams multiply = 231;
AverageLayerParams average = 240;
ScaleLayerParams scale = 245;
BiasLayerParams bias = 250;
MaxLayerParams max = 260;
MinLayerParams min = 261;
DotProductLayerParams dot = 270;
ReduceLayerParams reduce = 280;
LoadConstantLayerParams loadConstant = 290;
// Data reorganization
ReshapeLayerParams reshape = 300;
FlattenLayerParams flatten = 301;
PermuteLayerParams permute = 310;
ConcatLayerParams concat = 320;
SplitLayerParams split = 330;
SequenceRepeatLayerParams sequenceRepeat = 340;
ReorganizeDataLayerParams reorganizeData = 345;
SliceLayerParams slice = 350;
// Recurrent Layers
SimpleRecurrentLayerParams simpleRecurrent = 400;
GRULayerParams gru = 410;
UniDirectionalLSTMLayerParams uniDirectionalLSTM = 420;
BiDirectionalLSTMLayerParams biDirectionalLSTM = 430;
// Custom (user-implemented) Layer
CustomLayerParams custom = 500;
// Following layers are available only after CoreML Specification
// version >= 4 (iOS >= 13, macOS >= 10.15)
// Control Flow related Layers
CopyLayerParams copy = 600;
BranchLayerParams branch = 605;
LoopLayerParams loop = 615;
LoopBreakLayerParams loopBreak = 620;
LoopContinueLayerParams loopContinue = 625;
RangeStaticLayerParams rangeStatic = 635;
RangeDynamicLayerParams rangeDynamic = 640;
// Elementwise Unary Layers
ClipLayerParams clip = 660;
CeilLayerParams ceil = 665;
FloorLayerParams floor = 670;
SignLayerParams sign = 680;
RoundLayerParams round = 685;
Exp2LayerParams exp2 = 700;
SinLayerParams sin = 710;
CosLayerParams cos = 715;
TanLayerParams tan = 720;
AsinLayerParams asin = 730;
AcosLayerParams acos = 735;
AtanLayerParams atan = 740;
SinhLayerParams sinh = 750;
CoshLayerParams cosh = 755;
TanhLayerParams tanh = 760;
AsinhLayerParams asinh = 770;
AcoshLayerParams acosh = 775;
AtanhLayerParams atanh = 780;
ErfLayerParams erf = 790;
GeluLayerParams gelu = 795;
// Elementwise Binary with Broadcasting Support
EqualLayerParams equal = 815;
NotEqualLayerParams notEqual = 820;
LessThanLayerParams lessThan = 825;
LessEqualLayerParams lessEqual = 827;
GreaterThanLayerParams greaterThan = 830;
GreaterEqualLayerParams greaterEqual = 832;
LogicalOrLayerParams logicalOr = 840;
LogicalXorLayerParams logicalXor = 845;
LogicalNotLayerParams logicalNot = 850;
LogicalAndLayerParams logicalAnd = 855;
ModBroadcastableLayerParams modBroadcastable = 865;
MinBroadcastableLayerParams minBroadcastable = 870;
MaxBroadcastableLayerParams maxBroadcastable = 875;
AddBroadcastableLayerParams addBroadcastable = 880;
PowBroadcastableLayerParams powBroadcastable = 885;
DivideBroadcastableLayerParams divideBroadcastable = 890;
FloorDivBroadcastableLayerParams floorDivBroadcastable = 895;
MultiplyBroadcastableLayerParams multiplyBroadcastable = 900;
SubtractBroadcastableLayerParams subtractBroadcastable = 905;
// Tensor Manipulations
TileLayerParams tile = 920;
StackLayerParams stack = 925;
GatherLayerParams gather = 930;
ScatterLayerParams scatter = 935;
GatherNDLayerParams gatherND = 940;
ScatterNDLayerParams scatterND = 945;
SoftmaxNDLayerParams softmaxND = 950;
GatherAlongAxisLayerParams gatherAlongAxis = 952;
ScatterAlongAxisLayerParams scatterAlongAxis = 954;
ReverseLayerParams reverse = 960;
ReverseSeqLayerParams reverseSeq = 965;
SplitNDLayerParams splitND = 975;
ConcatNDLayerParams concatND = 980;
TransposeLayerParams transpose = 985;
SliceStaticLayerParams sliceStatic = 995;
SliceDynamicLayerParams sliceDynamic = 1000;
SlidingWindowsLayerParams slidingWindows = 1005;
TopKLayerParams topK = 1015;
ArgMinLayerParams argMin = 1020;
ArgMaxLayerParams argMax = 1025;
EmbeddingNDLayerParams embeddingND = 1040;
BatchedMatMulLayerParams batchedMatmul = 1045;
// Tensor Allocation / Reshape sort of operations
GetShapeLayerParams getShape = 1065;
LoadConstantNDLayerParams loadConstantND = 1070;
FillLikeLayerParams fillLike = 1080;
FillStaticLayerParams fillStatic = 1085;
FillDynamicLayerParams fillDynamic = 1090;
BroadcastToLikeLayerParams broadcastToLike = 1100;
BroadcastToStaticLayerParams broadcastToStatic = 1105;
BroadcastToDynamicLayerParams broadcastToDynamic = 1110;
SqueezeLayerParams squeeze = 1120;
ExpandDimsLayerParams expandDims = 1125;
FlattenTo2DLayerParams flattenTo2D = 1130;
ReshapeLikeLayerParams reshapeLike = 1135;
ReshapeStaticLayerParams reshapeStatic = 1140;
ReshapeDynamicLayerParams reshapeDynamic = 1145;
RankPreservingReshapeLayerParams rankPreservingReshape = 1150;
ConstantPaddingLayerParams constantPad = 1155;
// Random Distributions
RandomNormalLikeLayerParams randomNormalLike = 1170;
RandomNormalStaticLayerParams randomNormalStatic = 1175;
RandomNormalDynamicLayerParams randomNormalDynamic = 1180;
RandomUniformLikeLayerParams randomUniformLike = 1190;
RandomUniformStaticLayerParams randomUniformStatic = 1195;
RandomUniformDynamicLayerParams randomUniformDynamic = 1200;
RandomBernoulliLikeLayerParams randomBernoulliLike = 1210;
RandomBernoulliStaticLayerParams randomBernoulliStatic = 1215;
RandomBernoulliDynamicLayerParams randomBernoulliDynamic = 1220;
CategoricalDistributionLayerParams categoricalDistribution = 1230;
// Reduction related Layers:
ReduceL1LayerParams reduceL1 = 1250;
ReduceL2LayerParams reduceL2 = 1255;
ReduceMaxLayerParams reduceMax = 1260;
ReduceMinLayerParams reduceMin = 1265;
ReduceSumLayerParams reduceSum = 1270;
ReduceProdLayerParams reduceProd = 1275;
ReduceMeanLayerParams reduceMean = 1280;
ReduceLogSumLayerParams reduceLogSum = 1285;
ReduceSumSquareLayerParams reduceSumSquare = 1290;
ReduceLogSumExpLayerParams reduceLogSumExp = 1295;
// Masking / Selection Layers
WhereNonZeroLayerParams whereNonZero = 1313;
MatrixBandPartLayerParams matrixBandPart = 1315;
LowerTriangularLayerParams lowerTriangular = 1320;
UpperTriangularLayerParams upperTriangular = 1325;
WhereBroadcastableLayerParams whereBroadcastable = 1330;
// Normalization Layers
LayerNormalizationLayerParams layerNormalization = 1350;
NonMaximumSuppressionLayerParams NonMaximumSuppression = 1400;
}
}
/**
* Branching Layer
*
* A layer that providies the functionality of branching or an If-Else block.
*
* Must have 1 input. There are no outputs as the execution is transferred to either the
* if or the else branch based on the value of the input.
*
* Input is the condition predicate. Must be a scalar (length 1 tensor).
*
*/
message BranchLayerParams {
/**
* execute this graph if the absolute value of the input Tensor is greater than 1e-6
* This must be present.
*/
NeuralNetwork ifBranch = 1;
/**
* execute this graph if the absolute value of the input Tensor is less than 1e-6
* This is optional.
*/
NeuralNetwork elseBranch = 2;
}
/**
* Loop Layer
*
* A layer that providies the functionality of a "for" loop or a "while" loop.
*
* There are either no inputs or 1 input. When an input is present, it corresponds to the maximum loop count,
* in that case the value of the "maxLoopIterations" field is ignored. Input must be a scalar.
* (For description below, maxLoopIterations is assumed to be the value of the input, when its present)
*
* No outputs are produced. Blobs produced by the condition or the body network are visible in the scope of the overall network.
*
* "conditionNetwork" must produce a tensor with the name specified in the "conditionVar" field.
*
* There are 3 possible cases for determining the termination condition:
*
* Case 1:
*
* If there is no "conditionNetwork", in this case the layer corresponds to a pure for loop, which is run "maxLoopIterations" number of times.
* Equivalent pseudo-code:
*
* for loopIterator = 0 : maxLoopIterations
* bodyNetwork()
*
*
* Case 2:
*
* "conditionNetwork" is present, and "maxLoopIterations" is 0 and there is no input,
* in this case the layer corresponds to a while loop. Equivalent pseudo-code:
*
* conditionVar = conditionNetwork()
* while conditionVar:
* bodyNetwork()
* conditionVar = conditionNetwork()
*
*
* Case 3:
*
* "conditionNetwork" is provided, and "maxLoopIterations" is positive or there is an input,
* in this case the layer corresponds to a while loop with a joint condition. Equivalent pseudo-code:
*
* loopIterator = 0
* conditionVar = conditionNetwork()
* while (conditionVar and loopIterator < maxLoopIterations):
* bodyNetwork()
* loopIterator = loopIterator + 1
* conditionVar = conditionNetwork()
*
*/
message LoopLayerParams {
/**
* maximum number of iterations. Ignored if input is present.
*/
uint64 maxLoopIterations = 1;
/**
* This field provides the name of the tensor which is produced by the conditionNetwork
* and whose value is checked to start/continue/terminate the loop. Value close to 0.0f is treated as False.
* This field is optional.
* Must be a non empty string if and only if "conditionNetwork" is present.
*/
string conditionVar = 2;
/**
* Must generate a tensor with the name provided in the "conditionVar" field.
* This field is optional.
* Must be present if and only if "conditionVar" field is a non empty string.
*/
NeuralNetwork conditionNetwork = 3;
/**
* Body of the loop.
* This field must be present.
*/
NeuralNetwork bodyNetwork = 4;
}
/**
* Loop break Layer
*
* Terminate the loop that has this layer.
* If present, it should always reside in the "bodyNetwork" of the loop layer
*
* No inputs/outputs
*
*/
message LoopBreakLayerParams {
}
/**
* Loop Continue Layer
*
* Stop the current loop iteration and continue on the next iteration.
* If present, it should always reside in the "bodyNetwork" of the loop layer
*
* No inputs/outputs
*
*/
message LoopContinueLayerParams {
}
/**
* Copy Layer
*
* A layer that copies its input tensor to the output tensor.
* Must have 1 input and 1 output, with distinct names.
* This is the only layer that is allowed to re-generate an output that is already present in the neural network prior to this layer,
* in which case it will overwrite the output tensor.
*
*/
message CopyLayerParams {
}
/**
* GreaterThan Layer
*
* Either 1 or 2 inputs.
* Produces 1 output.
* Perform elementwise greater than operation.
*
* Output is 1.0f if the condition is true otherwise 0.0f.
*
* .. code::
*
* y = x1 > x2
* or
* y = x1 > alpha, if only one input is provided
*
* Broadcasting is supported.
*
*/
message GreaterThanLayerParams {
/**
* Compare to the scalar value provided here if there is 1 input
*/
float alpha = 2;
}
/**
* GreaterEqual Layer
*
* Either 1 or 2 inputs.
* Produces 1 output.
* Perform elementwise greater equal operation.
*
* Output is 1.0f if the condition is true otherwise 0.0f.
*
* .. code::
*
* y = x1 >= x2
* or
* y = x1 >= alpha, if only one input is provided
*
* Broadcasting is supported.
*
*/
message GreaterEqualLayerParams {
/**
* Compare to the scalar value provided here if there is 1 input
*/
float alpha = 2;
}
/**
* LessThan Layer
*
* Either 1 or 2 inputs.
* Produces 1 output.
* Perform elementwise less than operation.
*
* Output is 1.0f if the condition is true otherwise 0.0f.
*
* .. code::
*
* y = x1 < x2
* or
* y = x1 < alpha, if only one input is provided
*
* Broadcasting is supported.
*
*/
message LessThanLayerParams {
/**
* Compare to the scalar value provided here if there is 1 input
*/
float alpha = 2;
}
/**
* LessEqual Layer
*
* Either 1 or 2 inputs.
* Produces 1 output.
* Perform elementwise less equal operation.
*
* Output is 1.0f if the condition is true otherwise 0.0f.
*
* .. code::
*
* y = x1 <= x2
* or
* y = x1 <= alpha, if only one input is provided
*
* Broadcasting is supported.
*
*/
message LessEqualLayerParams {
/**
* Compare to the scalar value provided here if there is 1 input
*/
float alpha = 2;
}
/**
* Equal Layer
*
* Either 1 or 2 inputs.
* Produces 1 output.
* Perform elementwise equal operation.
*
* Output is 1.0f if the condition is true otherwise 0.0f.
*
* .. code::
*
* y = x1 == x2
* or
* y = x1 == alpha, if only one input is provided
*
* Broadcasting is supported.
*
*/
message EqualLayerParams {
/**
* Compare to the scalar value provided here if there is 1 input
*/
float alpha = 1;
}
/**
* NotEqual Layer
*
* Either 1 or 2 inputs.
* Produces 1 output.
* Perform elementwise not equal operation.
*
* Output is 1.0f if the condition is true otherwise 0.0f.
*
* .. code::
*
* y = x1 != x2
* or
* y = x1 != alpha, if only one input is provided
*
* Broadcasting is supported.
*
*/
message NotEqualLayerParams {
/**
* Compare to the scalar value provided here if there is 1 input
*/
float alpha = 1;
}
/**
* LogicalAnd Layer
*
* Must have 2 inputs, produces 1 output.