@@ -52,10 +52,14 @@ export class ResNet50V2Nhwc {
52
52
options . bias = await bias ;
53
53
// WebNN spec drops autoPad support, compute the explicit padding instead.
54
54
if ( options . autoPad == 'same-upper' ) {
55
+ const isShapeMethod = typeof weights . shape === 'function' ;
56
+ const inputShape = isShapeMethod ? ( await input ) . shape ( ) :
57
+ ( await input ) . shape ;
58
+ const weightsShape = isShapeMethod ? weights . shape ( ) : weights . shape ;
55
59
options . padding =
56
60
computePadding2DForAutoPad (
57
- /* nwhc */ [ await input . shape ( ) [ 1 ] , await input . shape ( ) [ 2 ] ] ,
58
- /* ohwi */ [ weights . shape ( ) [ 1 ] , weights . shape ( ) [ 2 ] ] ,
61
+ /* nwhc */ [ inputShape [ 1 ] , inputShape [ 2 ] ] ,
62
+ /* ohwi */ [ weightsShape [ 1 ] , weightsShape [ 2 ] ] ,
59
63
options . strides , options . dilations , options . autoPad ) ;
60
64
}
61
65
const conv2d = this . builder_ . conv2d ( await input , weights , options ) ;
@@ -141,10 +145,12 @@ export class ResNet50V2Nhwc {
141
145
const conv1 = await this . buildConv_ (
142
146
input , [ '' , '' , '1' ] , { strides, padding : [ 3 , 3 , 3 , 3 ] } , false ) ;
143
147
const windowDimensions = [ 3 , 3 ] ;
148
+ const conv1Shape = typeof conv1 . shape === 'function' ?
149
+ conv1 . shape ( ) : conv1 . shape ;
144
150
const pool = this . builder_ . maxPool2d (
145
151
conv1 , { windowDimensions, strides, layout,
146
152
padding : computePadding2DForAutoPad (
147
- /* nhwc */ [ conv1 . shape ( ) [ 1 ] , conv1 . shape ( ) [ 2 ] ] ,
153
+ /* nhwc */ [ conv1Shape [ 1 ] , conv1Shape [ 2 ] ] ,
148
154
windowDimensions , strides , /* dilations */ undefined ,
149
155
'same-upper' ) } ) ;
150
156
// Block 1
0 commit comments