1 Segmentation Fault (core dumped)
例如,在测试relay.nn.conv2d_transpose转conv2d的测试用例中,出现如下错误:
而debug也几乎也无法定位到出错的代码。
通过打断点的方式,逐步缩小范围,发现其中调用了MakeExpandPixel函数,而该函数调用了vacc_expandpixel算子,但是,在当前分支却找不到该算子的定义(只在src/relay/pass/vacc/pipeline_grouping.cc中通过RELAY_REGISTER_OP(“vacc_expandpixel”)注册了算子, 只要注册了算子,调用算子不会有提示)。也就是说该算子是没有定义的,所以才导致了上面的错误。
也就是说,在tvm中,调用已注册但未定义的算子,编译阶段不会出错,但是在运行阶段会出现上面的Segmentation Fault (core dumped)错误。
2 Incompatible broadcast type

这个问题是weight (int 8)被数据对齐成了TensorType([8, 8, 3, 3], int8), 而scale (float)数据对齐是TensorType([4, 4, 3, 3], float32) 二者的shape不一样,无法broadcast
3 在使用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)
上面的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)
3 TVMError: Check failed: ObjectTypeChecker: :Check(ptr): Expected type List[Tensor] but get Tensor 

这有可能是算子的compute的实现返回的不是一个包含tensor的list,而是一个tensor
例如:
@_reg.register_compute("vacc.op.annotation.qt_after_conv")def simulated_quantize_compute(attrs, inputs, out_type, target):"""Compiler for qt_after_conv."""assert len(inputs) == 2data, _ = inputsreturn topi.identity(data)
上面的返回值是topi.identity(data),应该改成:
@_reg.register_compute("vacc.op.annotation.qt_after_conv")def simulated_quantize_compute(attrs, inputs, out_type, target):"""Compiler for qt_after_conv."""assert len(inputs) == 2data, _ = inputsreturn [topi.identity(data)]
4 在114上计算KL散度问题,弹出如下错误
5 在使用KL散度计算时,发现计算出的值小于0
原因是:咱们的计算KL散度的函数只支持float32或float16类型。而np默认是float64

