Skip to content

Commit 68cefc7

Browse files
committed
Bugfix: Add missing validation for conv2d() and convTranspose2d()
1 parent 74b9831 commit 68cefc7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

index.bs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1851,6 +1851,7 @@ partial interface MLGraphBuilder {
18511851
1. If any element in |options|.{{MLConv2dOptions/strides}} is equal to 0, then [=exception/throw=] a {{TypeError}}.
18521852
1. If |options|.{{MLConv2dOptions/dilations}} does not [=map/exist=], set it to the [=/list=] « 1, 1 ».
18531853
1. Otherwise, if |options|.{{MLConv2dOptions/dilations}}'s [=list/size=] is not 2, then [=exception/throw=] a {{TypeError}}.
1854+
1. If any element in |options|.{{MLConv2dOptions/dilations}} is equal to 0, then [=exception/throw=] a {{TypeError}}.
18541855
1. If |options|.{{MLConv2dOptions/groups}} is 0, then [=exception/throw=] a {{TypeError}}.
18551856
1. *Calculate the output shape:*
18561857
1. Let |inputShape| be |input|'s [=MLOperand/shape=].
@@ -2060,12 +2061,14 @@ partial interface MLGraphBuilder {
20602061
1. If any element in |options|.{{MLConv2dOptions/strides}} is equal to 0, then [=exception/throw=] a {{TypeError}}.
20612062
1. If |options|.{{MLConvTranspose2dOptions/dilations}} does not [=map/exist=], set it to the [=/list=] « 1, 1 ».
20622063
1. Otherwise, if |options|.{{MLConvTranspose2dOptions/dilations}}'s [=list/size=] is not 2, then [=exception/throw=] a {{TypeError}}.
2064+
1. If any element in |options|.{{MLConvTranspose2dOptions/dilations}} is equal to 0, then [=exception/throw=] a {{TypeError}}.
20632065
1. If |options|.{{MLConvTranspose2dOptions/outputPadding}} does not [=map/exist=], set it to the [=/list=] « 0, 0 ».
20642066
1. Otherwise, if |options|.{{MLConvTranspose2dOptions/outputPadding}}'s [=list/size=] is not 2, then [=exception/throw=] a {{TypeError}}.
20652067
1. If |options|.{{MLConvTranspose2dOptions/outputSizes}} [=map/exists=]:
20662068
1. If its [=list/size=] is not 2, then [=exception/throw=] a {{TypeError}}.
20672069
1. Otherwise:
20682070
1. If |options|.{{MLConvTranspose2dOptions/outputPadding}}[0] is greater than or equal to |options|.{{MLConvTranspose2dOptions/strides}}[0], or |options|.{{MLConvTranspose2dOptions/outputPadding}}[1] is greater than or equal to |options|.{{MLConvTranspose2dOptions/strides}}[1], then [=exception/throw=] a {{TypeError}}.
2071+
1. If |options|.{{MLConvTranspose2dOptions/groups}} is 0, then [=exception/throw=] a {{TypeError}}.
20692072
1. *Calculate the output shape:*
20702073
1. Let |inputShape| be |input|'s [=MLOperand/shape=].
20712074
1. Switch on |options|.{{MLConvTranspose2dOptions/inputLayout}}:
@@ -2106,7 +2109,7 @@ partial interface MLGraphBuilder {
21062109
1. Let |filterInputChannels| be |filterShape|[3].
21072110
</dl>
21082111
1. If |inputChannels| is not equal to |filterInputChannels|, then [=exception/throw=] a {{TypeError}}.
2109-
1. Let |outputChannels| be |filterOutputChannels| * |options|.{{MLConvTranspose2dOptions/groups}}
2112+
1. Let |outputChannels| be |filterOutputChannels| * |options|.{{MLConvTranspose2dOptions/groups}}.
21102113
1. If |options|.{{MLConvTranspose2dOptions/bias}} [=map/exists=]:
21112114
1. If its [=MLOperand/shape=] is not equal to « |outputChannels| », then [=exception/throw=] a {{TypeError}}.
21122115
1. If its [=MLOperand/dataType=] is not equal to |input|'s [=MLOperand/dataType=], then [=exception/throw=] a {{TypeError}}.

0 commit comments

Comments
 (0)