testing.create_workload用于创建基准图像分类工作量。
    在使用testing.create_workload(f)的过程中出现如下问题:
    image.png
    这一般是因为定义变量的名称有问题,例如:

    1. def test_quantize_weight_conv2d():
    2. """ the channel is a multiple of 4"""
    3. dtype = "float32"
    4. dshape = (1, 3, 8, 8)
    5. data = relay.var("x", shape=dshape,dtype=dtype)
    6. w0 = relay.var("w0")
    7. conv0 = relay.nn.conv2d(data, w0,
    8. kernel_size=(3, 3),
    9. padding=(1, 1),
    10. channels=4)
    11. f = relay.Function(relay.analysis.free_vars(conv0), conv0)
    12. mod, params = testing.create_workload(f)
    13. graph, lib, params = relay.build(mod, 'llvm', params=params)

    上面的data和w0都有问题:
    输入的data的名称应该为”data”
    权重的名称应该以”weight”结尾
    例如:

    1. def test_quantize_weight_conv2d():
    2. """ the channel is a multiple of 4"""
    3. dtype = "float32"
    4. dshape = (1, 3, 8, 8)
    5. data = relay.var("data", shape=dshape,dtype=dtype)
    6. w0 = relay.var("w0_weight")
    7. conv0 = relay.nn.conv2d(data, w0,
    8. kernel_size=(3, 3),
    9. padding=(1, 1),
    10. channels=4)
    11. w1 = relay.var("w1_weight")
    12. z = relay.nn.conv2d(conv0, w1,
    13. kernel_size=(3, 3),
    14. padding=(1, 1),
    15. channels=4)
    16. f = relay.Function(relay.analysis.free_vars(conv0), conv0)
    17. mod, params = testing.create_workload(f)
    18. graph, lib, params = relay.build(mod, 'llvm', params=params)