@@ -1864,6 +1864,40 @@ def test_accuracy_sub_scalar_scalar(dtype):
18641864 gems_assert_close (res_out , ref_out , dtype )
18651865
18661866
1867+ @pytest .mark .rsub
1868+ @pytest .mark .parametrize ("shape" , POINTWISE_SHAPES )
1869+ @pytest .mark .parametrize ("alpha" , SCALARS )
1870+ @pytest .mark .parametrize ("dtype" , FLOAT_DTYPES )
1871+ def test_accuracy_rsub (shape , alpha , dtype ):
1872+ inp1 = torch .randn (shape , dtype = dtype , device = flag_gems .device )
1873+ inp2 = torch .randn (shape , dtype = dtype , device = flag_gems .device )
1874+ ref_inp1 = to_reference (inp1 , True )
1875+ ref_inp2 = to_reference (inp2 , True )
1876+
1877+ ref_out = torch .rsub (ref_inp1 , ref_inp2 , alpha = alpha )
1878+ with flag_gems .use_gems ():
1879+ res_out = torch .rsub (inp1 , inp2 , alpha = alpha )
1880+
1881+ gems_assert_close (res_out , ref_out , dtype )
1882+
1883+
1884+ @pytest .mark .rsub
1885+ @pytest .mark .parametrize ("shape" , POINTWISE_SHAPES )
1886+ @pytest .mark .parametrize ("scalar" , SCALARS )
1887+ @pytest .mark .parametrize ("alpha" , SCALARS )
1888+ @pytest .mark .parametrize ("dtype" , FLOAT_DTYPES )
1889+ def test_accuracy_rsub_tensor_scalar (shape , scalar , alpha , dtype ):
1890+ inp1 = torch .randn (shape , dtype = dtype , device = flag_gems .device )
1891+ inp2 = scalar
1892+ ref_inp1 = to_reference (inp1 , True )
1893+
1894+ ref_out = torch .rsub (ref_inp1 , inp2 , alpha = alpha )
1895+ with flag_gems .use_gems ():
1896+ res_out = torch .rsub (inp1 , inp2 , alpha = alpha )
1897+
1898+ gems_assert_close (res_out , ref_out , dtype )
1899+
1900+
18671901@pytest .mark .where
18681902@pytest .mark .parametrize ("shape" , POINTWISE_SHAPES )
18691903@pytest .mark .parametrize ("dtype" , FLOAT_DTYPES )
0 commit comments