@@ -499,63 +499,63 @@ def test_matmul(usm_type_x, usm_type_y, shape_pair):
499499 assert z .usm_type == du .get_coerced_usm_type ([usm_type_x , usm_type_y ])
500500
501501
502- # @pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
503- # @pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
504- # @pytest.mark.parametrize(
505- # "shape_pair",
506- # [
507- # ((4,), (4,)), # call_flag: dot
508- # ((3, 1), (3, 1)),
509- # ((2, 0), (2, 0)), # zero-size inputs, 1D output
510- # ((3, 0, 4), (3, 0, 4)), # zero-size output
511- # ((3, 4), (3, 4)), # call_flag: vecdot
512- # ],
513- # )
514- # def test_vecdot(usm_type_x, usm_type_y, shape_pair):
515- # shape1, shape2 = shape_pair
516- # x = numpy.arange(numpy.prod(shape1)).reshape(shape1)
517- # y = numpy.arange(numpy.prod(shape2)).reshape(shape2)
502+ @pytest .mark .parametrize ("usm_type_x" , list_of_usm_types , ids = list_of_usm_types )
503+ @pytest .mark .parametrize ("usm_type_y" , list_of_usm_types , ids = list_of_usm_types )
504+ @pytest .mark .parametrize (
505+ "shape_pair" ,
506+ [
507+ ((4 ,), (4 ,)), # call_flag: dot
508+ ((3 , 1 ), (3 , 1 )),
509+ ((2 , 0 ), (2 , 0 )), # zero-size inputs, 1D output
510+ ((3 , 0 , 4 ), (3 , 0 , 4 )), # zero-size output
511+ ((3 , 4 ), (3 , 4 )), # call_flag: vecdot
512+ ],
513+ )
514+ def test_vecdot (usm_type_x , usm_type_y , shape_pair ):
515+ shape1 , shape2 = shape_pair
516+ x = numpy .arange (numpy .prod (shape1 )).reshape (shape1 )
517+ y = numpy .arange (numpy .prod (shape2 )).reshape (shape2 )
518518
519- # x = dp.array(x, usm_type=usm_type_x)
520- # y = dp.array(y, usm_type=usm_type_y)
521- # z = dp.vecdot(x, y)
519+ x = dp .array (x , usm_type = usm_type_x )
520+ y = dp .array (y , usm_type = usm_type_y )
521+ z = dp .vecdot (x , y )
522522
523- # assert x.usm_type == usm_type_x
524- # assert y.usm_type == usm_type_y
525- # assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y])
523+ assert x .usm_type == usm_type_x
524+ assert y .usm_type == usm_type_y
525+ assert z .usm_type == du .get_coerced_usm_type ([usm_type_x , usm_type_y ])
526526
527527
528- # @pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types)
529- # @pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types)
530- # def test_meshgrid(usm_type_x, usm_type_y):
531- # x = dp.arange(100, usm_type=usm_type_x)
532- # y = dp.arange(100, usm_type=usm_type_y)
533- # z = dp.meshgrid(x, y)
534- # assert z[0].usm_type == usm_type_x
535- # assert z[1].usm_type == usm_type_y
528+ @pytest .mark .parametrize ("usm_type_x" , list_of_usm_types , ids = list_of_usm_types )
529+ @pytest .mark .parametrize ("usm_type_y" , list_of_usm_types , ids = list_of_usm_types )
530+ def test_meshgrid (usm_type_x , usm_type_y ):
531+ x = dp .arange (100 , usm_type = usm_type_x )
532+ y = dp .arange (100 , usm_type = usm_type_y )
533+ z = dp .meshgrid (x , y )
534+ assert z [0 ].usm_type == usm_type_x
535+ assert z [1 ].usm_type == usm_type_y
536536
537537
538- # @pytest.mark.parametrize("usm_type", list_of_usm_types, ids=list_of_usm_types)
539- # @pytest.mark.parametrize(
540- # "ord", [None, -dp.inf, -2, -1, 1, 2, 3, dp.inf, "fro", "nuc"]
541- # )
542- # @pytest.mark.parametrize(
543- # "axis",
544- # [-1, 0, 1, (0, 1), (-2, -1), None],
545- # ids=["-1", "0", "1", "(0, 1)", "(-2, -1)", "None"],
546- # )
547- # def test_norm(usm_type, ord, axis):
548- # ia = dp.arange(120, usm_type=usm_type).reshape(2, 3, 4, 5)
549- # if (axis in [-1, 0, 1] and ord in ["nuc", "fro"]) or (
550- # isinstance(axis, tuple) and ord == 3
551- # ):
552- # pytest.skip("Invalid norm order for vectors.")
553- # elif axis is None and ord is not None:
554- # pytest.skip("Improper number of dimensions to norm")
555- # else:
556- # result = dp.linalg.norm(ia, ord=ord, axis=axis)
557- # assert ia.usm_type == usm_type
558- # assert result.usm_type == usm_type
538+ @pytest .mark .parametrize ("usm_type" , list_of_usm_types , ids = list_of_usm_types )
539+ @pytest .mark .parametrize (
540+ "ord" , [None , - dp .inf , - 2 , - 1 , 1 , 2 , 3 , dp .inf , "fro" , "nuc" ]
541+ )
542+ @pytest .mark .parametrize (
543+ "axis" ,
544+ [- 1 , 0 , 1 , (0 , 1 ), (- 2 , - 1 ), None ],
545+ ids = ["-1" , "0" , "1" , "(0, 1)" , "(-2, -1)" , "None" ],
546+ )
547+ def test_norm (usm_type , ord , axis ):
548+ ia = dp .arange (120 , usm_type = usm_type ).reshape (2 , 3 , 4 , 5 )
549+ if (axis in [- 1 , 0 , 1 ] and ord in ["nuc" , "fro" ]) or (
550+ isinstance (axis , tuple ) and ord == 3
551+ ):
552+ pytest .skip ("Invalid norm order for vectors." )
553+ elif axis is None and ord is not None :
554+ pytest .skip ("Improper number of dimensions to norm" )
555+ else :
556+ result = dp .linalg .norm (ia , ord = ord , axis = axis )
557+ assert ia .usm_type == usm_type
558+ assert result .usm_type == usm_type
559559
560560
561561# @pytest.mark.parametrize(
0 commit comments