@@ -110,3 +110,57 @@ def test_int64_tosa_INT(test_data: Tuple):
110110 .to_executorch ()
111111 .run_method_and_compare_outputs (inputs )
112112 )
113+
114+
115+ class Int64Add (torch .nn .Module ):
116+ def forward (self , x : torch .Tensor , y : torch .Tensor ):
117+ return x + y
118+
119+
120+ class Int64Sub (torch .nn .Module ):
121+ def forward (self , x : torch .Tensor , y : torch .Tensor ):
122+ return x - y
123+
124+
125+ class Int64Mul (torch .nn .Module ):
126+ def forward (self , x : torch .Tensor , y : torch .Tensor ):
127+ return x * y
128+
129+
130+ class Int64GreaterScalar (torch .nn .Module ):
131+ """Compare against a scalar that a double cannot represent exactly."""
132+
133+ def forward (self , x : torch .Tensor , y : torch .Tensor ):
134+ return x > 9007199254740993
135+
136+
137+ # Operands straddle the int32 range, so a narrowed lowering cannot reproduce
138+ # the reference result.
139+ _WIDE = torch .tensor ([2 ** 40 , - (2 ** 38 ), 2 ** 31 , - 1 ], dtype = torch .int64 )
140+ _WIDE_2 = torch .tensor ([2 ** 39 , 2 ** 37 , 1 , - (2 ** 40 )], dtype = torch .int64 )
141+ _NEAR_2_53 = torch .tensor ([2 ** 53 , 2 ** 53 + 1 , 2 ** 53 + 2 , - (2 ** 53 )], dtype = torch .int64 )
142+
143+ int64_extension_suite = {
144+ "add" : (Int64Add (), (_WIDE , _WIDE_2 ), "aten_add_tensor" ),
145+ "sub" : (Int64Sub (), (_WIDE , _WIDE_2 ), "aten_sub_tensor" ),
146+ "mul" : (Int64Mul (), (_WIDE , _WIDE_2 ), "aten_mul_tensor" ),
147+ "gt_scalar" : (Int64GreaterScalar (), (_NEAR_2_53 , _WIDE ), "aten_gt_scalar" ),
148+ }
149+
150+
151+ @common .parametrize ("test_data" , int64_extension_suite )
152+ def test_int64_extension_tosa_INT (test_data : Tuple ):
153+ """Int64 operands are delegated when the spec declares the extension."""
154+ model , inputs , aten_op = test_data
155+ (
156+ ArmTester (
157+ model ,
158+ inputs ,
159+ common .get_tosa_compile_spec ("TOSA-1.1+INT+int64" ),
160+ )
161+ .export ()
162+ .to_edge_transform_and_lower ()
163+ .check_count ({"torch.ops.higher_order.executorch_call_delegate" : 1 })
164+ .check_not ([aten_op ])
165+ .to_executorch ()
166+ )
0 commit comments