Ejemplo n.º 1
0
def test_F_concat():
    net = FConcatOpr()
    data1 = mge.tensor(np.random.random((1, 3, 24, 24)).astype(np.float32))
    data2 = mge.tensor(np.random.random((1, 3, 24, 24)).astype(np.float32))
    traced_module, tm_result = get_traced_module(net, [data1, data2])
    print(traced_module.flatten().graph)
    _test_convert_result([data1, data2], traced_module, tm_result)
Ejemplo n.º 2
0
def test_convrelu():
    net = ConvRelu2dOpr()
    data = mge.tensor(net.data)
    traced_module, tm_result = get_traced_module(net, data)
    print(traced_module.flatten().graph)

    _test_convert_result(data, traced_module, tm_result)
Ejemplo n.º 3
0
def test_conv(mode):
    net = ConvOpr(mode)
    data = mge.tensor(np.random.random((1, 3, 224, 224)).astype(np.float32))
    traced_module, tm_result = get_traced_module(net, data)
    print(traced_module.flatten().graph)

    _test_convert_result(data, traced_module, tm_result)
Ejemplo n.º 4
0
def test_pooling(mode):
    if mge.__version__ > "0.6.0" and mode == "avg":
        return
    net = PoolOpr(mode)
    traced_module, tm_result = get_traced_module(net, mge.tensor(net.data))
    print(traced_module.flatten().graph)

    _test_convert_result(mge.tensor(net.data), traced_module, tm_result)
Ejemplo n.º 5
0
def test_reshape():
    net = ReshapeOpr(fix_batch=True)
    traced_module, tm_result = get_traced_module(net, mge.tensor(net.data))
    print(traced_module.flatten().graph)
    _test_convert_result(mge.tensor(net.data),
                         traced_module,
                         tm_result,
                         nhwc=False)
Ejemplo n.º 6
0
def test_convbnrelu(has_bias):
    net = ConvBnRelu2dOpr(has_bias)
    net.eval()
    data = mge.tensor(net.data)
    traced_module, tm_result = get_traced_module(net, data)
    print(traced_module.flatten().graph)

    _test_convert_result(data, traced_module, tm_result)
Ejemplo n.º 7
0
def test_slice():
    net = SubtensorOpr()
    tm, tm_result = get_traced_module(net, mge.tensor(net.data))
    print(tm.flatten().graph)
    _test_convert_result(mge.tensor(net.data),
                         tm,
                         tm_result,
                         nhwc=False,
                         nhwc2=False)
Ejemplo n.º 8
0
def test_model(model):
    data = np.ones((1, 3, 224, 224)).astype(np.float32)
    if megengine.__version__ < "1.1.0":
        commit_id = "dc2f2cfb228a135747d083517b98aea56e7aab92"
    else:
        commit_id = None
    net = megengine.hub.load("megengine/models",
                             model,
                             use_cache=False,
                             commit=commit_id,
                             pretrained=True)
    net.eval()
    traced_module, tm_result = get_traced_module(net, mge.tensor(data))
    _test_convert_result(mge.tensor(data), traced_module, tm_result, 1e-4)
Ejemplo n.º 9
0
def test_resize():
    net = ResizeOpr()
    traced_module, tm_result = get_traced_module(net, mge.tensor(net.data))
    print(traced_module.flatten().graph)
    _test_convert_result(mge.tensor(net.data), traced_module, tm_result)
Ejemplo n.º 10
0
def test_pad():
    net = PadOpr()
    traced_module, tm_result = get_traced_module(net, mge.tensor(net.data))
    _test_convert_result(mge.tensor(net.data), traced_module, tm_result)
Ejemplo n.º 11
0
def test_elemwise(mode):
    net = ElemwiseOpr(mode)
    traced_module, tm_result = get_traced_module(net, mge.tensor(net.data))
    print(traced_module.flatten().graph)

    _test_convert_result(mge.tensor(net.data), traced_module, tm_result)