testing.create_workload用于创建基准图像分类工作量。
在使用testing.create_workload(f)的过程中出现如下问题:
这一般是因为定义变量的名称有问题,例如:
def test_quantize_weight_conv2d():
""" the channel is a multiple of 4"""
dtype = "float32"
dshape = (1, 3, 8, 8)
data = relay.var("x", shape=dshape,dtype=dtype)
w0 = relay.var("w0")
conv0 = relay.nn.conv2d(data, w0,
kernel_size=(3, 3),
padding=(1, 1),
channels=4)
f = relay.Function(relay.analysis.free_vars(conv0), conv0)
mod, params = testing.create_workload(f)
graph, lib, params = relay.build(mod, 'llvm', params=params)
上面的data和w0都有问题:
输入的data的名称应该为”data”
权重的名称应该以”weight”结尾
例如:
def test_quantize_weight_conv2d():
""" the channel is a multiple of 4"""
dtype = "float32"
dshape = (1, 3, 8, 8)
data = relay.var("data", shape=dshape,dtype=dtype)
w0 = relay.var("w0_weight")
conv0 = relay.nn.conv2d(data, w0,
kernel_size=(3, 3),
padding=(1, 1),
channels=4)
w1 = relay.var("w1_weight")
z = relay.nn.conv2d(conv0, w1,
kernel_size=(3, 3),
padding=(1, 1),
channels=4)
f = relay.Function(relay.analysis.free_vars(conv0), conv0)
mod, params = testing.create_workload(f)
graph, lib, params = relay.build(mod, 'llvm', params=params)