MingkangW opened a new pull request, #15529: URL: https://github.com/apache/tvm/pull/15529
The type of add op`s output is activation, it should annotate by QAnnotateKind.ACTIVATION. If not, the graph will cast int32 into int8 directly without quantized, when quantize resnet. It will product overflow error, and it won`t prompt when infer the model. The resnet18_v1 test case is below. before fixed %703 = add(%701, %702) /* ty=Tensor[(1, 512, 7, 7), int32] */; %704 = nn.relu(%703) /* ty=Tensor[(1, 512, 7, 7), int32] */; %705 = cast(%704, dtype="int8") /* ty=Tensor[(1, 512, 7, 7), int8] */; %706 = annotation.stop_fusion(%705) /* ty=Tensor[(1, 512, 7, 7), int8] */; after fixed %443 = add(%441, %442) /* ty=Tensor[(1, 512, 7, 7), int32] */; %444 = nn.relu(%443) /* ty=Tensor[(1, 512, 7, 7), int32] */; %445 = cast(%444, dtype="int64") /* ty=Tensor[(1, 512, 7, 7), int64] */; %446 = fixed_point_multiply(%445, multiplier=1439683968, shift=-2) /* ty=Tensor[(1, 512, 7, 7), int64] */; %447 = clip(%446, a_min=-127f, a_max=127f) /* ty=Tensor[(1, 512, 7, 7), int64] */; %448 = cast(%447, dtype="int32") /* ty=Tensor[(1, 512, 7, 7), int32] */; %449 = cast(%448, dtype="int8") /* ty=Tensor[(1, 512, 7, 7), int8] */; %450 = annotation.stop_fusion(%449) /* ty=Tensor[(1, 512, 7, 7), int8] */; -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org