3838from executorch .backends .arm ._passes .prepare_gather_indices_pass import (
3939 is_safe_int32_to_int64_gather_boundary ,
4040)
41+ from executorch .backends .arm .operator_support .dtype_support import (
42+ is_indexing_dtype_supported ,
43+ )
4144from executorch .backends .arm .operator_support .tosa_supported_operators import (
4245 register_tosa_support_check ,
4346 SupportedTOSAOperatorCheck ,
@@ -52,9 +55,10 @@ class GatherSupported(SupportedTOSAOperatorCheck):
5255
5356 targets = [exir_ops .edge .aten .gather .default ]
5457
55- def is_node_tosa_supported ( # noqa: C901
58+ def is_node_tosa_supported (
5659 self , node : fx .Node , tosa_spec : TosaSpecification
5760 ) -> bool : # type: ignore[override, misc]
61+ """Return True if the gather node passes the TOSA support checks."""
5862 if len (node .args ) != 3 :
5963 self .reporter .report_reject (
6064 node ,
@@ -111,62 +115,4 @@ def is_node_tosa_supported( # noqa: C901
111115 )
112116 return False
113117
114- # ---- values dtype ----
115- values_dtype = x_val .dtype
116- # ints (and bool via casts) require INT profile
117- if values_dtype in (torch .bool , torch .int8 , torch .int16 , torch .int32 ):
118- if not tosa_spec .support_integer ():
119- self .reporter .report_reject (
120- node ,
121- f"{ node .target } : dtype { values_dtype } requires INT profile." ,
122- )
123- return False
124- # fp16/fp32/bf16/fp8: either FP profile, or INT profile (via quantization)
125- elif values_dtype in (
126- torch .float16 ,
127- torch .float32 ,
128- torch .bfloat16 ,
129- torch .float8_e4m3fn ,
130- torch .float8_e5m2 ,
131- ):
132- if values_dtype == torch .bfloat16 and not tosa_spec .support_extension (
133- "bf16"
134- ):
135- self .reporter .report_reject (
136- node ,
137- f"{ node .target } : dtype { values_dtype } requires bf16 extension." ,
138- )
139- return False
140- if values_dtype == torch .float8_e4m3fn and not tosa_spec .support_extension (
141- "fp8e4m3"
142- ):
143- self .reporter .report_reject (
144- node ,
145- f"{ node .target } : dtype { values_dtype } requires fp8e4m3 extension." ,
146- )
147- return False
148- if values_dtype == torch .float8_e5m2 and not tosa_spec .support_extension (
149- "fp8e5m2"
150- ):
151- self .reporter .report_reject (
152- node ,
153- f"{ node .target } : dtype { values_dtype } requires fp8e5m2 extension." ,
154- )
155- return False
156- if not (tosa_spec .support_float () or tosa_spec .support_integer ()):
157- self .reporter .report_reject (
158- node ,
159- f"{ node .target } : dtype { values_dtype } requires FP profile or "
160- "INT profile (with quantization)." ,
161- )
162- return False
163- else :
164- self .reporter .report_reject (
165- node ,
166- f"{ node .target } : unsupported values dtype { values_dtype } ; "
167- "expected bool/int8/int16/int32/float16/bfloat16/float32/"
168- "float8_e4m3fn/float8_e5m2." ,
169- )
170- return False
171-
172- return True
118+ return is_indexing_dtype_supported (node , x_val .dtype , tosa_spec , self .reporter )
0 commit comments