!1044 clean pylint warning in test dir

Merge pull request !1044 from jinyaohui/clean_pylint_test
pull/1044/MERGE
mindspore-ci-bot 5 years ago committed by Gitee
commit 2bc3fcb1c1

@ -20,8 +20,11 @@ import numpy as np
import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
context.set_context(mode=context.GRAPH_MODE, device_target="Ascend")
context.set_context(enable_task_sink=True)
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -30,9 +33,11 @@ class Net(nn.Cell):
def construct(self, x, y):
return self.add(x, y)
x = np.ones([1, 3, 3, 4]).astype(np.float32)
y = np.ones([1, 3, 3, 4]).astype(np.float32)
def test_net():
add = Net()
output = add(Tensor(x), Tensor(y))

@ -20,7 +20,10 @@ import numpy as np
import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
context.set_context(mode=context.GRAPH_MODE, device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -29,6 +32,7 @@ class Net(nn.Cell):
def construct(self, x, y):
return self.add((x, y))
def test_net():
x = np.random.randn(1, 3, 3, 4).astype(np.float32)
y = np.random.randn(1, 3, 3, 4).astype(np.float32)

@ -18,7 +18,10 @@ import mindspore.nn as nn
from mindspore.common.api import ms_function
import numpy as np
import mindspore.context as context
context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -35,6 +38,7 @@ def test_net_bool():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.expand_dims(x, -1)))
def test_net_int8():
x = np.random.randn(1, 16, 1, 1).astype(np.int8)
net = Net()
@ -42,6 +46,7 @@ def test_net_int8():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.expand_dims(x, -1)))
def test_net_uint8():
x = np.random.randn(1, 16, 1, 1).astype(np.uint8)
net = Net()
@ -49,6 +54,7 @@ def test_net_uint8():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.expand_dims(x, -1)))
def test_net_int16():
x = np.random.randn(1, 16, 1, 1).astype(np.int16)
net = Net()
@ -56,6 +62,7 @@ def test_net_int16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.expand_dims(x, -1)))
def test_net_uint16():
x = np.random.randn(1, 16, 1, 1).astype(np.uint16)
net = Net()
@ -63,6 +70,7 @@ def test_net_uint16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.expand_dims(x, -1)))
def test_net_int32():
x = np.random.randn(1, 16, 1, 1).astype(np.int32)
net = Net()
@ -70,6 +78,7 @@ def test_net_int32():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.expand_dims(x, -1)))
def test_net_uint32():
x = np.random.randn(1, 16, 1, 1).astype(np.uint32)
net = Net()
@ -77,6 +86,7 @@ def test_net_uint32():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.expand_dims(x, -1)))
def test_net_int64():
x = np.random.randn(1, 16, 1, 1).astype(np.int64)
net = Net()
@ -84,6 +94,7 @@ def test_net_int64():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.expand_dims(x, -1)))
def test_net_uint64():
x = np.random.randn(1, 16, 1, 1).astype(np.uint64)
net = Net()
@ -91,6 +102,7 @@ def test_net_uint64():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.expand_dims(x, -1)))
def test_net_float16():
x = np.random.randn(1, 16, 1, 1).astype(np.float16)
net = Net()
@ -98,6 +110,7 @@ def test_net_float16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.expand_dims(x, -1)))
def test_net_float32():
x = np.random.randn(1, 16, 1, 1).astype(np.float32)
net = Net()
@ -105,10 +118,10 @@ def test_net_float32():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.expand_dims(x, -1)))
def test_net_float64():
x = np.random.randn(1, 16, 1, 1).astype(np.float64)
net = Net()
output = net(Tensor(x), -1)
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.expand_dims(x, -1)))

@ -17,7 +17,10 @@ from mindspore.ops import operations as P
import mindspore.nn as nn
import numpy as np
import mindspore.context as context
context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -34,6 +37,7 @@ def test_net_int8():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.flatten()))
def test_net_uint8():
x = np.random.randn(1, 16, 1, 1).astype(np.uint8)
net = Net()
@ -41,6 +45,7 @@ def test_net_uint8():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.flatten()))
def test_net_int16():
x = np.random.randn(1, 16, 1, 1).astype(np.int16)
net = Net()
@ -48,6 +53,7 @@ def test_net_int16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.flatten()))
def test_net_uint16():
x = np.random.randn(1, 16, 1, 1).astype(np.uint16)
net = Net()
@ -55,6 +61,7 @@ def test_net_uint16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.flatten()))
def test_net_int32():
x = np.random.randn(1, 16, 1, 1).astype(np.int32)
net = Net()
@ -62,6 +69,7 @@ def test_net_int32():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.flatten()))
def test_net_uint32():
x = np.random.randn(1, 16, 1, 1).astype(np.uint32)
net = Net()
@ -69,6 +77,7 @@ def test_net_uint32():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.flatten()))
def test_net_int64():
x = np.random.randn(1, 16, 1, 1).astype(np.int64)
net = Net()
@ -76,6 +85,7 @@ def test_net_int64():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.flatten()))
def test_net_uint64():
x = np.random.randn(1, 16, 1, 1).astype(np.uint64)
net = Net()
@ -83,6 +93,7 @@ def test_net_uint64():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.flatten()))
def test_net_float16():
x = np.random.randn(1, 16, 1, 1).astype(np.float16)
net = Net()
@ -90,10 +101,10 @@ def test_net_float16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.flatten()))
def test_net_float32():
x = np.random.randn(1, 16, 1, 1).astype(np.float32)
net = Net()
output = net(Tensor(x))
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.flatten()))

@ -18,7 +18,10 @@ import mindspore.nn as nn
from mindspore.common.api import ms_function
import numpy as np
import mindspore.context as context
context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -35,6 +38,7 @@ def test_net_bool():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.isfinite(x)))
def test_net_int8():
x = np.random.randn(1, 16, 1, 1).astype(np.int8)
net = Net()
@ -42,6 +46,7 @@ def test_net_int8():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.isfinite(x)))
def test_net_uint8():
x = np.random.randn(1, 16, 1, 1).astype(np.uint8)
net = Net()
@ -49,6 +54,7 @@ def test_net_uint8():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.isfinite(x)))
def test_net_int16():
x = np.random.randn(1, 16, 1, 1).astype(np.int16)
net = Net()
@ -56,6 +62,7 @@ def test_net_int16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.isfinite(x)))
def test_net_uint16():
x = np.random.randn(1, 16, 1, 1).astype(np.uint16)
net = Net()
@ -63,6 +70,7 @@ def test_net_uint16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.isfinite(x)))
def test_net_int32():
x = np.random.randn(1, 16, 1, 1).astype(np.int32)
net = Net()
@ -70,6 +78,7 @@ def test_net_int32():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.isfinite(x)))
def test_net_uint32():
x = np.random.randn(1, 16, 1, 1).astype(np.uint32)
net = Net()
@ -77,6 +86,7 @@ def test_net_uint32():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.isfinite(x)))
def test_net_int64():
x = np.random.randn(1, 16, 1, 1).astype(np.int64)
net = Net()
@ -84,6 +94,7 @@ def test_net_int64():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.isfinite(x)))
def test_net_uint64():
x = np.random.randn(1, 16, 1, 1).astype(np.uint64)
net = Net()
@ -91,6 +102,7 @@ def test_net_uint64():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.isfinite(x)))
def test_net_float16():
x = np.random.randn(1, 16, 1, 1).astype(np.float16)
net = Net()
@ -98,6 +110,7 @@ def test_net_float16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.isfinite(x)))
def test_net_float32():
x = np.random.randn(1, 16, 1, 1).astype(np.float32)
net = Net()
@ -105,10 +118,10 @@ def test_net_float32():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.isfinite(x)))
def test_net_float64():
x = np.random.randn(1, 16, 1, 1).astype(np.float64)
net = Net()
output = net(Tensor(x))
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.isfinite(x)))

@ -18,7 +18,10 @@ import mindspore.nn as nn
from mindspore.common.api import ms_function
import numpy as np
import mindspore.context as context
context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -35,6 +38,7 @@ def test_net_bool():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.reshape(x, (4, 4))))
def test_net_int8():
x = np.random.randn(1, 16, 1, 1).astype(np.int8)
net = Net()
@ -42,6 +46,7 @@ def test_net_int8():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.reshape(x, (4, 4))))
def test_net_uint8():
x = np.random.randn(1, 16, 1, 1).astype(np.uint8)
net = Net()
@ -49,6 +54,7 @@ def test_net_uint8():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.reshape(x, (4, 4))))
def test_net_int16():
x = np.random.randn(1, 16, 1, 1).astype(np.int16)
net = Net()
@ -56,6 +62,7 @@ def test_net_int16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.reshape(x, (4, 4))))
def test_net_uint16():
x = np.random.randn(1, 16, 1, 1).astype(np.uint16)
net = Net()
@ -63,6 +70,7 @@ def test_net_uint16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.reshape(x, (4, 4))))
def test_net_int32():
x = np.random.randn(1, 16, 1, 1).astype(np.int32)
net = Net()
@ -70,6 +78,7 @@ def test_net_int32():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.reshape(x, (4, 4))))
def test_net_uint32():
x = np.random.randn(1, 16, 1, 1).astype(np.uint32)
net = Net()
@ -77,6 +86,7 @@ def test_net_uint32():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.reshape(x, (4, 4))))
def test_net_int64():
x = np.random.randn(1, 16, 1, 1).astype(np.int64)
net = Net()
@ -84,6 +94,7 @@ def test_net_int64():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.reshape(x, (4, 4))))
def test_net_uint64():
x = np.random.randn(1, 16, 1, 1).astype(np.uint64)
net = Net()
@ -91,6 +102,7 @@ def test_net_uint64():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.reshape(x, (4, 4))))
def test_net_float16():
x = np.random.randn(1, 16, 1, 1).astype(np.float16)
net = Net()
@ -98,6 +110,7 @@ def test_net_float16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.reshape(x, (4, 4))))
def test_net_float32():
x = np.random.randn(1, 16, 1, 1).astype(np.float32)
net = Net()
@ -105,10 +118,10 @@ def test_net_float32():
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.reshape(x, (4, 4))))
def test_net_float64():
x = np.random.randn(1, 16, 1, 1).astype(np.float64)
net = Net()
output = net(Tensor(x))
print(output.asnumpy())
assert (np.all(output.asnumpy() == np.reshape(x, (4, 4))))

@ -17,7 +17,10 @@ from mindspore.ops import operations as P
import mindspore.nn as nn
import numpy as np
import mindspore.context as context
context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -34,6 +37,7 @@ def test_net_bool():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.squeeze()))
def test_net_int8():
x = np.random.randn(1, 16, 1, 1).astype(np.int8)
net = Net()
@ -41,6 +45,7 @@ def test_net_int8():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.squeeze()))
def test_net_uint8():
x = np.random.randn(1, 16, 1, 1).astype(np.uint8)
net = Net()
@ -48,6 +53,7 @@ def test_net_uint8():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.squeeze()))
def test_net_int16():
x = np.random.randn(1, 16, 1, 1).astype(np.int16)
net = Net()
@ -55,6 +61,7 @@ def test_net_int16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.squeeze()))
def test_net_uint16():
x = np.random.randn(1, 16, 1, 1).astype(np.uint16)
net = Net()
@ -62,6 +69,7 @@ def test_net_uint16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.squeeze()))
def test_net_int32():
x = np.random.randn(1, 16, 1, 1).astype(np.int32)
net = Net()
@ -69,6 +77,7 @@ def test_net_int32():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.squeeze()))
def test_net_uint32():
x = np.random.randn(1, 16, 1, 1).astype(np.uint32)
net = Net()
@ -76,6 +85,7 @@ def test_net_uint32():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.squeeze()))
def test_net_int64():
x = np.random.randn(1, 16, 1, 1).astype(np.int64)
net = Net()
@ -83,6 +93,7 @@ def test_net_int64():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.squeeze()))
def test_net_uint64():
x = np.random.randn(1, 16, 1, 1).astype(np.uint64)
net = Net()
@ -90,6 +101,7 @@ def test_net_uint64():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.squeeze()))
def test_net_float16():
x = np.random.randn(1, 16, 1, 1).astype(np.float16)
net = Net()
@ -97,6 +109,7 @@ def test_net_float16():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.squeeze()))
def test_net_float32():
x = np.random.randn(1, 16, 1, 1).astype(np.float32)
net = Net()
@ -104,10 +117,10 @@ def test_net_float32():
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.squeeze()))
def test_net_float64():
x = np.random.randn(1, 16, 1, 1).astype(np.float64)
net = Net()
output = net(Tensor(x))
print(output.asnumpy())
assert (np.all(output.asnumpy() == x.squeeze()))

@ -20,7 +20,10 @@ import numpy as np
import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
context.set_context(mode=context.GRAPH_MODE, device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -35,9 +38,11 @@ class Net(nn.Cell):
'normal', [2, 3, 3, 4]), name='gradient')
self.momentum = Parameter(initializer(
'normal', [1, ]), name='momentum')
def construct(self):
return self.apply_momentum(self.variable, self.accumulation, self.learning_rate, self.gradient, self.momentum)
def test_net():
apply_momentum = Net()
output = apply_momentum()

@ -21,7 +21,10 @@ import numpy as np
import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
context.set_context(device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -29,11 +32,11 @@ class Net(nn.Cell):
# self.dout = Parameter(initializer(
# 'normal', [2, 3, 3, 4]), name='dout')
@ms_function
def construct(self, dout):
return self.bias_add_grad(dout)
dout = np.ones([2, 3, 4, 4]).astype(np.float32)
bias_add_grad = Net()
output = bias_add_grad(Tensor(dout))

@ -21,17 +21,20 @@ import numpy as np
import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
context.set_context(device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
self.bias_add_grad = G.BiasAddGrad()
@ms_function
def construct(self, dout):
return self.bias_add_grad(dout)
def test_net():
dout = np.random.rand(1, 1001).astype(np.float32)
bias_add_grad = Net()

@ -20,7 +20,10 @@ import numpy as np
import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
context.set_context(device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -37,13 +40,11 @@ class Net(nn.Cell):
self.w = Parameter(initializer(
'normal', [64, 3, 7, 7]), name='w')
@ms_function
def construct(self, x):
return self.conv(x, self.w)
def test_net():
x = np.random.randn(32, 3, 224, 224).astype(np.float32)
conv = Net()

@ -21,8 +21,10 @@ import numpy as np
import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
context.set_context(device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -35,6 +37,7 @@ class Net(nn.Cell):
def construct(self, x, out):
return self.conv2d_grad(out, x, self.get_shape(self.y))
x = Tensor(np.array([[[
[3, 0, 1, 2, 7, 4],
[1, 5, 8, 9, 3, 1],

@ -21,8 +21,10 @@ import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
from mindspore.ops.composite import GradOperation
context.set_context(device_target="Ascend")
class Grad(nn.Cell):
def __init__(self, network):
super(Grad, self).__init__()
@ -33,6 +35,7 @@ class Grad(nn.Cell):
def construct(self, input, output_grad):
return self.grad(self.network)(input, output_grad)
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -53,6 +56,7 @@ class Net(nn.Cell):
def construct(self, x):
return self.conv(x, self.w)
def test_net():
x = np.ones([32, 2048, 7, 7]).astype(np.float32)
sens = np.ones([32, 512, 7, 7]).astype(np.float32)

@ -20,7 +20,10 @@ import numpy as np
import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
context.set_context(device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -30,6 +33,7 @@ class Net(nn.Cell):
def construct(self, x):
return self.dense(x)
def test_net():
x = np.random.randn(32, 2048).astype(np.float32)
net = Net()

@ -21,8 +21,10 @@ import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
from mindspore.ops.composite import GradOperation
context.set_context(device_target="Ascend")
class Grad(nn.Cell):
def __init__(self, network):
super(Grad, self).__init__()
@ -33,6 +35,7 @@ class Grad(nn.Cell):
def construct(self, input, output_grad):
return self.grad(self.network)(input, output_grad)
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -41,6 +44,7 @@ class Net(nn.Cell):
def construct(self, x):
return self.dense(x)
def test_net():
x = np.random.randn(32, 2048).astype(np.float32)
sens = np.random.randn(32, 1001).astype(np.float32)

@ -17,6 +17,7 @@ from mindspore.ops import operations as P
import mindspore.nn as nn
import numpy as np
import mindspore.context as context
context.set_context(mode=context.GRAPH_MODE,
device_target="Ascend")

@ -21,6 +21,7 @@ import mindspore.context as context
context.set_context(device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()

@ -20,7 +20,10 @@ import numpy as np
import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
context.set_context(mode=context.GRAPH_MODE, device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -45,4 +48,3 @@ def test_net():
print("***********output y*********")
print(output.asnumpy())

@ -21,8 +21,11 @@ import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
from mindspore.ops.composite import GradOperation
# context.set_context(mode=context.GRAPH_MODE, device_target="Ascend")
context.set_context(device_target="Ascend")
class Grad(nn.Cell):
def __init__(self, network):
super(Grad, self).__init__()
@ -33,6 +36,7 @@ class Grad(nn.Cell):
def construct(self, input, output_grad):
return self.grad(self.network)(input, output_grad)
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()

@ -20,6 +20,8 @@ from mindspore import Tensor
from mindspore.common.api import ms_function
context.set_context(device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()

@ -20,7 +20,10 @@ import numpy as np
import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
context.set_context(device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -30,9 +33,11 @@ class Net(nn.Cell):
def construct(self, x1, x2):
return self.matmul(x1, x2)
x1 = np.random.randn(1, 3).astype(np.float32)
x2 = np.random.randn(3, 4).astype(np.float32)
def test_net():
matmul = Net()
output = matmul(Tensor(x1), Tensor(x2))

@ -20,12 +20,13 @@ import numpy as np
import mindspore.context as context
context.set_context(device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
self.maxpool = P.MaxPool(pad_mode="SAME", window=3, stride=2)
@ms_function
def construct(self, x):
output = self.maxpool(x)

@ -19,6 +19,7 @@ from mindspore.common.api import ms_function
import numpy as np
import mindspore.context as context
from mindspore.ops.composite import GradOperation
context.set_context(device_target="Ascend")

@ -21,8 +21,10 @@ import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
from mindspore.ops.composite import GradOperation
context.set_context(device_target="Ascend")
class Grad(nn.Cell):
def __init__(self, network):
super(Grad, self).__init__()
@ -33,6 +35,7 @@ class Grad(nn.Cell):
def construct(self, input, output_grad):
return self.grad(self.network)(input, output_grad)
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -46,6 +49,7 @@ class Net(nn.Cell):
output = self.maxpool(x)
return output[0]
def test_net():
x = np.random.randn(32, 64, 112, 112).astype(np.float32)
sens = np.random.randn(32, 64, 56, 56).astype(np.float32)

@ -20,7 +20,10 @@ import numpy as np
import mindspore.context as context
from mindspore.common.initializer import initializer
from mindspore.common.parameter import Parameter
context.set_context(device_target="Ascend")
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
@ -30,6 +33,7 @@ class Net(nn.Cell):
def construct(self, x):
return self.relu(x)
def test_net():
x = np.random.randn(2, 3, 3, 4).astype(np.float32)
relu = Net()

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save