@@ -170,6 +170,35 @@ defmodule Emily.CompilerEquivalenceTest do
170170 assert_equiv ( & Nx . add / 2 , [ a , b ] )
171171 end
172172
173+ # Binary arithmetic peers added with the Expr op-coverage sweep (#188).
174+ # atan2 is a direct @arith_binary mapping (atan2: :arctan2); quotient
175+ # routes through floor_divide the same way Emily.Backend.quotient/3 does.
176+ test "atan2 matches the evaluator across the four quadrants" do
177+ # Quadrant-covering pairs (y, x): include the axes so the result
178+ # lands on the ±0, ±pi, ±pi/2 boundaries the eager Backend produces.
179+ y = et ( [ 1.0 , 1.0 , - 1.0 , - 1.0 , 0.0 , 0.0 , 2.0 , - 2.0 ] )
180+ x = et ( [ 1.0 , - 1.0 , - 1.0 , 1.0 , 1.0 , - 1.0 , 0.0 , 0.0 ] )
181+ assert_equiv ( & Nx . atan2 / 2 , [ y , x ] )
182+ end
183+
184+ test "quotient matches the evaluator for signed and unsigned integer dtypes" do
185+ # Backend casts both operands to out.type then calls floor_divide.
186+ # Quotient is integer-only in Nx, so we exercise the s32/s64/u8/u32
187+ # paths; the native lane matches the evaluator bit-for-bit because
188+ # both end up at the same mx::floor_divide kernel.
189+ for type <- [ :s32 , :s64 ] do
190+ a = et ( [ 7 , - 7 , 10 , - 10 , 4 , - 4 ] , type: type )
191+ b = et ( [ 2 , 2 , 3 , 3 , 5 , 5 ] , type: type )
192+ assert_equiv ( & Nx . quotient / 2 , [ a , b ] )
193+ end
194+
195+ for type <- [ :u8 , :u32 ] do
196+ a = et ( [ 7 , 10 , 4 , 255 ] , type: type )
197+ b = et ( [ 2 , 3 , 5 , 2 ] , type: type )
198+ assert_equiv ( & Nx . quotient / 2 , [ a , b ] )
199+ end
200+ end
201+
173202 test "scalar constant operand (materialized capture)" do
174203 x = et ( [ 1.0 , 2.0 , 3.0 ] )
175204 assert_equiv ( fn t -> Nx . add ( t , 1.5 ) end , [ x ] )
@@ -192,6 +221,22 @@ defmodule Emily.CompilerEquivalenceTest do
192221 assert out . type == { :u , 8 }
193222 end
194223 end
224+
225+ # logical_xor: MLX has no primitive, so both paths run
226+ # `(a != 0) != (b != 0)` — Emily.Backend.logical_xor/3 eagerly, the
227+ # IR via a dedicated composite clause that emits the same three
228+ # not_equal ops. Inputs span the four truth-table corners across
229+ # float and integer dtypes; the trailing coerce produces {:u, 8}.
230+ test "logical_xor matches across float and integer dtypes" do
231+ a = et ( [ 1.0 , 0.0 , 1.0 , 0.0 ] )
232+ b = et ( [ 1.0 , 1.0 , 0.0 , 0.0 ] )
233+ out = assert_equiv ( & Nx . logical_xor / 2 , [ a , b ] )
234+ assert out . type == { :u , 8 }
235+
236+ ai = et ( [ 1 , 0 , 1 , 0 ] , type: :s32 )
237+ bi = et ( [ 1 , 1 , 0 , 0 ] , type: :s32 )
238+ assert_equiv ( & Nx . logical_xor / 2 , [ ai , bi ] )
239+ end
195240 end
196241
197242 describe "cast / shape" do
0 commit comments