Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support paddle_yolov5s transform to MLIR #142

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

hlt-bkx
Copy link

@hlt-bkx hlt-bkx commented Oct 23, 2023

adding some files(for example:paddleCoverter.py) to convert the model from paddle_yolov5s to MLIR

for i in range(len(out_name)):
outputs[out_name[i]] = out_data[i]

#返回的是一个字典:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请用英文注释,删除非必要注释。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,我调整一下

paddle.enable_static()
exe = paddle.static.Executor(paddle.CPUPlace())
[inference_program, feed_target_names, fetch_targets] = (
paddle.static.load_inference_model('model', exe))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

读的pdmodel路径是当前路径下的model.pdmodel,不是paddle_file输入的任意路径。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的 这个我也调整一下

self.init_MLIRImporter()
self.preprocess_args = {}
if 'channel_format' in preprocess_args:
if preprocess_args['channel_format'] != "none":

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Traceback (most recent call last):
File "/workspace/tpu-mlir/python/tools/model_transform.py", line 296, in
tool.model_transform(args.mlir, args.add_postprocess)
File "/workspace/tpu-mlir/python/tools/model_transform.py", line 50, in model_transform
self.converter.generate_mlir(mlir_origin)
File "/workspace/tpu-mlir/python/transform/paddleConverter.py", line 395, in generate_mlir
input_ = self.mlir.create_input_op(self.get_loc(_name),idx,self.preprocess_args)
File "/workspace/tpu-mlir/python/transform/MLIRImporter.py", line 183, in create_input_op
input_op = top.InputOp(**init_args)
TypeError: InputOp.init() got an unexpected keyword argument 'preprocess_list'

Copy link
Author

@hlt-bkx hlt-bkx Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请问您执行的命令是这个吗
model_transform.py
--model_name paddle_yolov5s
--model_def ../model.pdmodel
--input_shapes [[1,3,640,640]]
--output_name 311,457,587
--mean 0.0,0.0,0.0
--scale 0.0039216,0.0039216,0.0039216
--keep_aspect_ratio
--pixel_format rgb
--test_input ../dog.jpg
--test_result paddle_yolov5s_top_outputs.npz
--mlir paddle_yolov5s.mlir

Copy link

@zhengqianisme zhengqianisme Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

您好,不是这个问题。
运行: model_transform.py --model_name model --model_def ../regression/model/model.pdmodel --input_shapes [[1,3,640,640]] --mean 0.0,0.0,0.0 --scale 0.0039216,0.0039216,0.0039216 --keep_aspect_ratio --pixel_format rgb --output_names 311,457,587 --test_input ../regression/image/dog.jpg --test_result yolov5s_top_outputs.npz --mlir yolov5s.mlir
报错:
Traceback (most recent call last):
File "/workspace/tpu-mlir/python/tools/model_transform.py", line 295, in
tool.model_transform(args.mlir, args.add_postprocess)
File "/workspace/tpu-mlir/python/tools/model_transform.py", line 50, in model_transform
self.converter.generate_mlir(mlir_origin)
File "/workspace/tpu-mlir/python/transform/paddleConverter.py", line 395, in generate_mlir
input_ = self.mlir.create_input_op(self.get_loc(_name),idx,self.preprocess_args)
File "/workspace/tpu-mlir/python/transform/MLIRImporter.py", line 183, in create_input_op
input_op = top.InputOp(**init_args)
TypeError: InputOp.init() got an unexpected keyword argument 'preprocess_list'
在PaddleConverter初始化时,缺少对preprocess_args['preprocess_list']的处理。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不好意思,我这边重新更换一下环境运行一下,看看如何解决这个问题。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

您好,我在最新环境下运行后也报了您那个错误。然后我重新调整了里面的转换代码,已经重新提交了代码,目前我这边运行结果是可以了,麻烦您有空试一下

@zhengqianisme
Copy link

您好,在paddle转mlir后,没有准确选取需要compare的算子进行compare。检查两者的name是否能匹配。
[Running]: npz_tool.py compare yolov5s_top_outputs.npz paddle_yolov5s_ref_outputs.npz --tolerance 0.99,0.99 --except - -vv
0it [00:00, ?it/s]0 compared
0 passed
0 equal, 0 close, 0 similar
0 failed
0 not equal, 0 not similar
min_similiarity = (1.0, 1.0, inf)

@hlt-bkx
Copy link
Author

hlt-bkx commented Nov 21, 2023

好的,我补充一下

if chip == 'BM1688' or chip == 'CV186X':
lib_so = 'libcmodel_1688.so'
if chip == 'BM1686' or chip == 'CV186X':
lib_so = 'libcmodel_1686.so'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if chip == 'BM1688' or chip == 'CV186X':
lib_so = 'libcmodel_1688.so'

Copy link
Author

@hlt-bkx hlt-bkx Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

您好,请问那个昨天的INT8量化问题后面解决了吗?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

解决了,不存在问题,我就撤回了comment。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants