@@ -790,7 +790,7 @@ def test_static_check(self):
790790 with paddle .static .program_guard (paddle .static .Program ()):
791791 x = paddle .static .data ('X' , x_np .shape , 'float32' )
792792 out1 = func (input = x , dim = None , _stacklevel = 3 )
793- out2 = func (x )
793+ out2 = func (x , None , 3 )
794794 exe = paddle .static .Executor (self .place )
795795 res = exe .run (feed = {'X' : x_np }, fetch_list = [out1 , out2 ])
796796 for rr in res :
@@ -840,7 +840,7 @@ def test_dygraph_check(self):
840840 x = paddle .to_tensor (x_np )
841841 out1 = func (input = x , dim = None , _stacklevel = 3 )
842842 x = paddle .to_tensor (x_np )
843- out2 = func (x )
843+ out2 = func (x , None , 3 )
844844 for r in [out1 , out2 ]:
845845 np .testing .assert_allclose (out_ref , r .numpy (), rtol = 1e-05 )
846846
@@ -940,6 +940,19 @@ def test_dygraph_check(self):
940940
941941 paddle .enable_static ()
942942
943+ def test_forbid_keywords (self ):
944+ with (
945+ static_guard (),
946+ paddle .static .program_guard (paddle .static .Program ()),
947+ ):
948+ x = paddle .static .data ('X' , [2 , 3 ], 'float32' )
949+ self .assertRaises (TypeError , compat .softmax , x = x , axis = - 1 )
950+ self .assertRaises (TypeError , compat .softmax , x = x , dim = - 1 )
951+ self .assertRaises (TypeError , compat .softmax , input = x , axis = - 1 )
952+
953+ if core .is_compiled_with_cuda ():
954+ compat .softmax (input = x , dim = - 1 )
955+
943956
944957if __name__ == "__main__" :
945958 unittest .main ()
0 commit comments