@@ -124,8 +124,82 @@ def _check_transposed_support(
124124 return False
125125 return True
126126
127+ def _check_transposed_conv_u55 (self , node : fx .Node ) -> bool :
128+ """Implement the condition checks specified in
129+ https://gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u-vela/-/blob/main/SUPPORTED_OPS.md?ref_type=heads#ethos-u55-and-ethos-u65-tosa-transpose_conv2d-constraints
130+ for the TransposeConv2D for Ethos-U55.
131+ """
132+ input_fake_tensor = get_first_fake_tensor (cast (fx .Node , node .args [0 ]))
133+ if input_fake_tensor .dim () != 4 :
134+ self .reporter .report_reject (
135+ node ,
136+ f"TransposeConv2d requires 4D input, got rank { input_fake_tensor .dim ()} ." ,
137+ )
138+ return False
139+ # For TransposeConv2D, the input tensor can only be 4D, hence we don't expect 3D input tensor.
140+ # In case of a 3D input tensor, the user should first unsqueeze the tensor and then pass it
141+ # to the TransposeConv2D, otherwise PyTorch throws an error.
142+ if input_fake_tensor .dim_order () == (0 , 1 , 2 , 3 ):
143+ input_C = input_fake_tensor .shape [1 ]
144+ input_H = input_fake_tensor .shape [2 ]
145+ input_W = input_fake_tensor .shape [3 ]
146+ elif input_fake_tensor .dim_order () == (0 , 2 , 3 , 1 ):
147+ input_C = input_fake_tensor .shape [3 ]
148+ input_H = input_fake_tensor .shape [1 ]
149+ input_W = input_fake_tensor .shape [2 ]
150+ else :
151+ self .reporter .report_reject (
152+ node ,
153+ f"Unsupported dim order. Support dim orders (0,1,2,3) or (0,2,3,1) and got dim_order { input_fake_tensor .dim_order ()} " ,
154+ )
155+ return False
156+ kernel = cast (fx .Node , node .args [1 ]).meta ["val" ].shape
157+ kernel_h = kernel [2 ]
158+ kernel_w = kernel [3 ] if len (kernel ) > 3 else 1
159+ if (
160+ input_C > 65536
161+ or input_C < 1
162+ or input_H > 65536
163+ or input_H < 1
164+ or input_W > 65536
165+ or input_W < 1
166+ ):
167+ self .reporter .report_reject (
168+ node ,
169+ f"HWC must be in the range [1;65536] but got { input_C } { input_H } { input_W } " ,
170+ )
171+ return False
172+
173+ if (
174+ kernel_h * kernel_w > 4096
175+ or kernel_h * kernel_w < 1
176+ or kernel_h > 64
177+ or kernel_h < 1
178+ ):
179+ self .reporter .report_reject (
180+ node ,
181+ f"Kernel Height * Kernel Width must be in the range [1;4096] but got { kernel_h * kernel_w } " ,
182+ )
183+ return False
184+ strides = expand_around_channel (cast (list [int ], node .args [3 ]), 2 )
185+ stride = (strides [0 ], strides [1 ])
186+ ok = False
187+ if stride in ((1 , 1 ), (2 , 2 )):
188+ ok = True
189+ elif stride == (1 , 2 ):
190+ ok = input_H == 1 and kernel_h == 1
191+ elif stride == (2 , 1 ):
192+ ok = input_W == 1 and kernel_w == 1
193+ if not ok :
194+ self .reporter .report_reject (
195+ node ,
196+ f"Unsupported stride of { stride } for Ethos-U55. You can use stride of (1,1) or (2,2), stride (1,2) for IFM height kernel height of 1 and stride(2,1) for IFM width and kernel width of 1" ,
197+ )
198+ return False
199+ return True
200+
127201 def _is_node_supported_u55 (self , node : fx .Node ) -> bool :
128- """Enforce Ethos-U55-specific constraints (Vela 4.2 .0).
202+ """Enforce Ethos-U55-specific constraints (Vela 5.0 .0).
129203
130204 Check channel dimensions, kernel sizes, and stride/pad/dilation
131205 combinations permitted on U55.
@@ -139,23 +213,7 @@ def _is_node_supported_u55(self, node: fx.Node) -> bool:
139213 """
140214 transposed = cast (bool , node .args [6 ])
141215 if transposed :
142- kernel = cast (fx .Node , node .args [1 ]).meta ["val" ].shape
143- kernel_h = kernel [2 ]
144- kernel_w = kernel [3 ] if len (kernel ) > 3 else 1
145- if kernel_h != kernel_w :
146- self .reporter .report_reject (
147- node ,
148- f"Transpose convolution on U55 requires square kernels, got ({ kernel_w } , { kernel_h } )." ,
149- )
150- return False
151-
152- strides = expand_around_channel (cast (list [int ], node .args [3 ]), 2 )
153- if strides [0 ] != strides [1 ]:
154- self .reporter .report_reject (
155- node ,
156- f"Transpose convolution on U55 requires equal strides, got { strides } ." ,
157- )
158- return False
216+ return self ._check_transposed_conv_u55 (node )
159217
160218 shape_in = cast (torch .Tensor , node .all_input_nodes [0 ].meta ["val" ]).shape
161219 shape_out = node .meta ["val" ].shape
0 commit comments