sophgo / tpu-mlir

Machine learning compiler based on MLIR for Sophgo TPU.
Other
611 stars 153 forks source link

INT8量化报错 #153

Open GengyuXu opened 11 months ago

GengyuXu commented 11 months ago

芯片1684 模型yolov5s

npz compare FAILED. compare output_Concat: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:00<00:00, 25.02it/s] Traceback (most recent call last): File "/workspace/tpu-mlir/tpu-mlir_v1.2.8-g32d7b3ec-20230802/python/tools/model_deploy.py", line 286, in tool.lowering() File "/workspace/tpu-mlir/tpu-mlir_v1.2.8-g32d7b3ec-20230802/python/tools/model_deploy.py", line 103, in lowering tool.validate_tpu_mlir() File "/workspace/tpu-mlir/tpu-mlir_v1.2.8-g32d7b3ec-20230802/python/tools/model_deploy.py", line 190, in validate_tpu_mlir f32_blobs_compare(self.tpu_npz, self.ref_npz, self.tolerance, self.excepts) File "/workspace/tpu-mlir/tpu-mlir_v1.2.8-g32d7b3ec-20230802/python/utils/mlir_shell.py", line 172, in f32_blobs_compare _os_system(cmd) File "/workspace/tpu-mlir/tpu-mlir_v1.2.8-g32d7b3ec-20230802/python/utils/mlir_shell.py", line 50, in _os_system raise RuntimeError("[!Error]: {}".format(cmd_str))

请问有大佬能帮忙解答一下吗

callmelaoyi commented 11 months ago

你跑的是readme吗?如果是readme的话,你提供的错误信息有点不够,推测可能是环境没装好

GengyuXu commented 11 months ago

你跑的是readme吗?如果是readme的话,你提供的错误信息有点不够,推测可能是环境没装好

我用这个工具转fp32 测试过yolov8的bmodel是没有问题的,我是按照文档的步骤走的,现在是想走量化发现报错了。

callmelaoyi commented 11 months ago

提供的错误信息不全,log信息截全一点

GengyuXu commented 11 months ago

提供的错误信息不全,log信息截全一点 不好意思回复晚了

SOPHGO Toolchain v1.2.8-g32d7b3ec-20230802 [Running]: tpuc-opt yolov8s-origin.mlir --chip-assign="chip=bm1684" --import-calibration-table="file=yolov8s-origin_cali_table asymmetric=False" --chip-top-optimize --convert-top-to-tpu="mode=INT8 asymmetric=False" --canonicalize -o yolov8s-origin_bm1684_int8_sym_tpu.mlir [Success]: tpuc-opt yolov8s-origin.mlir --chip-assign="chip=bm1684" --import-calibration-table="file=yolov8s-origin_cali_table asymmetric=False" --chip-top-optimize --convert-top-to-tpu="mode=INT8 asymmetric=False" --canonicalize -o yolov8s-origin_bm1684_int8_sym_tpu.mlir [CMD]: model_runner.py --input yolov8s-origin_in_f32.npz --model yolov8s-origin_bm1684_int8_sym_tpu.mlir --output yolov8s-origin_bm1684_int8_sym_tpu_outputs.npz [##################################################] 100% [Running]: npz_tool.py compare yolov8s-origin_bm1684_int8_sym_tpu_outputs.npz yolov8s-origin_top_outputs.npz --tolerance 0.85,0.45 --except - -vv compare output0_Concat: 0%| | 0/1 [00:00<?, ?it/s][output0_Concat ] NOT_SIMLIAR [FAILED] (1, 84, 8400) float32 cosine_similarity = 0.766871 euclidean_similarity = -0.612472 sqnr_similarity = -16.174872 top-k: idx-t target idx-r ref 20162 40.069126 5599 637.0387 20164 40.069126 5519 636.8641 20152 40.069126 5679 636.829 20153 40.069126 799 636.739 20156 40.069126 719 636.5047 20150 40.069126 5759 636.4254 20163 40.069126 5439 636.3794 20167 40.069126 879 636.27893 20166 40.069126 3679 636.2008 20148 40.069126 959 636.146 1 compared 0 passed 0 equal, 0 close, 0 similar 1 failed 0 not equal, 1 not similar min_similiarity = (0.7668710350990295, -0.6124719814439703, -16.174871921539307) Target yolov8s-origin_bm1684_int8_sym_tpu_outputs.npz Reference yolov8s-origin_top_outputs.npz npz compare FAILED. compare output0_Concat: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 22.17it/s] Traceback (most recent call last): File "/workspace/tpu-mlir/tpu-mlir_v1.2.8-g32d7b3ec-20230802/python/tools/model_deploy.py", line 286, in tool.lowering() File "/workspace/tpu-mlir/tpu-mlir_v1.2.8-g32d7b3ec-20230802/python/tools/model_deploy.py", line 103, in lowering tool.validate_tpu_mlir() File "/workspace/tpu-mlir/tpu-mlir_v1.2.8-g32d7b3ec-20230802/python/tools/model_deploy.py", line 190, in validate_tpu_mlir f32_blobs_compare(self.tpu_npz, self.ref_npz, self.tolerance, self.excepts) File "/workspace/tpu-mlir/tpu-mlir_v1.2.8-g32d7b3ec-20230802/python/utils/mlir_shell.py", line 172, in f32_blobs_compare _os_system(cmd) File "/workspace/tpu-mlir/tpu-mlir_v1.2.8-g32d7b3ec-20230802/python/utils/mlir_shell.py", line 50, in _os_system raise RuntimeError("[!Error]: {}".format(cmd_str)) RuntimeError: [!Error]: npz_tool.py compare yolov8s-origin_bm1684_int8_sym_tpu_outputs.npz yolov8s-origin_top_outputs.npz --tolerance 0.85,0.45 --except - -vv

GengyuXu commented 11 months ago

提供的错误信息不全,log信息截全一点

补充 重新新建一个docker操作 coco数据集的yolov5可以量化,但是yolov8不成功,错误内容和上一个回复的一样,和yolov5一样的转化指令

callmelaoyi commented 11 months ago

晓得了,应该是yolov8s这个模型量化的效果不好,建议你加一下官方的wx群,然后问一下工作人员

dzy1128 commented 3 months ago

我将自己的v8模型转换成onnx,编译的时候也出现这个错,请问你解决了吗