Skip to content

Commit 6023741

Browse files
committed
Apply [EnforceRange] to all integer types
Fixes #562
1 parent 0de084d commit 6023741

1 file changed

Lines changed: 56 additions & 41 deletions

File tree

index.bs

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ dictionary MLOperandDescriptor {
10861086

10871087
// The dimensions field is empty for scalar operands,
10881088
// and non-empty for tensor operands.
1089-
sequence<unsigned long> dimensions = [];
1089+
sequence<[EnforceRange] unsigned long> dimensions = [];
10901090
};
10911091
</script>
10921092

@@ -1531,7 +1531,7 @@ Return the index location of the minimum or maxmium values of all the input valu
15311531

15321532
<script type=idl>
15331533
dictionary MLArgMinMaxOptions {
1534-
sequence<unsigned long> axes;
1534+
sequence<[EnforceRange] unsigned long> axes;
15351535
boolean keepDimensions = false;
15361536
boolean selectLastIndex = false;
15371537
};
@@ -1617,7 +1617,7 @@ Normalize the values of the input tensor using [[Batch-Normalization]]. For each
16171617
dictionary MLBatchNormalizationOptions {
16181618
MLOperand scale;
16191619
MLOperand bias;
1620-
unsigned long axis = 1;
1620+
[EnforceRange] unsigned long axis = 1;
16211621
float epsilon = 1e-5;
16221622
MLActivation activation;
16231623
};
@@ -1851,7 +1851,7 @@ partial interface MLGraphBuilder {
18511851
Concatenates the input tensors along a given axis.
18521852
<script type=idl>
18531853
partial interface MLGraphBuilder {
1854-
MLOperand concat(sequence<MLOperand> inputs, unsigned long axis);
1854+
MLOperand concat(sequence<MLOperand> inputs, [EnforceRange] unsigned long axis);
18551855
};
18561856
</script>
18571857
<div>
@@ -1917,10 +1917,10 @@ enum MLConv2dFilterOperandLayout {
19171917
};
19181918

19191919
dictionary MLConv2dOptions {
1920-
sequence<unsigned long> padding;
1921-
sequence<unsigned long> strides;
1922-
sequence<unsigned long> dilations;
1923-
unsigned long groups = 1;
1920+
sequence<[EnforceRange] unsigned long> padding;
1921+
sequence<[EnforceRange] unsigned long> strides;
1922+
sequence<[EnforceRange] unsigned long> dilations;
1923+
[EnforceRange] unsigned long groups = 1;
19241924
MLInputOperandLayout inputLayout = "nchw";
19251925
MLConv2dFilterOperandLayout filterLayout = "oihw";
19261926
MLOperand bias;
@@ -2115,12 +2115,12 @@ enum MLConvTranspose2dFilterOperandLayout {
21152115
};
21162116

21172117
dictionary MLConvTranspose2dOptions {
2118-
sequence<unsigned long> padding;
2119-
sequence<unsigned long> strides;
2120-
sequence<unsigned long> dilations;
2121-
sequence<unsigned long> outputPadding;
2122-
sequence<unsigned long> outputSizes;
2123-
unsigned long groups = 1;
2118+
sequence<[EnforceRange] unsigned long> padding;
2119+
sequence<[EnforceRange] unsigned long> strides;
2120+
sequence<[EnforceRange] unsigned long> dilations;
2121+
sequence<[EnforceRange] unsigned long> outputPadding;
2122+
sequence<[EnforceRange] unsigned long> outputSizes;
2123+
[EnforceRange] unsigned long groups = 1;
21242124
MLInputOperandLayout inputLayout = "nchw";
21252125
MLConvTranspose2dFilterOperandLayout filterLayout = "iohw";
21262126
MLOperand bias;
@@ -2803,7 +2803,7 @@ partial interface MLGraphBuilder {
28032803
Expand any dimension of size 1 of the input tensor to a larger size according to the new shape. The expansion is consistent with [[!numpy-broadcasting-rule]]. The input dimensions must have the size of 1 or match the sizes of the corresponding output dimensions according to the new shape.
28042804
<script type=idl>
28052805
partial interface MLGraphBuilder {
2806-
MLOperand expand(MLOperand input, sequence<unsigned long> newShape);
2806+
MLOperand expand(MLOperand input, sequence<[EnforceRange] unsigned long> newShape);
28072807
};
28082808
</script>
28092809
<div>
@@ -2843,7 +2843,7 @@ partial interface MLGraphBuilder {
28432843
Gather values of the input tensor along an axis according to the indices.
28442844
<script type=idl>
28452845
dictionary MLGatherOptions {
2846-
unsigned long axis = 0;
2846+
[EnforceRange] unsigned long axis = 0;
28472847
};
28482848

28492849
partial interface MLGraphBuilder {
@@ -3096,8 +3096,11 @@ dictionary MLGruOptions {
30963096
};
30973097

30983098
partial interface MLGraphBuilder {
3099-
sequence<MLOperand> gru(MLOperand input, MLOperand weight, MLOperand recurrentWeight,
3100-
unsigned long steps, unsigned long hiddenSize,
3099+
sequence<MLOperand> gru(MLOperand input,
3100+
MLOperand weight,
3101+
MLOperand recurrentWeight,
3102+
[EnforceRange] unsigned long steps,
3103+
[EnforceRange] unsigned long hiddenSize,
31013104
optional MLGruOptions options = {});
31023105
};
31033106
</script>
@@ -3257,8 +3260,11 @@ dictionary MLGruCellOptions {
32573260
};
32583261

32593262
partial interface MLGraphBuilder {
3260-
MLOperand gruCell(MLOperand input, MLOperand weight, MLOperand recurrentWeight,
3261-
MLOperand hiddenState, unsigned long hiddenSize,
3263+
MLOperand gruCell(MLOperand input,
3264+
MLOperand weight,
3265+
MLOperand recurrentWeight,
3266+
MLOperand hiddenState,
3267+
[EnforceRange] unsigned long hiddenSize,
32623268
optional MLGruCellOptions options = {});
32633269
};
32643270
</script>
@@ -3712,7 +3718,7 @@ Normalize the input using [[Layer-Normalization]]. Unlike {{MLGraphBuilder/batch
37123718
dictionary MLLayerNormalizationOptions {
37133719
MLOperand scale;
37143720
MLOperand bias;
3715-
sequence<unsigned long> axes;
3721+
sequence<[EnforceRange] unsigned long> axes;
37163722
float epsilon = 1e-5;
37173723
};
37183724

@@ -4008,8 +4014,11 @@ dictionary MLLstmOptions {
40084014
};
40094015

40104016
partial interface MLGraphBuilder {
4011-
sequence<MLOperand> lstm(MLOperand input, MLOperand weight, MLOperand recurrentWeight,
4012-
unsigned long steps, unsigned long hiddenSize,
4017+
sequence<MLOperand> lstm(MLOperand input,
4018+
MLOperand weight,
4019+
MLOperand recurrentWeight,
4020+
[EnforceRange] unsigned long steps,
4021+
[EnforceRange] unsigned long hiddenSize,
40134022
optional MLLstmOptions options = {});
40144023
};
40154024
</script>
@@ -4219,8 +4228,12 @@ dictionary MLLstmCellOptions {
42194228
};
42204229

42214230
partial interface MLGraphBuilder {
4222-
sequence<MLOperand> lstmCell(MLOperand input, MLOperand weight, MLOperand recurrentWeight,
4223-
MLOperand hiddenState, MLOperand cellState, unsigned long hiddenSize,
4231+
sequence<MLOperand> lstmCell(MLOperand input,
4232+
MLOperand weight,
4233+
MLOperand recurrentWeight,
4234+
MLOperand hiddenState,
4235+
MLOperand cellState,
4236+
[EnforceRange] unsigned long hiddenSize,
42244237
optional MLLstmCellOptions options = {});
42254238
};
42264239
</script>
@@ -4501,8 +4514,8 @@ dictionary MLPadOptions {
45014514

45024515
partial interface MLGraphBuilder {
45034516
MLOperand pad(MLOperand input,
4504-
sequence<unsigned long> beginningPadding,
4505-
sequence<unsigned long> endingPadding,
4517+
sequence<[EnforceRange] unsigned long> beginningPadding,
4518+
sequence<[EnforceRange] unsigned long> endingPadding,
45064519
optional MLPadOptions options = {});
45074520
};
45084521
</script>
@@ -4618,13 +4631,13 @@ enum MLRoundingType {
46184631
};
46194632

46204633
dictionary MLPool2dOptions {
4621-
sequence<unsigned long> windowDimensions;
4622-
sequence<unsigned long> padding;
4623-
sequence<unsigned long> strides;
4624-
sequence<unsigned long> dilations;
4634+
sequence<[EnforceRange] unsigned long> windowDimensions;
4635+
sequence<[EnforceRange] unsigned long> padding;
4636+
sequence<[EnforceRange] unsigned long> strides;
4637+
sequence<[EnforceRange] unsigned long> dilations;
46254638
MLInputOperandLayout layout = "nchw";
46264639
MLRoundingType roundingType = "floor";
4627-
sequence<unsigned long> outputSizes;
4640+
sequence<[EnforceRange] unsigned long> outputSizes;
46284641
};
46294642

46304643
partial interface MLGraphBuilder {
@@ -4885,7 +4898,7 @@ partial interface MLGraphBuilder {
48854898
Reduce the input tensor along all dimensions, or along the axes specified in the {{MLReduceOptions/axes}} array parameter. For each specified axis, the dimension with that index is reduced, i.e. the resulting tensor will not contain it, unless the {{MLReduceOptions/keepDimensions}} option is specified. The values of the resulting tensor are calculated using the specified reduction function that takes as parameters all the values across the reduced dimension.
48864899
<script type=idl>
48874900
dictionary MLReduceOptions {
4888-
sequence<unsigned long> axes;
4901+
sequence<[EnforceRange] unsigned long> axes;
48894902
boolean keepDimensions = false;
48904903
};
48914904

@@ -5139,8 +5152,8 @@ enum MLInterpolationMode {
51395152
dictionary MLResample2dOptions {
51405153
MLInterpolationMode mode = "nearest-neighbor";
51415154
sequence<float> scales;
5142-
sequence<unsigned long> sizes;
5143-
sequence<unsigned long> axes;
5155+
sequence<[EnforceRange] unsigned long> sizes;
5156+
sequence<[EnforceRange] unsigned long> axes;
51445157
};
51455158

51465159
partial interface MLGraphBuilder {
@@ -5234,7 +5247,7 @@ partial interface MLGraphBuilder {
52345247
Alter the shape of a tensor to a new shape. Reshape does not copy or change the content of the tensor. It just changes the tensor's logical dimensions for the subsequent operations.
52355248
<script type=idl>
52365249
partial interface MLGraphBuilder {
5237-
MLOperand reshape(MLOperand input, sequence<unsigned long> newShape);
5250+
MLOperand reshape(MLOperand input, sequence<[EnforceRange] unsigned long> newShape);
52385251
};
52395252
</script>
52405253
<div>
@@ -5390,7 +5403,9 @@ partial interface MLGraphBuilder {
53905403
Produce a slice of the input tensor.
53915404
<script type=idl>
53925405
partial interface MLGraphBuilder {
5393-
MLOperand slice(MLOperand input, sequence<unsigned long> starts, sequence<unsigned long> sizes);
5406+
MLOperand slice(MLOperand input,
5407+
sequence<[EnforceRange] unsigned long> starts,
5408+
sequence<[EnforceRange] unsigned long> sizes);
53945409
};
53955410
</script>
53965411
<div>
@@ -5666,12 +5681,12 @@ partial interface MLGraphBuilder {
56665681
Split the input tensor into a number of sub tensors along the given axis.
56675682
<script type=idl>
56685683
dictionary MLSplitOptions {
5669-
unsigned long axis = 0;
5684+
[EnforceRange] unsigned long axis = 0;
56705685
};
56715686

56725687
partial interface MLGraphBuilder {
56735688
sequence<MLOperand> split(MLOperand input,
5674-
(unsigned long or sequence<unsigned long>) splits,
5689+
([EnforceRange] unsigned long or sequence<[EnforceRange] unsigned long>) splits,
56755690
optional MLSplitOptions options = {});
56765691
};
56775692
</script>
@@ -5814,7 +5829,7 @@ partial interface MLGraphBuilder {
58145829
Permute the dimensions of the input tensor according to the *permutation* argument.
58155830
<script type=idl>
58165831
dictionary MLTransposeOptions {
5817-
sequence<unsigned long> permutation;
5832+
sequence<[EnforceRange] unsigned long> permutation;
58185833
};
58195834

58205835
partial interface MLGraphBuilder {
@@ -5868,7 +5883,7 @@ Given a 2-D tensor (matrix), return a 2-D tensor containing either the upper or
58685883
<script type=idl>
58695884
dictionary MLTriangularOptions {
58705885
boolean upper = true;
5871-
long diagonal = 0;
5886+
[EnforceRange] long diagonal = 0;
58725887
};
58735888

58745889
partial interface MLGraphBuilder {

0 commit comments

Comments
 (0)