|
|
|
@ -42,6 +42,11 @@ class GradWrap(nn.Cell):
|
|
|
|
|
return C.grad_all(self.network)(x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def compile(net, x, y, b):
|
|
|
|
|
net.set_auto_parallel()
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_matmul_sub():
|
|
|
|
|
class Net(nn.Cell):
|
|
|
|
|
def __init__(self, strategy1, strategy2):
|
|
|
|
@ -64,7 +69,7 @@ def test_matmul_sub():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 64]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([64, 64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_matmul_add():
|
|
|
|
@ -88,7 +93,7 @@ def test_matmul_add():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 64]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([64, 64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_matmul_mul():
|
|
|
|
@ -112,7 +117,7 @@ def test_matmul_mul():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 64]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([64, 64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_matmul_div():
|
|
|
|
@ -136,7 +141,7 @@ def test_matmul_div():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 64]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([64, 64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
def test_matmul_greater():
|
|
|
|
|
class Net(nn.Cell):
|
|
|
|
@ -159,7 +164,7 @@ def test_matmul_greater():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 64]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([64, 64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
def test_matmul_add_broadcast():
|
|
|
|
|
class Net(nn.Cell):
|
|
|
|
@ -182,7 +187,7 @@ def test_matmul_add_broadcast():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 64]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_matmul_add_broadcast2():
|
|
|
|
@ -206,7 +211,7 @@ def test_matmul_add_broadcast2():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 1]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([1, 64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_matmul_sub_broadcast():
|
|
|
|
@ -230,7 +235,7 @@ def test_matmul_sub_broadcast():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 64]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_matmul_sub_broadcast2():
|
|
|
|
@ -254,7 +259,7 @@ def test_matmul_sub_broadcast2():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 1]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([1, 64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_matmul_mul_broadcast():
|
|
|
|
@ -278,7 +283,7 @@ def test_matmul_mul_broadcast():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 64]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_matmul_mul_broadcast2():
|
|
|
|
@ -302,7 +307,7 @@ def test_matmul_mul_broadcast2():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 1]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([1, 64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_matmul_div_broadcast():
|
|
|
|
@ -326,7 +331,7 @@ def test_matmul_div_broadcast():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 64]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_matmul_div_broadcast2():
|
|
|
|
@ -350,7 +355,7 @@ def test_matmul_div_broadcast2():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 1]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([1, 64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
def test_matmul_greater_broadcast():
|
|
|
|
|
class Net(nn.Cell):
|
|
|
|
@ -373,7 +378,7 @@ def test_matmul_greater_broadcast():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 64]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_matmul_greater_broadcast2():
|
|
|
|
@ -397,7 +402,7 @@ def test_matmul_greater_broadcast2():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 1]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([1, 64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
def test_matmul_floordiv():
|
|
|
|
|
class Net(nn.Cell):
|
|
|
|
@ -420,7 +425,7 @@ def test_matmul_floordiv():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 64]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([64, 64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_matmul_floordiv_broadcast():
|
|
|
|
@ -444,7 +449,7 @@ def test_matmul_floordiv_broadcast():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 64]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_matmul_floordiv_broadcast2():
|
|
|
|
@ -468,7 +473,7 @@ def test_matmul_floordiv_broadcast2():
|
|
|
|
|
x = Tensor(np.ones([64, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([32, 1]), dtype=ms.float32)
|
|
|
|
|
b = Tensor(np.ones([1, 64]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, b)
|
|
|
|
|
compile(net, x, y, b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_assign_sub():
|
|
|
|
@ -495,4 +500,4 @@ def test_assign_sub():
|
|
|
|
|
x = Tensor(np.ones([128, 32]), dtype=ms.float32)
|
|
|
|
|
y = Tensor(np.ones([128, 32]), dtype=ms.float32)
|
|
|
|
|
z = Tensor(np.ones([128, 32]), dtype=ms.float32)
|
|
|
|
|
_executor.compile(net, x, y, z)
|
|
|
|
|
compile(net, x, y, z)
|
|
|
|
|