@@ -138,6 +138,7 @@ class EthosU55NotSupported(OperatorSupportBase):
138138 exir_ops .edge .aten .gt .Tensor ,
139139 exir_ops .edge .aten .gt .Scalar ,
140140 exir_ops .edge .aten .le .Tensor ,
141+ exir_ops .edge .aten .le .Scalar ,
141142 exir_ops .edge .aten .lt .Tensor ,
142143 exir_ops .edge .aten .lt .Scalar ,
143144 exir_ops .edge .aten .ne .Tensor ,
@@ -174,6 +175,69 @@ def is_node_supported(
174175shape_t = list [int ]
175176
176177
178+ class EthosU55ViewCheck (OperatorSupportBase ):
179+
180+ def __init__ (self , reporter : WhyNoPartitionReporter ):
181+ super ().__init__ ()
182+ self .reporter = reporter
183+
184+ def axes_product (self , nhwc_shape : shape_t ) -> int :
185+ product = 1
186+ for axes in nhwc_shape :
187+ product *= axes
188+ return product
189+
190+ # TODO: Extend this check to comply with u55 restrictions
191+ def is_node_supported (
192+ self , submodules : typing .Mapping [str , torch .nn .Module ], node : fx .Node
193+ ) -> bool :
194+ """
195+ Check whether a given view node is supported on U55.
196+
197+ Currently only checks dtypes and product of axes.
198+
199+ It is not the view operator itself that is not supported on U55. In order for the
200+ view operator to be compatible with the channels-last format of TosaBackend,
201+ transposes may need to be inserted before and after the view op. If that happens
202+ and that transpose operator does not adhere to the limitations then it will
203+ result in the following error:
204+
205+ CPU performance estimation for "Transpose" not implemented.
206+ ...
207+ CPU operations are not supported for GraphAPI input
208+
209+ Args:
210+ node: The FX node representing the view_copy operator.
211+
212+ Returns:
213+ False if the operator is not support and True if it is supported.
214+ """
215+ if not node .target == exir_ops .edge .aten .view_copy .default :
216+ return True
217+
218+ shape = list (get_first_fake_tensor (node ).shape )
219+ dtype = _try_determine_dtype (node )
220+ permutation = list (typing .cast (list [int ], node .args [1 ]))
221+
222+ rank = len (shape )
223+ if rank > 4 :
224+ if dtype == torch .int32 :
225+ self .reporter .report_reject (
226+ node , f"No support for { permutation = } in int32."
227+ )
228+ return False
229+
230+ if dtype in (torch .int8 , torch .int16 ):
231+ if self .axes_product (shape ) > 65536 :
232+ self .reporter .report_reject (
233+ node ,
234+ f"No support for { shape = } , { dtype = } . Product of axes must be <65536" ,
235+ )
236+ return False
237+
238+ return True
239+
240+
177241class EthosU55TransposeCheck (OperatorSupportBase ):
178242
179243 def __init__ (self , reporter : WhyNoPartitionReporter ):
0 commit comments